wiz-icon
MyQuestionIcon
MyQuestionIcon
1
You visited us 1 times! Enjoying our articles? Unlock Full Access!
Question

Choose the correct option to fill?1 and?2 so that the program below prints an input string in reverse order. Assume that the input string is terminated by a newline character.
void revese (void) {
int c;
if (?1) reverse();
?2
}
main ( ) {
printf ("Enter Text"); printf("\n");
reverse ( ); printf ("\n");
}


A
? 1 is (getchar ( ) ! = '\n')
? 2 is getchar (c);
No worries! We‘ve got your back. Try BYJU‘S free classes today!
B
? 1 is (c = getchar ( ) ) ! = '\n')
? 2 is getchar (c)
No worries! We‘ve got your back. Try BYJU‘S free classes today!
C
? 1 is (c ! = '\n')
? 2 is putchar (c);
No worries! We‘ve got your back. Try BYJU‘S free classes today!
D
? 1 is ((c = getchar ( ) ) ! = '\n')
? 2 is putchar (c);
Right on! Give the BNAT exam to get a 100% scholarship for BYJUS courses
Open in App
Solution

The correct option is D ? 1 is ((c = getchar ( ) ) ! = '\n')
? 2 is putchar (c);
  • getchar()––––––––– is a function which read from standard input and return integer value.
  • putchar ( ) is a function which used to write a character on standard output/screen.
Here if condition need to check input is finished or not by doing ((c = getchar ( )! = '\n') i.e. when character = '\n','\n' represent end of input.
After reverse ( ) function we need to print the output by using putchar (c).

flag
Suggest Corrections
thumbs-up
0
Join BYJU'S Learning Program
similar_icon
Related Videos
thumbnail
lock
Integration as Anti-Derivative
MATHEMATICS
Watch in App
Join BYJU'S Learning Program
CrossIcon