C Language - Input/Output Questions and Answers

Take Exam

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
Show Answer Report

22.  Identify the correct statement given double x; 

  • scanf ("%d", & x);
  • scanf ("%f", x);
  • sfanf ("%d", *x);
  • scanf ("% | f ", & x) ;
Show Answer Report

23.  Identify the correct statement (s) given float y; 

  • scanf ("%e", & y);
  • scanf ("%i", & y);
  • scanf ("%g", &y);
  • options a and c
Show Answer Report

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
Show Answer Report

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.
Show Answer Report

26. &nbsp;What are the values of x, y and z, if 25 20 30 are given as inputs for scanf(&quot;d %*d%d&quot;, &amp;x, &amp;y, &amp;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
Show Answer Report

27. &nbsp;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(&quot;%2d % 2d', &amp;p, &amp;q); ?

  • x = 356 y =47
  • x = 35 y = 6
  • x = 35 y = 4
  • x = 35 y = 47
Show Answer Report

28. &nbsp;Char p,q; scanf(&quot;%c%Is', &amp;p, &amp;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
Show Answer Report

29. &nbsp;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
Show Answer Report

30. What is the the value returned by printf () function, if an error occurs ?

  • Positive value
  • 0
  • Negative value
  • 1
Show Answer Report
Questions and Answers for Competitive Exams Various Entrance Test