squeeze ur brain

ish_nalini

ish_nalini

@ish-nalini-lT8U2a Oct 25, 2024
what is the o/p:

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

Replies

Welcome, guest

Join CrazyEngineers to reply, ask questions, and participate in conversations.

CrazyEngineers powered by Jatra Community Platform

  • sristi

    sristi

    @sristi-483Qff 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

    @pad-cAxwqR 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

    @mahul-ZxpiLA Nov 15, 2007

    yeah pad is right this gotta depend on compiler and architecture
  • Yamini L

    Yamini L

    @yamini-uMEVDQ 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

    @ambuja-28-TeGMOY Mar 27, 2008

    we cant write sizeof() inside printf .so it 'll give error
  • sattu21

    sattu21

    @sattu21-goMlVo Mar 28, 2008

    the answer wud be
    1 1
  • pallavi agarwal

    pallavi agarwal

    @pallavi-agarwal-c3jWrI Mar 29, 2008

    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

    @friendster7-oVJr9h Mar 30, 2008

    the answer will be 1 and 1 too.and we can write sizeof() in printf their will be no error.