Skip to content
Related Articles

Related Articles

GATE | GATE-IT-2004 | Question 60

View Discussion
Improve Article
Save Article
  • Last Updated : 28 Jun, 2021

Choose the correct option to fill the ?1 and ?2 so that the program prints an input string in reverse order. Assume that the input string is terminated by a new line character.

#include <stdio.h>
void wrt_it (void);
int main (void)
    printf("Enter Text"); 
    printf ("\n");
    wrt_ it();
    printf ("\n");
    return 0;
void wrt_it (void)
    int c;
    if (?1)

(A) ?1 is  getchar() ! = ‘\n’
?2 is  getchar(c);
(B) ?1 is  (c = getchar()); ! = ‘\n’
?2 is  getchar(c);
(C) ?1 is  c! = ‘\n’
?2 is  putchar(c);
(D) ?1 is (c = getchar()) ! = ‘\n’
?2 is putchar(c);

Answer: (D)

getchar() : This function is used to read a character from the standard input stream.

putchar() : This function is used to write a character to the standard output stream.

Thus, option (D) is correct.

Please comment below if you find anything wrong in the above post.

Quiz of this Question

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!