Chapter:

50+ Managing IO Operations Solved MCQs

in C Language

Chapters

Chapter: Managing IO Operations
1.

Which among the following is the odd one out?

A. printf
B. fprintf
C. putchar
D. scanf
Answer» D. scanf
2.

For a typical program, the input is taken using _________

A. scanf
B. Files
C. Command-line
D. All of the mentioned
Answer» D. All of the mentioned
3.

What does the following command line signify? prog1 prog2

A. It runs prog1 first, prog2 second
B. It runs prog2 first, prog1 second
C. It runs both the programs, pipes output of prog1 to input of prog2
D. It runs both the programs, pipes output of prog2 to input of prog1
Answer» C. It runs both the programs, pipes output of prog1 to input of prog2
4.

What is the default return-type of getchar()?

A. char
B. int
C. char *
D. reading character doesn’t require a return-type
Answer» B. int
5.

What is the value of EOF?

A. -1
B. 0
C. 1
D. 10
Answer» A. -1
6.

What is the use of getchar()?

A. The next input character each time it is called
B. EOF when it encounters end of file
C. The next input character each time it is called EOF when it encounters end of file
D. None of the mentioned
Answer» C. The next input character each time it is called EOF when it encounters end of file
7.

Which of the following statement is true?

A. The symbolic constant EOF is defined in <stdio.h>
B. The value is -1
C. The symbolic constant EOF is defined in <stdio.h> & value is -1
D. Only value is -1
Answer» C. The symbolic constant EOF is defined in <stdio.h> & value is -1
8.

What is the return value of putchar()?

A. The character written
B. EOF if an error occurs
C. Nothing
D. Both character written & EOF if an error occurs
Answer» D. Both character written & EOF if an error occurs
9.

Escape sequences are prefixed with ________

A. %
B. /
C.
D. None of the mentioned
Answer» D. None of the mentioned
10.

What is the purpose of sprintf?

A. It prints the data into stdout
B. It writes the formatted data into a string
C. It writes the formatted data into a file
D. None of the mentioned
Answer» B. It writes the formatted data into a string
11.

The syntax to print a % using printf statement can be done by ________

A. %
B. \%
C. ‘%’
D. %%
Answer» D. %%
12.

What are the Properties of the first argument of a printf() functions?

A. It is defined by a user
B. It keeps the record of the types of arguments that will follow
C. There may no be first argument
D. None of the mentioned
Answer» B. It keeps the record of the types of arguments that will follow
13.

Which of the following function with ellipsis are illegal?

A. void func(…);
B. void func(int, …);
C. void func(int, int, …);
D. none of the mentioned
Answer» A. void func(…);
14.

Which of the following data-types are promoted when used as a parameter for an ellipsis?

A. char
B. short
C. int
D. none of the mentioned
Answer» A. char
15.

Which header file includes a function for variable number of arguments?

A. stdlib.h
B. stdarg.h
C. ctype.h
D. both stdlib.h and stdarg.h
Answer» A. stdlib.h
16.

Which of the following macro extracts an argument from the variable argument list (ie ellipsis) and advance the pointer to the next argument?

A. va_list
B. va_arg
C. va_end
D. va_start
Answer» B. va_arg
17.

The type va_list in an argument list is used ________

A. To declare a variable that will refer to each argument in turn;
B. For cleanup
C. To create a list
D. There is no such type
Answer» A. To declare a variable that will refer to each argument in turn;
18.

In a variable length argument function, the declaration “…” can _______

A. Appear anywhere in the function declaration
B. Only appear at the end of an argument list
C. Nothing
D. None of the mentioned
Answer» B. Only appear at the end of an argument list
19.

Each call of va_arg _______

A. Returns one argument
B. Steps va_list variable to the next
C. Returns one argument & Steps va_list variable to the next
D. None of the mentioned
Answer» C. Returns one argument & Steps va_list variable to the next
20.

The standard header _______ is used for variable list arguments (…) in C.

A. <stdio.h >
B. <stdlib.h>
C. <math.h>
D. <stdarg.h>
Answer» D. <stdarg.h>
21.

What is the purpose of va_end?

A. Cleanup is necessary
B. Must be called before the program returns
C. Cleanup is necessary & Must be called before the program returns
D. None of the mentioned
Answer» C. Cleanup is necessary & Must be called before the program returns
22.

