Open In App

C | String | Question 6

Like Article
Like
Save
Share
Report

C




#include<stdio.h>
int main()
{
    char str[] = \"GeeksQuiz\";
    printf(\"%s %s %s \", &str[5], &5[str], str+5);
    printf(\"%c %c %c \", *(str+6), str[6], 6[str]);
    return 0;
}


(A)

Runtime Error

(B)

Compiler Error

(C)

uiz uiz uiz u u u

(D)

Quiz Quiz Quiz u u u


Answer: (D)

Explanation:

The program has no error. All of the following expressions mean same thing &str[5] &5[str] str+5 Since compiler converts the array operation in pointers before accessing the array elements, all above result in same address. Similarly, all of the following expressions mean same thing. *(str+6) str[6] 6[str]


Quiz of this Question
Please comment below if you find anything wrong in the above post


Last Updated : 05 Feb, 2013
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads