FAQ on Formatted and Unformatted I/O in C!
Distinguish
between the following: getchar() and getche()
getch() : Reads a
character and never waits for Enter key. Just getch processed after getting any
key pressed and it never echoes the character on screen which u pressed.
getche() : it works same as getch() but it echoes on screen.
getchar() : It works differently from the other two. Whenever you press any key these are kept in Buffer. After hitting Enter key, the first character gets processed and it echoes on the screen.
getche() : it works same as getch() but it echoes on screen.
getchar() : It works differently from the other two. Whenever you press any key these are kept in Buffer. After hitting Enter key, the first character gets processed and it echoes on the screen.
Write single C Statements for the following:
- Declare variables x,y and z to store floating point
value
- Display the product of 34.54 and 5.46
- Display the quotient and remainder when 453 is divided
by 34
- Prompt the user to type an integer number
- Read an integer variable k, that has been declared
earlier
- Read an integer variable k, and a character variable ch
that has been declared earlier
- Display float variable x with an accuracy of three
places after the decimal point
- Display integer number k with a field width of 7 columns
- Display the character whose ASCII number is 95
Answer:
- float x,y,z;
- printf(“%f”, 34.54
* 5.46);
- printf(“%d%d”,
453/34, 453%34);
- printf(“Type an
integer number : ”);
- scanf(“%d”,
&k);
- scanf(“%d %c”,
&k, &ch);
- printf(“%10.3f”,
x);
- printf(“%7d”, k);
- printf(“%c”, 95);