

MCQOPTIONS
Saved Bookmarks
This section includes 391 Mcqs, each offering curated multiple-choice questions to sharpen your C Programming knowledge and support exam preparation. Choose a topic below to get started.
301. |
puts() function adds newline character. |
A. | True |
B. | False |
C. | Depends on the standard |
D. | Undefined behaviour |
Answer» B. False | |
302. |
Which of the following will return a result most quickly for searching a given key? |
A. | Unsorted Array |
B. | Sorted Array |
C. | Sorted linked list |
D. | Binary Search Tree |
Answer» E. | |
303. |
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» B. compile error | |
304. |
Which of the following library function is not case-sensitive? |
A. | toupper() |
B. | tolower() |
C. | isdigit() |
D. | all of the mentioned |
Answer» D. all of the mentioned | |
305. |
Which of these is a correct way to generate numbers between 0 to 1(inclusive) randomly? |
A. | rand() / RAND_MAX |
B. | rand() % 2 |
C. | rand(0, 1) |
D. | none of the mentioned |
Answer» B. rand() % 2 | |
306. |
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» B. int name[10]; | |
307. |
The______function reads atmost one less than the number of characters specified by size from the given stream and it is stored in the string str. |
A. | fget() |
B. | fgets() |
C. | fput() |
D. | fputs() |
Answer» C. fput() | |
308. |
What is the syntax of ungetc()? |
A. | void ungetc(int c, FILE *fp) |
B. | int ungetc(int c, FILE *fp) |
C. | int ungetc(String c, FILE *fp) |
D. | int getc(int c, FILE *fp) |
Answer» C. int ungetc(String c, FILE *fp) | |
309. |
Control string specifies the type and format of the data that has to be obtained from the keyboard. |
A. | true |
B. | false |
Answer» B. false | |
310. |
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» C. – means display the sign, + means left justify, 7 specifies the precision and 2 specifies the width | |
311. |
Which of the following mathematical function requires 2 parameter for successful function call? |
A. | fmod(); |
B. | div(); |
C. | atan2(); |
D. | all of the mentioned |
Answer» E. | |
312. |
The syntax to print a % using printf statement can be done by ________ |
A. | % |
B. | \% |
C. | '%' |
D. | %% |
Answer» E. | |
313. |
Which type of files can't be opened using fopen()? |
A. | .txt |
B. | .bin |
C. | .c |
D. | none of the mentioned |
Answer» E. | |
314. |
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» E. | |
315. |
Which types of input are accepted in toupper(c)? |
A. | char |
B. | char * |
C. | float |
D. | Both char and char * |
Answer» B. char * | |
316. |
gets() does the following when it reads from stdin. |
A. | Deletes the 't' |
B. | Puts adds it. |
C. | Deletes the terminating 'n' |
D. | Nothing |
Answer» D. Nothing | |
317. |
scanf() is a predefined function in______header file. |
A. | stdlib. h |
B. | ctype. h |
C. | stdio. h |
D. | stdarg. h |
Answer» D. stdarg. h | |
318. |
Which among the following is the odd one out? |
A. | printf |
B. | fprintf |
C. | putchar |
D. | scanf |
Answer» E. | |
319. |
what is the function of fputs()? |
A. | read a line from a file |
B. | read a character from a file |
C. | write a character to a file |
D. | write a line to a file |
Answer» E. | |
320. |
Which of the following is the correct declaration for ungetc? |
A. | int ungetc(int c, FILE fp); |
B. | int ungetc(int *c, FILE fp); |
C. | int ungetc(int c, FILE *fp); |
D. | int ungetc(int *c, FILE *fp); |
Answer» D. int ungetc(int *c, FILE *fp); | |
321. |
What is the difference in the ASCII value of capital and non-capital of the same letter is? |
A. | 1 |
B. | 16 |
C. | 32 |
D. | Depends with compiler |
Answer» D. Depends with compiler | |
322. |
What type of inputs are accepted by mathematical functions? |
A. | short |
B. | int |
C. | float |
D. | double |
Answer» E. | |
323. |
calloc() initialize memory with all bits set to zero. |
A. | True |
B. | False |
C. | Depends on the compiler |
D. | Depends on the standard |
Answer» B. False | |
324. |
log(x) function defined in math.h header file is __________ |
A. | Natural base logarithm |
B. | Logarithm to the base 2 |
C. | Logarithm to the base 10 |
D. | None of the mentioned |
Answer» B. Logarithm to the base 2 | |
325. |
gets() function checks overflow run. |
A. | True |
B. | False |
C. | Depends on the standard |
D. | Undefined behaviour |
Answer» C. Depends on the standard | |
326. |
What is function srand(unsigned)? |
A. | Sets the seed for rand |
B. | Doesn't exist |
C. | Is an error |
D. | None of the mentioned |
Answer» B. Doesn't exist | |
327. |
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» C. logical error | |
328. |
_____ is an optional argument that gives the maximum number of characters to be read. |
A. | modifiers |
B. | width |
C. | precision |
D. | length |
Answer» C. precision | |
329. |
Which of the following is used during memory deallocation in C? |
A. | remove(p); |
B. | delete(p); |
C. | free(p); |
D. | terminate(p); |
Answer» D. terminate(p); | |
330. |
ungetc() can be used only with getc(). |
A. | true |
B. | false |
C. | depends on the standard |
D. | depends on the platform |
Answer» C. depends on the standard | |
331. |
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» D. you are awesome | |
332. |
What is the size of array 'line' used in fgets(line, maxline, *fp) function? |
A. | maxline – 1 |
B. | maxline |
C. | maxline + 1 |
D. | Size is dynamic |
Answer» C. maxline + 1 | |
333. |
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» D. %[flags][.precision][length][width]specifier | |
334. |
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» C. Nothing | |
335. |
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» C. A pointer to long | |
336. |
Which of the following is not a valid mathematical function? |
A. | frexp(x); |
B. | atan2(x,y); |
C. | srand(x); |
D. | fmod(x); |
Answer» E. | |
337. |
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» B. [=%[modifiers][width]type=]. | |
338. |
The standard header _______ is used for variable list arguments (…) in C. |
A. | <stdio.h > |
B. | <stdlib.h> |
C. | <math.h> |
D. | <stdarg.h> |
Answer» E. | |
339. |
Choose the correct difference between getc() and fgetc(). |
A. | If it is not a macro, it may evaluate stream more than once |
B. | if it is amacro, it may not evaluate stream more than once |
C. | if it is a macro, it may evaluate stream more than once |
D. | no difference between fgetc() and getc() |
Answer» D. no difference between fgetc() and getc() | |
340. |
A fatal error will be generated if the format string is ended with a white space character. |
A. | true |
B. | false |
Answer» B. false | |
341. |
ungetc() is used __________ |
A. | to get a char |
B. | to get an int |
C. | to push a character back to file |
D. | nothing |
Answer» D. nothing | |
342. |
The functions vprintf(), vfprintf(), and vsprintf() are not equivalent to the corresponding printf() functions except the variable argument list. |
A. | true |
B. | false |
Answer» C. | |
343. |
function fabs defined math.h header file takes argument of type integer. |
A. | True |
B. | False |
C. | Depends on the implementation |
D. | Depends on the standard |
Answer» C. Depends on the implementation | |
344. |
What is the difference between %e and %g? |
A. | %e output formatting depends on the argument and %g always formats in the format [-]m.dddddd or [-]m.dddddE[+|-]xx where no.of ds are optional |
B. | %e always formats in the format [-]m.dddddd or [-]m.dddddE[+|-]xx where no.of ds are optional and output formatting depends on the argument |
C. | No differences |
D. | Depends on the standard |
Answer» C. No differences | |
345. |
The statement prog < infile causes _________ |
A. | prog to read characters from infile |
B. | prog to write characters to infile |
C. | infile to read characters from prog instead |
D. | nothing |
Answer» B. prog to write characters to infile | |
346. |
What are the first and second arguments of fopen? |
A. | A character string containing the name of the file & the second argument is the mode |
B. | A character string containing the name of the user & the second argument is the mode |
C. | A character string containing file pointer & the second argument is the mode |
D. | None of the mentioned |
Answer» B. A character string containing the name of the user & the second argument is the mode | |
347. |
puts() does the following when it writes to stdout. |
A. | Deletes everything |
B. | Adds 't' to the line written |
C. | Deletes the terminating 'n' |
D. | Adds 'n' to the line written |
Answer» E. | |
348. |
Strcat() function adds null character. |
A. | Only if there is space |
B. | Always |
C. | Depends on the standard |
D. | Depends on the compiler |
Answer» C. Depends on the standard | |
349. |
The syntax of fgets is char *fgets(char *line, int maxline, FILE *fp). Which is true for fgets? |
A. | Returns line on success |
B. | On end of file or error it returns NULL |
C. | Nothing |
D. | Both returns line on success & On end of file or error it returns NULL |
Answer» E. | |
350. |
In linux, apart from including math header file, the program is successfully executed by which of the following? |
A. | cc filename.c |
B. | cc filename.c -lc |
C. | cc -math filename.c |
D. | cc -lm filename.c |
Answer» E. | |