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 new line character.

void reverse(void)  {
    int c;
    if(?1) reverse();
    ?2
}
main()  {
    printf("Enter text"); ptintf("\n");
    reverse(); printf("\n");
}

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

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

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

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

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