Someone please help me in understanding the following output -
Problem *1>.*
#include<stdio.h>
#ifdef getchar //this expression is evaluated to zero.....why is so
happening ??........getchar is defined as macro in stdio.h.....i mean else
part shouldn't be executed which is happening
#undef getchar
#else
#define getchar scanf("%c",&ch);
#endif
main()
{
char ch;
int c;
c=getchar;
printf("%d",c);
}
*OUTPUT- 1*
*
*
*
*
*2>.*
#include<stdio.h>
void main()
{
long x;
float t;
scanf("%f",&t);
printf("%d\n",t);
x=90;
printf("%ld\n",x);
{
x=1;
printf("%f\n",x);
{
x=30;
printf("%f\n",x);
}
printf("%f\n",x);
}
x==9;
printf("%f\n",x);
}
*OUTPUT(INPUT IS 2) -*
*2*
*0*
*90*
*2.000000*
*2.000000*
*2.000000*
*2.000000*
*
*
In this problem i failed to Understand why t is printed as 0 (though float
is converted to integer by truncation of the fractional part)
and how the value of t is transferred to x....looks very strange to me !!
*3>.*
#include<stdio.h>
main()
{
printf("\nACM-CIC"+3);
printf(4+"\nACM-CIC");
}
*OUTPUT -*
*M-CIC-CIC*
*
*
What does +3 and +4 doing and does it matter to use them before the format
string or after it ??
*4>.*
#include<stdio.h>
main()
{
long long i=50;
i==1000000000000000000000000000000000000000;
printf("i=%d\n\n%lld",sizeof(i),i);
//system("pause");
}
*OUTPUT -*
*i=8*
*
*
*50*
*
*
Assigning very large value to i isn't changing it's value.....why is so
happening ??
and the last one
*5>.*
#include<stdio.h>
main()
{
static int i=0;
if(i<=-1)
printf("\nBull's Eye");
else
{
main();
_exit(1);
}
i++;
}
*OUTPUT -*
*segementation fault*
*
*
What's Wrong with the above Code due to which it is giving Runtime
error....plz help me pointing it out !!
--
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/algogeeks?hl=en.