Web for Nerds !!!

Posts Tagged ‘c programming’

Evaluate a=b+++++c;

How will a ANSI C compiler parse the following C snippet ? a=b+++++c; Select the right answer (i) a = (b++) + (++c); // because of common sense (ii) a = ((b++)++) + c ; // evaluated left to right (iii) a = b + (++(++c)); //

Read more

Value Of Pi

Why is pre-defining Π (Pi) value as a macro or a constant is a better choice in most common use cases, rather than implementing Π (Pi) function to compute value. Hint: 22/7 > Π

Read more

float and double, the inescapable difference

Its very common question, but lets see your reasoning. Why does this code snippet gives a contradictory result ? For example, call below function foo ( 22 / 7 , 22 / 7 ) from main(). void foo(float f, double d) { printf("f= %f d= %lf\n", f,

Read more

ternary operator assignment

I have asked this question to several job aspirant software engineers in many of my interviews, and hardly few able to get it right. Identify the core problem with this code. int main (int argv, char * argc) { int i, j=43420, k=17440, m=20, l=30,p; p >

Read more