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);
}
#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);
}
A. NOITANIMAXE C
B. NOITANIMAXE
C. C
D. No output at all.
E. Syntax error
Answer: Option D
Solution(By Examveda Team)
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.
Related Questions on Arrays and Strings
Join The Discussion