

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.
201. |
What does this statement printf(“%10s”, state); means? |
A. | 10 spaces before the string state is printed |
B. | Print empty spaces if the string state is less than 10 characters |
C. | Print the last 10 characters of the string |
D. | None of the mentioned |
Answer» C. Print the last 10 characters of the string | |
202. |
What does the following segment of code do? fprintf(fp, “Copying!”); |
A. | It writes “Copying!” into the file pointed by fp |
B. | It reads “Copying!” from the file and prints on display |
C. | It writes as well as reads “Copying!” to and from the file and prints it |
D. | None of the mentioned |
Answer» B. It reads “Copying!” from the file and prints on display | |
203. |
The following statement prlntf( ‘%f ’, 9/5) ; prints |
A. | 1.8 |
B. | 1.0 |
C. | 2.0 |
D. | 0.00 |
Answer» E. | |
204. |
The statementprintf ("%d", 10 ? 0 ? 5 : 11 : 12 ) ;prints |
A. | 10 |
B. | 0 |
C. | 12 |
D. | 11 |
Answer» E. | |
205. |
Memory allocation using malloc() is done in? |
A. | Static area |
B. | Stack area |
C. | Heap area |
D. | Both Stack & Heap area |
Answer» D. Both Stack & Heap area | |
206. |
What is the output of this C code if 2 character is typed by the user? |
A. | Compilation error |
B. | Undefined behaviour |
C. | 0 |
D. | 10(ascii value of newline character) |
Answer» D. 10(ascii value of newline character) | |
207. |
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 | |
208. |
The following function int fputs(char *line, FILE *fp) returns EOF when: |
A. | ‘�’ character of array line is encountered |
B. | ‘n’ character in array line is encountered |
C. | ‘t’ character in array line is encountered |
D. | When an error occurs |
Answer» E. | |
209. |
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. | |
210. |
Identify X library function for line input and output? |
A. | getc |
B. | putc |
C. | fgets |
D. | fputs |
Answer» E. | |
211. |
fputs adds newline character |
A. | True |
B. | False |
C. | Depends on the standard |
D. | Undefined behaviour |
Answer» C. Depends on the standard | |
212. |
puts function adds newline character |
A. | True |
B. | False |
C. | Depends on the standard |
D. | Undefined behaviour |
Answer» B. False | |
213. |
gets function checks overflow run |
A. | True |
B. | False |
C. | Depends on the standard |
D. | Depends on the compiler |
Answer» C. Depends on the standard | |
214. |
The process of accessing data stored in a tape is similar to manipulating data on a |
A. | Stack |
B. | Queue |
C. | List |
D. | None of these |
Answer» C. List | |
215. |
Which is true about fputs.fputs returns? |
A. | EOF if an error occurs |
B. | Non-negative if no error |
C. | EOF if an error occurs & Non-negative if no error |
D. | None of the mentioned |
Answer» D. None of the mentioned | |
216. |
What is the purpose of the function? int ferror(FILE *fp) |
A. | They check for input errors |
B. | They check for output errors |
C. | They check for all types of errors |
D. | They check for error in accessing the file |
Answer» C. They check for all types of errors | |
217. |
What are the Properties of first argument of a printf functions? |
A. | It is defined by 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» C. There may no be first argument | |
218. |
Which type of files can’t be opened using fopen()? |
A. | .txt |
B. | .bin |
C. | .c |
D. | none of the mentioned |
Answer» E. | |
219. |
Why do we write (int *) before malloc? int *ip = (int *)malloc(sizeof(int)); |
A. | It is for the syntax correctness |
B. | It is for the type-casting |
C. | It is to inform malloc function about the data-type expected |
D. | None of the mentioned |
Answer» C. It is to inform malloc function about the data-type expected | |
220. |
int ungetc(int c, FILE *fp) returns |
A. | Either c or EOF for an error |
B. | Nothing |
C. | fp |
D. | None of the mentioned |
Answer» B. Nothing | |
221. |
printf("ab", "cd", "ef"); prints |
A. | ab |
B. | abcdef |
C. | abcdef, followed by garbage |
D. | none of above |
Answer» B. abcdef | |
222. |
Which of the following the 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); | |
223. |
If a = 9, b = 5 and c = 3, then the expression ( a - a/b * b % c) > a % b % c evaluates to |
A. | true |
B. | false |
C. | invalid |
D. | 0 |
Answer» B. false | |
224. |
The statement fseek(fp,0L,0)i - if syntactically correct,means |
A. | fp is a file pointer |
B. | position the read-write-head at the start of the file |
C. | position the read-write-head at the end of the file |
D. | None of these |
Answer» C. position the read-write-head at the end of the file | |
225. |
Which among the following is never possible in C when members are different in a structure and union? //Let P be a structure //Let Q be a union |
A. | sizeof(P) is greater than sizeof(Q) |
B. | sizeof(P) is less than sizeof(Q) |
C. | sizeof(P) is equal to sizeof(Q) |
D. | none of the mentioned |
Answer» E. | |
226. |
Which of the following is the right declaration for fgets inside the library? |
A. | int *fgets(char *line, int maxline, FILE *fp); |
B. | char *fgets(char *line, int maxline, FILE *fp); |
C. | char *fgets(char *line, FILE *fp); |
D. | int *fgets(char *line, FILE *fp); |
Answer» C. char *fgets(char *line, FILE *fp); | |
227. |
%lf is used to display |
A. | float |
B. | long float |
C. | double |
D. | all of the mentioned |
Answer» D. all of the mentioned | |
228. |
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 | |
229. |
Which of the following is the correct syntax for calling function ungetc?(Assume int c and FILE *fp) |
A. | ungetc(c,*fp); |
B. | ungetc(c, fp); |
C. | ungetc(fp, c); |
D. | ungetc(*fp,c); |
Answer» C. ungetc(fp, c); | |
230. |
What will be the value of x and y after execution of the following statement (C language) n ==5;x=n++;y=-x;? |
A. | 5,4 |
B. | 6,5 |
C. | 5,6 |
D. | 5,5 |
Answer» B. 6,5 | |
231. |
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 | |
232. |
For union union temp { char a; int b; float c; };The size is decided by: |
A. | char |
B. | int |
C. | float |
D. | both int and float |
Answer» E. | |
233. |
calloc initialises memory with all bits set to zero. |
A. | True |
B. | False |
C. | Depends on the compiler |
D. | Depends on the standard |
Answer» B. False | |
234. |
The number of digits present after decimal in float is________. |
A. | 1 |
B. | 3 |
C. | 6 |
D. | 16 |
Answer» D. 16 | |
235. |
What is the output of this program 32 bit c compiler ? |
A. | %%%%% |
B. | %% |
C. | No output |
D. | Error |
Answer» C. No output | |
236. |
What is the output of this program ? |
A. | 11 |
B. | 13 |
C. | Error |
D. | No output |
Answer» C. Error | |
237. |
What is the output of this C code if following commands are used to run and if myfile does not exist? gcc -o test test.c ./test > myfile |
A. | d 2 in myfile |
B. | d 1 in myfile |
C. | Depends on the system |
D. | Depends on the standard |
Answer» C. Depends on the system | |
238. |
What is the output of this C code if following commands are used to run(considering myfile exists)? gcc -otest test.c ./test < myfile |
A. | Compile time error (after first command) |
B. | d in the myfile file |
C. | d on the screen |
D. | Undefined behaviour |
Answer» D. Undefined behaviour | |
239. |
The statement prog |
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 | |
240. |
putchar(c) function/macro always outputs character c to the |
A. | screen |
B. | standard output |
C. | depends on the compiler |
D. | depends on the standard |
Answer» C. depends on the compiler | |
241. |
What is the output of this C code if following commands are used to run(considering myfile exists)? gcc -otest test.c ./test > myfile |
A. | d 2 in myfile |
B. | d 1 in myfile |
C. | d in myfile and 1 in screen |
D. | d in myfile and 2 in screen |
Answer» C. d in myfile and 1 in screen | |
242. |
va_end does whatever |
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» D. None of the mentioned | |
243. |
The type va_list is used in an argument list |
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» B. For cleanup | |
244. |
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» D. None of the mentioned | |
245. |
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]; | |
246. |
Interrupts initiated by an instruction is called as |
A. | Internal |
B. | External |
C. | Hardware |
D. | Software |
Answer» C. Hardware | |
247. |
When the disks rotate at 5400 RPM-15,000 RPM, then they have average rotational latency is between |
A. | 1ms |
B. | 1.2ms |
C. | 1.5ms |
D. | 2.0 ms |
Answer» E. | |
248. |
The time between the receive of an interrupt and its service is ______ |
A. | Interrupt delay |
B. | Interrupt latency |
C. | Cycle time |
D. | Switching time |
Answer» C. Cycle time | |
249. |
Which one of the following is true with regard to a CPU having a single interrupt request line and single interrupt grant line…??i) Neither vectored nor multiple interrupting devices is possible.ii) Vectored interrupts is not possible but multiple interrupting devices is possible.iii) Vectored interrupts is possible and multiple interrupting devices is not possible.iv) Both vectored and multiple interrupting devices is possible. |
A. | iii |
B. | i,iv |
C. | ii,iii |
D. | iii,iv |
Answer» B. i,iv | |
250. |
From amongst the following given scenarios determine the right one to justify interrupt mode of data transferi) Bulk transfer of several kilo-byteii) Moderately large data transfer of more than 1kbiii) Short events like mouse actioniv) Keyboard inputs |
A. | i and ii |
B. | ii |
C. | i,ii and iv |
D. | iv |
Answer» E. | |