CameraIcon
CameraIcon
SearchIcon
MyQuestionIcon
MyQuestionIcon
1
You visited us 1 times! Enjoying our articles? Unlock Full Access!
Question

Consider the following C program segment:
char p[20];
char *s= "string";
int length = strlen (s) ;
for (i = 0 ; i < length; i++)
p[i] = s[length -i];
printf("%s", p);
The output of the program is

A
gnirts
No worries! We‘ve got your back. Try BYJU‘S free classes today!
B
no output is printed
Right on! Give the BNAT exam to get a 100% scholarship for BYJUS courses
C
gnirt
No worries! We‘ve got your back. Try BYJU‘S free classes today!
D
string
No worries! We‘ve got your back. Try BYJU‘S free classes today!
Open in App
Solution

The correct option is B no output is printed
Because of first character is '\0' nothing will be printed

flag
Suggest Corrections
thumbs-up
0
Join BYJU'S Learning Program
similar_icon
Related Videos
thumbnail
lock
Reviewing the Content of Mass Media
HISTORY
Watch in App
Join BYJU'S Learning Program
CrossIcon