Guys plz help me in understanding the following output
*PROBLEM 1>.*
*
*
#include<stdio.h>
main()
{
int scanf=78;
//int printf=45;
int getchar=6;
printf("%d",scanf);
printf("\n%d",getchar);
}
*OUTPUT-*
78
6
in this problem my problem is using printf and scanf as variable
names.....they are functions in the stdio.h then how are they available for
variable name ??...generally what happens is that whenever we use some name
for the function and then use that name for some variable then compiler
gives error then why in this case error is not coming ??
*PROBLEM 2>.*
#include<stdio.h>
main()
{
int i=1;
printf("\n%d %d",i^=1%2,i<<=1%2); // does it evaluate the final value of i
before printing ??
**}
*OUTPUT-*
3 3
In gcc what i have observed is that arguments of printf are evaluated from
right to left i.e i<<=1%2 is evaluated before i^=1%2...hence i first becomes
2 then 3 after XOR with 1....now output according to me should be "3
1".....but what actually is happening is that it us evaluating i and then
printing it 3 3.....can someone explain why this output is coming ?
and the last problem
*PROBLEM 3>.*
*
*
#include<stdio.h>
main()
{
enum {low='a',high='b'}tag;
char try=low;
printf("Size=%d",sizeof(tag));
switch (try)
{
case 'a':printf("aaa");break;
case 'b':printf("bbb");
case 'c':printf("ccc");
}
//system("pause");
}
in this program size of enum comes out to be 4..help me in understanding the
size of enum...how it is stored in memory??...does the size of enum depend
on number of constant in it ?....anyone link regarding that ??
--
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.