1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Explanation of output

Discussion in 'C' started by parvathynp, Mar 4, 2011.

  1. parvathynp

    parvathynp New Member

    Joined:
    Mar 3, 2011
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    main()
    {
    char *q;
    iny j;
    q=(char*)macclo(20*sizeof(char));
    for(i=0;i<3;i++)scanf("%s",(q+i));
    for(i=0;i<3;i++)printf("%c",*(q+i));
    for(i=0;i<3;i++)printf("%s",(q+i));
    }

    please send me the output and its explanation.
     
  2. lionaneesh

    lionaneesh Active Member

    Joined:
    Mar 21, 2010
    Messages:
    848
    Likes Received:
    224
    Trophy Points:
    43
    Occupation:
    Student
    Location:
    India
    The code is totally messed up!

    Here's the corrected code :-

    Code:
    #include<stdio.h>
    
    int main()
    {
        char *q;
        int i;
        q=(char*)malloc(20*sizeof(char));
        for(i=0;i<3;i++)scanf("%s",(q+i));
        for(i=0;i<3;i++)printf("%c",*(q+i));
        for(i=0;i<3;i++)printf("%s",(q+i));
        system("pause");
        return(0);
    }
    
    
    Output :-

    Code:
    1
    2
    3
    123123233
    
     

Share This Page