Which of the following is NOT a delimiter for an input in scanf?

A. Enter
B. Space
C. Tab
D. None of the mentioned
Answer» D. None of the mentioned
23.

If the conversion characters of int d, i, o, u and x are preceded by h, it indicates?

A. A pointer to int
B. A pointer to short
C. A pointer to long
D. A pointer to char
Answer» B. A pointer to short
24.

Which of the following doesn’t require an & for the input in scanf()?

A. char name[10];
B. int name[10];
C. float name[10];
D. all of the mentioned
Answer» A. char name[10];
25.

Which of the following is an invalid method for input?

A. scanf(“%d%d%d”,&a, &b, &c);
B. scanf(“%d %d %d”, &a, &b, &c);
C. scanf(“Three values are %d %d %d”,&a,&b,&c);
D. none of the mentioned
Answer» D. none of the mentioned
26.

Which of the following represents the function for scanf()?

A. void scanf(char *format, …)
B. int scanf(char *format, …)
C. char scanf(int format, …)
D. char *scanf(char *format, …)
Answer» B. int scanf(char *format, …)
27.

What does scanf() function return?

A. Number of successfully matched and assigned input items
B. Nothing
C. Number of characters properly printed
D. Error
Answer» A. Number of successfully matched and assigned input items
28.

The conversion characters d, i, o, u, and x may be preceded by h in scanf() to indicate?

A. A pointer to short
B. A pointer to long
C. Nothing
D. Error
Answer» A. A pointer to short
29.

The syntax of printf() function is printf(“control string”, variable list) ;what is the prototype of the control string?

A. %[flags][.precision][width][length]specifier
B. %[flags][length][width][.precision]specifier
C. %[flags][width][.precision][length]specifier
D. %[flags][.precision][length][width]specifier
Answer» C. %[flags][width][.precision][length]specifier
30.

The parameter control string in the printf () is a C String that contains text to be __________

A. taken from a standard output device
B. written on to the standard output device
C. received from the standard output device
D. nothing can be said
Answer» B. written on to the standard output device
31.

Output justification such as decimal point, numerical sign, trailing zeros or octal are specified.

A. specifier
B. flags
C. precision
D. decimal
Answer» B. flags
32.

What symbol is used to Left-justify within the data given field width?

A. -(minus sign)
B. +(plus sign)
C. #
D. 0
Answer» A. -(minus sign)
33.

What specifies the minimum number of characters to print after being padded with zeros or blank spaces?

A. flags
B. length
C. width
D. precision
Answer» C. width
34.

The maximum number of characters to be printed is specified by __________

A. precision
B. width
C. length
D. flags
Answer» A. precision
35.

________is used to define the type and the interpretation of the value of the corresponding argument.

A. precision
B. specifiers
C. flags
D. decimal
Answer» B. specifiers
36.

A conversion specification %7.4f means ____________

A. print a floating point value of maximum 7 digits where 4 digits are allotted for the digits after the decimal point
B. print a floating point value of maximum 4 digits where 7digits are allotted for the digits after the decimal point
C. print a floating point value of maximum 7 digits
D. print a floating point value of minimum 7 digits where 4 digits are allotted for the digits after the decimal point
Answer» A. print a floating point value of maximum 7 digits where 4 digits are allotted for the digits after the decimal point
37.

Choose the correct description for control string %-+7.2f.

A. – means display the sign, + means left justify, 7 specifies the width and 2 specifies the precision
B. – means left justify, + means display the sign, 7 specifies the width and 2 specifies the precision
C. – means display the sign, + means left justify, 7 specifies the precision and 2 specifies the width
D. – means left justify, + means display the sign, 7 specifies the precision and 2 specifies the width
Answer» B. – means left justify, + means display the sign, 7 specifies the width and 2 specifies the precision
38.

What error is generated on placing an address operator with a variable in the printf statement?

A. compile error
B. run-time error
C. logical error
D. no error
Answer» B. run-time error
39.

If by mistake you specify more number of arguments, the excess arguments will ____________

A. be ignored
B. produce compile error
C. produce run-time error
D. produce logical error
Answer» A. be ignored
40.

What happens when zero flag is used with left justification?

A. data is padded with zeros
B. zero flag is ignored
C. data is padded with blank spaces
D. will give error
Answer» B. zero flag is ignored
41.

