Programming for Problem Solving (3110003)

BE | Semester-1   Winter-2019 | 07-01-2020

Q3) (a)

Explain getch(), getchar(), gets().

gets()

  • It is used to read a single string with white spaces.
  • It is terminated by entering the key or at the end of line.
Example:

char str[10];
gets(str);

getchar(), getch( )

  • It is used to read a single character at a time.
  • getchar() function requires enter key to terminate input while getch() does not require.
  • getch()function does not display the input character while getchar()function displays the input character on the screen.
Example:

char ch;
ch = getchar();
ch = getch();