The GATE Grind

GATE 2008 CS – Question 61

Programming and Data Structures · Recursion · 2 marks · Multiple choice

Fill ?1, ?2 to print a newline-terminated input string in reverse order.

void reverse(void) {
 int c;
 if (?1) reverse();
 ?2
}
main() {
 printf("Enter Text"); printf("\n");
 reverse(); printf("\n");
}
  1. ?1: getchar() != '\n'; ?2: getchar(c);
  2. ?1: (c = getchar()) != '\n'; ?2: getchar(c);
  3. ?1: c != '\n'; ?2: putchar(c);
  4. ?1: (c = getchar()) != '\n'; ?2: putchar(c);

Practise this question in The GATE Grind →

Show answer and explanation

Correct answer: (D) ?1: (c = getchar()) != '\n'; ?2: putchar(c);

Explanation

We are sorry we couldn't write detailed soluition for this, we are working on it!, please consider asking your own AI, its just 2-3 clicks with very minimum effort

More Recursion questions

All Recursion questions →