C Language - Input/Output Questions and Answers
The C Language Input/Output questions with answers focus on concepts like printf(), scanf(), file handling, and formatted I/O operations in C programming. These programming questions and answers help you understand how data is read from and displayed to the console or files. Practicing such MCQs is crucial for C programming interviews, technical tests, and campus placements conducted by Infosys, TCS, and Wipro. Each question includes detailed solutions and code examples to clarify syntax, input validation, and buffer management—making it ideal for students preparing for technical exams.
C Language - Input/Output
Showing 10 of
54 questions
41. main ( ) { double x = 1/2. 0 - 1/2; printf('x=%.2f\n',x); } What will be printed when the above code is executed ?
- x=0.00
- x=0.25
- x=0.50
- x=1.00
42. main ( ) { int x = 5, y = 10; double z; z = (double) ( x / y); printf ("z = %. 2f\n',z) } What will be printed when the above code is executed ?
- z = 0.00
- z = 0.50
- z = 1.00
- 2.00
43. What will be printed when the following code is executed ? main ( ) { int i = 4, a = 6; double z; z = a /i; printf ("z = %.2f\n",z) }
- z = 0.00
- z = 1.00
- z = 1.50
- z = 2.00
44. main ( ) { int x = 3, y = 3, z = 3; z - = x - - - --y; printf ("x = %d y = % d z = %d', x, y, z); } What will be the value of x, y, and z ?
- x = 2 y = 2z = 2
- x = 1 y = 2 z = 2
- x = 2 x = 2 y = 0
- x 2 y = 2 z = 1
45. main ( ) { int x, y, z ; printf (" %d \n', ( z > = y>= x ? 10 : 20)); } What might be the value of x, y, and z, if 20 has to be printed ?
- 0, 0, 0
- -1, -1, -2
- -1, 0, 1
- none
46. # include <stdio.h> main () { int a = 0xfff; (a << 4 >> 12) ? printf ("Sandeep "): printf ("Ashok"); } What will be the output of the program ?
- Ashok
- Sandeep
- Error: Incorrect Assignment
- None
47. printf ("daily click !"); in the code segment above, the words Daily click ! will be printed to what output device ?
- to an E-mail message
- to the console
- to the default printer
- to wherever standard output has been directed to
48. If x -= 2, y = 6, and z = 6 then, what will be the output of x = y = = z; printf (%d", x) ;
- 0
- 1
- 2
- 6
49. int i = 20; printf ( "%x", i); What is the output?
- x 14
- 14
- 20
- none of the above
50. float x, y, z; scanf ("%f%f", &x, &y); printf ("%.2f, %.2f", x,y); if input stream contains "4.2 3.2 3..." what will be the output?
- 4.20, 3.00
- 4.2, 2.3
- 4.20, 2.30
- 4.20 3.20