Choose the correct option to fill the ?1 and ?2 so that the program prints an…

GATE · 2004 · ITGATE · 2008 · CS

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)
        wrt_it();
    ?2
}

  1. A.

    ?1 is  getchar() ! = '\n' ?2 is  getchar(c);

  2. B.

    ?1 is  (c = getchar()); ! = '\n' ?2 is  getchar(c);

  3. C.

    ?1 is  c! = '\n' ?2 is  putchar(c);

  4. D.

    ?1 is (c = getchar()) ! = '\n' ?2 is putchar(c);

Attempted by 421 students.

Sign up free to check your answer

Sign up free

Explore the full course: Gate Guidance By Sanchit Sir

Loading lesson…