• Courses
  • Tutorials
  • Jobs
  • Practice
  • Contests

GATE | GATE CS 2008 | Question 61

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. C
void reverse(void)
 {
  int c;
  if (?1) reverse();
  ?2
}
int main()
{
  printf (\"Enter Text \") ;
  printf (\"\\n\") ;
  reverse();
  printf (\"\\n\") ;
}

(A)

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

(B)

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

(C)

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

(D)

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

Answer

Please comment below if you find anything wrong in the above post
Feeling lost in the world of random DSA topics, wasting time without progress? It's time for a change! Join our DSA course, where we'll guide you on an exciting journey to master DSA efficiently and on schedule.
Ready to dive in? Explore our Free Demo Content and join our DSA course, trusted by over 100,000 geeks!

Last Updated :
Share your thoughts in the comments