

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.
101. |
Which of the following cannot be used with ungetc? |
A. | scanf |
B. | getc |
C. | getchar |
D. | printf |
Answer» E. | |
102. |
Consider the declaration static char hello[ ] = " hello " ; The output of printf( " % s \ n ", hello) ; will be the same as that of |
A. | puts(" hello "); |
B. | puts( hello ); |
C. | printf(" %s \ n", " hello ") ; |
D. | puts( " hello \ n ") ; |
Answer» D. puts( " hello \ n ") ; | |
103. |
sin(x) returns |
A. | sine of x where x is in radians |
B. | sine of x where x is in degree |
C. | cosine of x where x is in radians |
D. | cosine of x where x is in degree |
Answer» B. sine of x where x is in degree | |
104. |
The syntax for ungetc is |
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) | |
105. |
Consider following statements:putchar(getchar());putchar(getchar());Ifabis the input, then output will be |
A. | An error message |
B. | this can't be the input |
C. | a, b |
D. | Undefined |
Answer» C. a, b | |
106. |
What does the ungetc function return for the following expression? ungetc(c, fp); //where declarations are int c and FILE *fp |
A. | It returns character c |
B. | It returns EOF for an error |
C. | Both returns character c and returns EOF for an error |
D. | Either returns character c or returns EOF for an error |
Answer» E. | |
107. |
The following expression can be substituted for if (isalpha(c) && isdigit(c)) |
A. | if (isalnum(c)) |
B. | if (isalphanum(c)) |
C. | if (isalphanumeric(c)) |
D. | none of the mentioned |
Answer» E. | |
108. |
ungetc may be used with |
A. | scanf |
B. | getc |
C. | getchar |
D. | all of the mentioned |
Answer» E. | |
109. |
void * malloc(size_t n) returns |
A. | Pointer to n bytes of uninitialized storage |
B. | NULL if the request can be satisfied |
C. | Nothing |
D. | None of the mentioned |
Answer» B. NULL if the request can be satisfied | |
110. |
To instantiate an object with the statement ifstream items("C:inven.txt");the file on the disk is identified by the name |
A. | items |
B. | inven.txt |
C. | either (a) or (b) |
D. | None of these |
Answer» C. either (a) or (b) | |
111. |
The program fragment |
A. | 263 |
B. | ASCII equivalent of 263 |
C. | Rings the bell |
D. | undefined |
Answer» D. undefined | |
112. |
In a 'C' program, constant is defined |
A. | Before main |
B. | After main |
C. | Anywhere, but starting on a new line |
D. | Any where in the program |
Answer» D. Any where in the program | |
113. |
Output of the following 'C' program is |
A. | ffff |
B. | 0fff |
C. | 0000 |
D. | Error |
Answer» B. 0fff | |
114. |
If abc is the input, then folloiwng program fragment results in |
A. | A syntax error |
B. | Garbage Values |
C. | Segmentation violation |
D. | Printing of 3 |
Answer» E. | |
115. |
Output of this statment is : |
A. | Syntex Error |
B. | hello5 |
C. | gives garbage value |
D. | print hello and terminates |
Answer» C. gives garbage value | |
116. |
Which statment is true about the given code ? |
A. | Goes in infinite loop |
B. | Gives Address of function main. |
C. | Gives garbage value |
D. | Compilation Error |
Answer» C. Gives garbage value | |
117. |
What is the output of this program, if input a is 1 and b is 2? |
A. | 1 |
B. | 2 |
C. | runtime error |
D. | compile time error |
Answer» C. runtime error | |
118. |
The following 'C' program |
A. | Counts the number of bits which are on in the number num |
B. | Sets all bits in the number num to 1 |
C. | Sets bits in the number num to 0 |
D. | Error |
Answer» B. Sets all bits in the number num to 1 | |
119. |
Comment on the given statment: |
A. | Will execute without any error |
B. | Will give Segmentation fault |
C. | Will give Compilation Error |
D. | None of the above |
Answer» C. Will give Compilation Error | |
120. |
Result of the execution of the following "C" program fragment is |
A. | An execution error |
B. | A syntax error |
C. | Printing of k |
D. | Garbage Value |
Answer» D. Garbage Value | |
121. |
Find output of following : |
A. | i5h4g3f2e1 |
B. | 14h3g2f1e0 |
C. | An error message |
D. | Infinite Loop |
Answer» B. 14h3g2f1e0 | |
122. |
Find the output of following code segment |
A. | A syntax error |
B. | Cartrta |
C. | Catrat |
D. | Catratratratrat... |
Answer» E. | |
123. |
If the following program fragment(assume negative numbers are stored in 2's complement form), output is (log in answers are to the base two) |
A. | An unpredictable value |
B. | 8*log(x+3) |
C. | log(x+3) |
D. | None of these |
Answer» D. None of these | |
124. |
Output of the following program fragment (in C) is |
A. | 1 2 3 4 5 |
B. | 1 2 4 |
C. | 2 4 5 |
D. | none of these |
Answer» C. 2 4 5 | |
125. |
The following code fragment |
A. | prints 8 |
B. | prints 6 |
C. | prints 6 or 8 depending on the compiler implementation |
D. | is syntactically wrong |
Answer» D. is syntactically wrong | |
126. |
The following program fragment prints |
A. | garbage |
B. | -3 |
C. | an integer that changes from machine to machine |
D. | none of above |
Answer» D. none of above | |
127. |
If the following program fragment ( assume negative numbers are stored in 2's complement form) outputs an integer that is same as (log in the answers are to the base two) |
A. | an unpredictable value |
B. | 8 * log( x + 3 ) |
C. | log( x+ 3 ) |
D. | none of above |
Answer» D. none of above | |
128. |
The program fragment: |
A. | prints 263 |
B. | prints the ASCll equivalent of 263 |
C. | rings the bell |
D. | prints garbage |
Answer» D. prints garbage | |
129. |
The following program fragment results in |
A. | an execution error |
B. | a syntax error |
C. | printing of k |
D. | none of the above |
Answer» D. none of the above | |
130. |
The following program fragment |
A. | prints 0 |
B. | prints a non-zero value |
C. | is illegal |
D. | prints an unpredictable value |
Answer» B. prints a non-zero value | |
131. |
Consider the following program. If Madam is the required output, then the body of first ( ) must be |
A. | empty |
B. | second( ) ; putchar ( 'a' ); |
C. | putchar( 'a' ) ; second(); printf ("%c", 'a' ); |
D. | none of the above |
Answer» D. none of the above | |
132. |
The following program |
A. | is illegal |
B. | keeps on printing tim |
C. | prints tim once |
D. | none of the above |
Answer» C. prints tim once | |
133. |
Consider the program. If the machine in which this program is executed is little-endian (meaning, the lower signifi-cant digits occupy lower addresses), then the output will he |
A. | 0 |
B. | 99999999 |
C. | 1 |
D. | unpredictable |
Answer» D. unpredictable | |
134. |
The following program results in |
A. | printing of a garbage number |
B. | an execution error |
C. | printing of starting address of the function main |
D. | an infinite loop |
Answer» D. an infinite loop | |
135. |
The following piece of code |
A. | results in syntax error |
B. | prints 7 |
C. | prints 8 |
D. | none of above |
Answer» C. prints 8 | |
136. |
A possible output of the following program fragment is |
A. | 262164 262164 262164 |
B. | 262164 262165 262166 |
C. | 262164 262165 262165 |
D. | 262164 262164 262165 |
Answer» B. 262164 262165 262166 | |
137. |
What is the output of the following program segment? |
A. | 5 |
B. | 20 |
C. | 0 |
D. | none of above |
Answer» D. none of above | |
138. |
The following program outputs |
A. | LTTE |
B. | TELO |
C. | JKLF |
D. | PLO |
Answer» B. TELO | |
139. |
The program prints |
A. | 2 |
B. | 5 |
C. | 1 |
D. | 6 |
Answer» D. 6 | |
140. |
The output of the following program will be |
A. | 8 |
B. | 12 |
C. | 9 |
D. | 6 |
Answer» B. 12 | |
141. |
What is the output of this code considering user typed jkl? |
A. | jkl |
B. | kl |
C. | Undefined behaviour |
D. | jk |
Answer» B. kl | |
142. |
x - = y + 1; means |
A. | x = x - y + 1 |
B. | x = -x -y -1 |
C. | x=-x +y + 1 |
D. | x= x - y -1 |
Answer» E. | |
143. |
The contents of a file will be lost if it is opened in |
A. | a mode |
B. | w mode |
C. | w+ mode |
D. | a+ mode |
Answer» D. a+ mode | |
144. |
The function fopen("filename","r")returns |
A. | Nothing |
B. | A value 0 or 1 depending on whether the file could be opened or not. |
C. | A pointer to FILE filename,if it exits |
D. | A pointer to a new file after creating it. |
Answer» D. A pointer to a new file after creating it. | |
145. |
The statement printf ( "%d" , sizeof (" "')); prints |
A. | an error message |
B. | 0 |
C. | garbage |
D. | 1 |
Answer» E. | |
146. |
The function sprintf()works like printf(),but operatres on |
A. | Data in a file |
B. | stderr |
C. | stdin |
D. | string |
Answer» E. | |
147. |
Size of an array can be evaluated by: (Assuming array declaration int a[10];) |
A. | sizeof(a); |
B. | sizeof(*a); |
C. | sizeof(a[10]); |
D. | 10 * sizeof(a); |
Answer» B. sizeof(*a); | |
148. |
%f access specifier is used for |
A. | Strings |
B. | Integral types |
C. | Floating type |
D. | All of the mentioned |
Answer» D. All of the mentioned | |
149. |
Which of the following fopen statements are illegal? |
A. | fp = fopen(“abc.txt”, “r”); |
B. | fp = fopen(“/home/user1/abc.txt”, “w”); |
C. | fp = fopen(“abc”, “w”); |
D. | none of the mentioned |
Answer» E. | |
150. |
Which is true about getc returns? |
A. | The next character from the stream is not referred by file pointer |
B. | EOF for end of file or error |
C. | Nothing |
D. | None of the mentioned |
Answer» C. Nothing | |