Input/Output in C Programming

This quiz contains questions related to input and output in the C language.

Last Updated :
Discuss
Comments

Question 1

Which function is used to read a single character from the user in C?

  • scanf()


  • getchar()


  • puts()

  • gets()


Question 2

Which format specifier is used to read an integer using scanf()?


  • %c

  • %d

  • %f

  • %s

Question 3

What is the correct syntax to print the value of a variable x in C?


  • print(x);

  • printf(x);

  • printf("%d", x);

  • cout << x;

Question 4

Which function is used to output a string followed by a newline?

  • printf()


  • puts()

  • scanf()

  • putchar()

Question 5

Which of the following is the standard input stream in C?

  • stdout

  • fscan

  • stdin

  • stdfile

Question 6

Which of the following is true

  • gets() can read a string with spaces but a normal scanf() with %s can not.

  • gets() can read a string with newline characters but a normal scanf() with %s can not.

  • gets() can always replace scanf() without any additional code.

  • None of the above

Question 7

Which header file is required for printf() and scanf()?


  • conio.h

  • stdio.h

  • stdlib.h

  • math.h

Question 8

Which function would you use to write a single character to the output?


  • putchar()

  • printf()


  • puts()

  • writechar()


Question 9

"Why is the & (address-of) operator used with scanf() when reading integer values?

  • To specify the format of the input.

  • To store the input at the variable’s memory address.

  • To perform pointer arithmetic.

  • It is optional and does not affect the function’s behavior.

Question 10

What is the return type of getchar() and putchar()?


  • char

  • int

  • void

  • string

Tags:

There are 18 questions to complete.

Take a part in the ongoing discussion