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
21. Conversion specification includes
- \ and a conversion character
- / and a conversion character
- & and a conversion character
- % and a conversion character
22. Identify the correct statement given double x;
- scanf ("%d", & x);
- scanf ("%f", x);
- sfanf ("%d", *x);
- scanf ("% | f ", & x) ;
23. Identify the correct statement (s) given float y;
- scanf ("%e", & y);
- scanf ("%i", & y);
- scanf ("%g", &y);
- options a and c
24. For the given scanf () statementt, what is the form of input expected ? scanf ("%D, %d. %d", &date, &month, &year);
- 22.4.1972
- 22 4 1972
- 22/4/1972
- options a and b
25. Identify the wrong statement given, int x; float y; char z;
- scanf ("%d, %f, %c", &x, &y, &z);
- scanf ("%d, %f, %c", &x, &y,z);
- scanf("Rs. %d, %f, %c"< &x, &y, &z);
- options a and c.
26. What are the values of x, y and z, if 25 20 30 are given as inputs for scanf("d %*d%d", &x, &y, &z);
- x = 25,y is not assigned, z = 30
- x = 25, y = 20, z = 30
- x = 25, y = 30, z is not assigned
- x = 25, y is not assigned, z = 20
27. What are the values of a, b and c, given int a, c' float b; with inputs as 50, 3.52, 20 for the statement scanf("%2d % 2d', &p, &q); ?
- x = 356 y =47
- x = 35 y = 6
- x = 35 y = 4
- x = 35 y = 47
28. Char p,q; scanf("%c%Is', &p, &q); what are the values assigned, if x and y are given as inputs ?
- P = x and q = blank
- p = x and q is not assigned
- p = x and q = y
- p = x and q = x
29. Identify the correct statement(s) given the declaration char x, y;
- scanf ("%c%c', &x, &y);
- scanf ("%c%1s", &x, &y);
- scanf ("%* [] %c", &x, &y);
- all the above
30. What is the the value returned by printf () function, if an error occurs ?
- Positive value
- 0
- Negative value
- 1