Multiple choice

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 reverse(void) {
  int c;
  if ( ?1) reverse(); ?2
}
Main() {
  Print f(“Enter Text”);
  printf(“\n”);
  Reverse();
  printf(“\n”);
}

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

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

  3. ?1 is (c != '') ?2 is putchar(c);

  4. ?1 is ((c = getchar) )) ! = '') ?2 is putchar (c);

Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation