View Feed
group-icon
Coffee Room
Discuss anything here - everything that you wish to discuss with fellow engineers.
12838 Members
Join this group to post and comment.
ish_nalini
ish_nalini • Jan 20, 2007

squeeze ur brain

what is the o/p:

char a='a';
printf("%d %d",sizeof(a),sizeof('a'));
sristi
sristi • Jan 21, 2007
i guesso/p will be 2 and 1since printf executes 4m left to right ..sizeof('a') =1 byte..sizeof a char and sizeof(a)=2 bytes
pad
pad • Jan 24, 2007
ish_nalini
what is the o/p:

char a='a';
printf("%d %d",sizeof(a),sizeof('a'));

answer is architecture dependant.

sizeof (datatype) are always architecture dependant.... unless you use virtual machines like JVM.
mahul
mahul • Nov 15, 2007
yeah pad is right this gotta depend on compiler and architecture
Yamini L
Yamini L • Mar 23, 2008
i think it would be 2 and 1...for int 2bytes and for char 1 byte...that also depends on the architecture of ur system
ambuja 28
ambuja 28 • Mar 27, 2008
we cant write sizeof() inside printf .so it 'll give error
sattu21
sattu21 • Mar 29, 2008
the answer wud be
1 1
according 2 me the answer wud be 1 1 & also there is no need to give char a='a' ,we can simply give char a coz thats not making any difference basically.
friendster7
friendster7 • Mar 30, 2008
the answer will be 1 and 1 too.and we can write sizeof() in printf their will be no error.

Share this content on your social channels -