Discussion :: Arrays
-
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);
}
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