=0; rev[j++] = str[i--])"/>
Home / C Programming / Arrays :: Discussion

Discussion :: Arrays

  1. What will be the correct output of the following program?

    #include<string.h>

    void main()

    {

    char str[] = "C EXAMINATION", rev[17];

    int i = strlen(str), j=0;

    for( ; i>=0; rev[j++] = str[i--])

    rev[j] = str[j] ;

    puts(rev);

    }

  2. A.

     NOITANIMAXE C

    B.

     NOITANIMAXE

    C.

     C

    D.

     No output at all.

    E.

     Syntax error

    View Answer

    Workspace

    Answer : Option D

    Explanation :

    As i is with the length of string and hence in array rev the contents are copied as "\0 NOITANIMAXE C". But while displaying those contents with puts function it stops because of the first character '\0' and hence no output.


Be The First To Comment