Predict the output!

Q. I have an error free C code, am writing for you. This code searches for the string “C+Trivia” in Google. Surprised, how it can be? #include “stdio.h” #include “stdlib.h” int main() { http://www.google.com; char* str; printf(“C + Trivia”,str); puts(str); return 0; } Read more about this program here.

What is being returned?

#include “stdio.h” int main() { int i=10,j=20,k; k=addsub(i,j); printf(“k=%d”,k); return 0; } addsub(int c, int d) { int x,y; x=c-d;y=c+d; return (x,y); } it’s the value of y which is returned here, because return statement never gives error if you write more than one arguments to it separated by a comma..it’s the last argument which… Continue reading What is being returned?

A little C sip

Here is a code: #include “stdio.h” int main() { float a=4; int i=2; printf(“%f\t%d”,i/a,i/a); printf(“\n%d\t%f”,i/a,i/a); return 0; } i expected the output to be: 0.500000 0 0 0.500000 but unfortunately..itsn’t not the same. The reason is the first printf conversion is messed up a little leading the second printf to not work in a predictable… Continue reading A little C sip