+ 1
Why do I always get the output as 64..???
3 Respostas
+ 11
#include <stdio.h>
int main()
{
int i=-4,j,num;
printf("num = %d\n", num);
j=(num<0?0:num*num);
printf ("%d\n",j);
return 0;
}
Since you have not initialized num variable it has some garbage value which is 8.
As 8 is greater than 0, the conditional expression executes the false statement which is 8*8 and that is why it prints 64
+ 2
I have a hypothesis that it gives the number the value of it's required memory size as default, if no value is given...
The hypothesis wasn't true, other numeric datatypes gave 0, except int and long.
+ 1
Thanks bro.. :)