For floating point numbers, the precision flag specifies the number of decimal places to be printed. When no precision modifier is specified, printf() prints _______

A. six decimal positions
B. five decimal positions
C. four decimal positions
D. three decimal positions
Answer» A. six decimal positions
42.

What will the given code result in printf(“\n you are\”awesome \" ");?

A. compile error
B. run-time error
C. you are "awesome"
D. you are awesome
Answer» C. you are "awesome"
43.

What will be the output for the given code printf(“\n The number is %07d”,1212);

A. The number is 0001212
B. The number is 1212
C. The number is 1212
D. The number is 1212000
Answer» A. The number is 0001212
44.

The syntax of the scanf() is scanf(“control string “, arg1,arg2,arg3,….,argn); the prototype of control string is ____________

A. [=%[width][modifiers]type=]
B. [=%[modifiers][width]type=]
C. [=%[width] [modifiers]]
D. [width][modifiers]
Answer» A. [=%[width][modifiers]type=]
45.

What is the use of symbol * in the control string as shown [=%[*][width] [modifiers] type=]?

A. * is optional and used when the data should be read from the stream but ignored
B. * is not optional, used to read data from the stream but it is not ignored
C. * is not optional, it is used to read data stream but ignored
D. * is optional and used to read data from stream but it is not ignored
Answer» A. * is optional and used when the data should be read from the stream but ignored
46.

What action is carried out by scanf if a user enters any blank spaces, tabs, and newlines?

A. consider as input
B. ignores it
C. produces error
D. nothing can be said
Answer» B. ignores it
47.

What error will generate if the read and write parameters are not separated by commas?

A. run-time error
B. compile error
C. logical error
D. no error
Answer» B. compile error
48.

_____ is an optional argument that gives the maximum number of characters to be read.

A. modifiers
B. width
C. precision
D. length
Answer» B. width
49.

Explain the format string "%5d%s %c"

A. five characters as a decimal integer, then reads the remaining as a string and then scans the first non-whitespace character
B. compile error
C. run-time error
D. read first five characters as a decimal and ignore the rest
Answer» A. five characters as a decimal integer, then reads the remaining as a string and then scans the first non-whitespace character
50.

Select the correct value of i from given options i=scanf("%d %d", &a, &b);

A. 1
B. 2
C. 3
D. No value assigned
Answer» B. 2
51.

If the user enters 1 3.2 s, what value will be returned by the scanf()?scanf("%d %f %c", &s1, &s2, &s3);

A. 1
B. 2
C. 3
D. No return value
Answer» C. 3
52.

If the user enters 1 s 3.2, what value will be returned by the scanf()?scanf("%d %f %c", &a, &b, &c);

A. 1
B. 2
C. 3
D. no return value
Answer» A. 1
53.

What error will be generated on using incorrect specifier for the datatype being read?

A. compile error
B. run-time error
C. logical error
D. no error
Answer» B. run-time error
54.

What is the prototype of scanf function?

A. scanf("controlstring",arg1,arg2,arg3,….,argn);
B. scanf("control string", variable list);
C. scanf(" varible list,", control string);
D. scanf("arg1,arg2,arg3,….,argn", control string);
Answer» A. scanf("controlstring",arg1,arg2,arg3,….,argn);
55.

What is the meaning of the following C statement? scanf("%[^\n]s", ch);

A. read all character except new line
B. read all characters
C. read only new line character
D. syntax error
Answer» A. read all character except new line
56.

What is the qualifying input for the type specifier G?

A. floating point numbers
B. floating point numbers in exponential format
C. floating point numbers in the shorter of exponential format
D. not a type specifier
Answer» C. floating point numbers in the shorter of exponential format
57.

scanf() is a predefined function in______header file.

A. stdlib. h
B. ctype. h
C. stdio. h
D. stdarg. h
Answer» C. stdio. h
58.

What does the C statement given below says? scanf("%7s",ch);

A. read string with minimum 7 characters.
B. read string with maximum 7 characters
C. read string exactly to 7 characters
D. read string with any number of characters
Answer» B. read string with maximum 7 characters
Tags
  • Question and answers in Managing IO Operations,
  • Managing IO Operations multiple choice questions and answers,
  • Managing IO Operations Important MCQs,
  • Solved MCQs for Managing IO Operations,
  • Managing IO Operations MCQs with answers PDF download