computer MCQs

12th • Chapter 10

49 Questions TextBook
1

Which function is used for formatted output in C?

A
scanf()
B
printf()
C
getch()
D
main()
2

What header file is required for standard input/output functions like printf() and scanf()?

A
conio.h
B
math.h
C
stdio.h
D
string.h
3

In C, what is generally considered the standard input device?

A
Monitor
B
Mouse
C
Printer
D
Keyboard
4

What does the format specifier %d represent?

A
float
B
char
C
double
D
int
5

What symbol must every format specifier begin with?

A
&
B
#
C
%
D
/
6

Which function is used to accept user input in various forms?

A
printf()
B
getche()
C
puts()
D
scanf()
7

What is the format specifier for a floating-point number?

A
%d
B
%c
C
%f
D
%s
8

What does the function signature describe?

A
The function's name only
B
The number and type of arguments, and the return type
C
The library it belongs to
D
The line number where it is defined
9

The list of variables in a printf() function is considered what?

A
Mandatory
B
Required
C
Essential
D
Optional
10

Which format specifier is used for a double data type?

A
%f
B
%lf
C
%c
D
%d
11

What is the term for the number of columns used to display a value on the screen?

A
Character width
B
Pixel count
C
Field-width
D
String length
12

Which format specifier is used for a single character?

A
%s
B
%d
C
%c
D
%f
13

How would you specify that an integer should be displayed using 5 columns?

A
%5d
B
%d5
C
5%d
D
%d.5
14

Values displayed with a field-width specifier in printf are typically justified in what way?

A
Left justified
B
Center justified
C
Right justified
D
Not justified
15

What is the general form for a floating-point format specifier with field width and precision?

A
%n.mf
B
%m.nf
C
%f.mn
D
%mf.nf
16

In the format specifier %6.2f, what does the '6' represent?

A
The number of decimal places
B
The number of variables
C
The total field width
D
The value to be printed
17

What symbol must every escape sequence begin with?

A
%
B
&
C
/
D
\
18

Which escape sequence represents a new line?

A
\t
B
\n
C
\r
D
\b
19

Which escape sequence is used to insert a tab space?

A
\t
B
\n
C
\a
D
\f
20

To use functions like getch() and getche(), which header file must be included?

A
stdio.h
B
stdlib.h
C
conio.h
D
math.h
21

What operator is required before the variable name in a scanf() function to store the input value?

A
*
B
&
C
$
D
#
22

Which function reads a character from the keyboard and echoes it to the screen?

A
getch()
B
getchar()
C
getche()
D
scanf()
23

Which function reads a character from the keyboard but does NOT echo it to the screen?

A
getche()
B
getch()
C
printf()
D
cin()
24

In C, how are character constants, like 'a' or '7', always specified?

A
Double quotes
B
Parentheses
C
Angle brackets
D
Single quotes
25

What happens if the ampersand (&) is omitted from a variable in a scanf() call?

A
The program crashes
B
A syntax error occurs
C
A garbage value is stored in the variable
D
The input is ignored
26

Which format specifier is used for a character string?

A
%c
B
%d
C
%s
D
%f
27

The escape sequence \r represents what action?

A
Backspace
B
Form Feed
C
Carriage Return
D
New Line
28

The escape sequence \b is used for what purpose?

A
Bell
B
Backspace
C
New Line
D
Tab
29

How do you print a literal backslash character using an escape sequence?

A
//
B
\/
C
\\
D
|
30

The format specifier %u is used for which data type?

A
unsigned float
B
unsigned char
C
unsigned short, unsigned int
D
unsigned long int
31

The format specifier %x is used for displaying what type of integers?

A
Octal
B
Decimal
C
Binary
D
Unsigned hexadecimal
32

The format specifier %o is used for which type of integers?

A
Unsigned octal
B
Signed octal
C
Hexadecimal
D
Long integer
33

In the exercise, what is the purpose of the getche() function?

A
It is defined in stdio.h
B
It is defined in string.h
C
It is defined in conio.h
D
It is defined in math.h
34

According to the exercise, the escape sequence for backslash is:

A
\
B
b\
C
\\
D
\t
35

The assignment operator in C is represented by which symbol?

A
0
B
0
C
:=
D
:
36

What does the C statement 'a += b;' mean?

A
a = b
B
b = a + b
C
a = a + b
D
a = b + 1
37

The format string of scanf() should consist only of what?

A
Text and format specifiers
B
Variables
C
Format specifiers only
D
Escape sequences
38

Do the getch() and getche() functions accept any arguments?

A
Yes, one integer
B
Yes, one character
C
No, they do not accept any arguments
D
Yes, a string
39

What is the return value of getch() and getche() functions?

A
The ASCII value of the key pressed
B
The character typed
C
An integer status code
D
Nothing (void)
40

When does the getche() function return the typed character?

A
After the Enter key is pressed
B
Immediately after a character is typed
C
After a space is typed
D
After 1 second
41

What does the escape sequence \f do?

A
Causes a backspace
B
Moves to the next page on a printer
C
Inserts a single quote
D
Represents a floating point number
42

The expression '\ddd' is used to print an ASCII code in which notation?

A
Hexadecimal
B
Binary
C
Decimal
D
Octal
43

In the format specifier %m.nf, what does 'n' represent?

A
Total width
B
Number of integer digits
C
Number of decimal places
D
A negative number
44

If a floating point value is being rounded, what happens if the third digit of the fractional part is 5 or greater?

A
The second digit is decreased by one
B
The second digit is increased by one
C
The third digit is kept
D
The entire number is rounded down
45

According to the text, what is the main purpose of using input and output functions?

A
To make the code shorter
B
To make the program more interactive
C
To perform complex calculations
D
To manage memory
46

What is the format specifier for a long integer?

A
%d
B
%f
C
%lf
D
%ld
47

Which of the following is an example of a character constant?

A
A""
B
A
C
(A)
D
[A]
48

The `scanf` function is pronounced as:

A
scan-ef
B
s-can-f
C
scan-eff
D
scanf
49

The `printf` function is pronounced as:

A
print-ef
B
p-rint-f
C
print-eff
D
printf