brain teaser

anandkumarjha

anandkumarjha

@anandkumarjha-jzdDMA Oct 26, 2024
main()
{
char thought[2][30]={"Don't walk infront me..","i am not follow"};
printf("%c%c",*(thought[0]9),*(*(thought 0)5));
}
What will be the output of this code???

Replies

Welcome, guest

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

CrazyEngineers powered by Jatra Community Platform

  • anandkumarjha

    anandkumarjha

    @anandkumarjha-jzdDMA Oct 4, 2010

    what will be the output of the following codes any why????please explain....
    #include<stdio.h>
    #include<conio.h>
    void main()
    {
    printf("%d",printf("%d %d",2,2)& printf("%d %d",2,2));
    getch();
    }




    #include<stdio.h>
    #include<conio.h>
    void main()
    {
    printf("%d",printf("%d %d",2,2)& printf("%d %d",2,2));
    getch();
    }
    although thay look like same but they different from each other
  • sam_from_hell

    sam_from_hell

    @sam-from-hell-8gE2gC Oct 4, 2010

    anandkumarjha
    main()
    {
    char thought[2][30]={"Don't walk infront me..","i am not follow"};
    printf("%c%c",*(thought[0]9),*(*(thought 0)5));
    }
    What will be the output of this code???
    Its throwing up a error "Expected ')' before numeric constant"
  • silverscorpion

    silverscorpion

    @silverscorpion-iJKtdQ Oct 5, 2010

    anandkumarjha
    what will be the output of the following codes any why????please explain....
    #include<stdio.h>
    #include<conio.h>
    void main()
    {
    printf("%d",printf("%d %d",2,2)& printf("%d %d",2,2));
    getch();
    }




    #include<stdio.h>
    #include<conio.h>
    void main()
    {
    printf("%d",printf("%d %d",2,2)& printf("%d %d",2,2));
    getch();
    }
    although thay look like same but they different from each other
    I dont see any difference between the first and the second.. I think both are one and the same..

    Anyhow, for the first program, the output is,

    2 2 2 2 1

    There are 2 printf statements inside the main printf statement.. printf statement returns the number of characters it has sent to the output buffer..
    So, both the inner printf's will return 2. It becomes '2 & 2' which is 1. So, 1 is printed last..