Questions tagged [c]

For questions related to computational software and libraries written in the C programming language

C is a general purpose programming language. Originally intended for implementing system software, C and its close relatives are the principle languages used in most modern operating systems. Due to its thin layer of abstraction and low overhead, C allows efficient coding of algorithms and data structures useful for scientific computation. Use this tag for questions involving the C programming language.

137 questions
5
votes
3 answers

A clean way to compute exp(-1/x^2) near x=0 in C?

I am looking for a clean way to compute preciseley, when $x$ is very close to zero: $$\exp(-1/x^2)$$ using C. What is the best way (speed, precision, etc.) ?
mellow
  • 281
  • 1
  • 2
  • 5
3
votes
5 answers

Optimization of prime factorization in C

I am trying to teach myself some programming in C by doing the problems of project Euler. I am trying to find the largest prime factor of the number 600851475143 (Euler problem 3). I have written a code which successfully does this for numbers which…
Funzies
  • 141
  • 1
  • 3
1
vote
1 answer

Heineken Virus C program ( how to simplify and discard else if in my code)

So I have a question about simplifying my C code , This is the question : A pandemic of the Heineken virus is underway in Croatia and around the world. The National Civil Protection Headquarters plans to introduce protection measures that will take…
Aster Nash
  • 13
  • 3
0
votes
1 answer

Suming up the series $1+1/2+...+1/n$ in C

#include #include int main() { float s=0; int i, n; printf("Quantity of terms:"); scanf("%f", &n); for(i==0; i<=n-1; i++); { s=s+1/(i+1); } printf("Sum: %f", s); return 0; } Hi. I'd like to sum up the series…
Quiet_waters
  • 209
  • 1
  • 6
0
votes
1 answer

Number of decimal of float and double in C

I'm reading the following table (from https://www.tutorialspoint.com/cprogramming/c_data_types.htm ) Why the precision of the float is 6 decimal places, but I see that the float are in the interval [1.2E-38 , 3.4E38] ? So, I think that I can have…
yemino
  • 515
  • 2
  • 15
0
votes
1 answer

Water Properties IAPWS-IF97 implementation on C/C++

I'm Looking for an implementation of the IAPWS-IF97 water properties on C/C++. I'm aware of the library freesteam. However freesteam does not include all the properties I'm looking for. Particularly I need differential properties like dh/dp, dv/dp…
Marwan
  • 39
  • 3
0
votes
1 answer

How to change one bit of a 32 bit integer in C

I have three 32 bit integers a,b,c. I want to make 10th bit of a=(23 rd bit of b) xor (4th bit of c) without disturbing other bits of a. How can I do this in C programming language? a can be zero also. In that case I consider a= 00...0, 32…
user12290
  • 275
  • 2
  • 6
0
votes
1 answer

Beginning Computer Programming

I was 7 years old when I learnt BASIC. Then I learnt C and Visual Basic till the age of 13. I stopped programming for 4 years continuously, and don't remember much about it now. I have lost the skill, and need to do learn it all over again. How can…