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.
$?1$ is $(getchar() != ’\setminus n’)$
$?1$ is $((c = getchar() ) !=’\setminus n’)$
$?2$ is $getchar(c);$
$?1$ is $(c != ’\setminus n’)$
$?2$ is $putchar(c);$
$?1$ is $((c = getchar() ) != ’\setminus n’)$
Here, we are using the '$=$' operator which has less priority than '$!=$' operator. So $(c=getchar())$ has to be in brackets and after reversing the string we use function $putchar(c)$ for printing the character.
So, option (D) is the right answer.
@ Swati Rauniyar
u mean after printing stack will remove that character from the stack, so there will be no need of pointer.