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.
| 151. |
rand() and srand() functions are used |
| A. | To find sqrt |
| B. | For and operations |
| C. | For or operations |
| D. | To generate random numbers |
| Answer» E. | |
| 152. |
FILE reserved word is |
| A. | A structure tag declared in stdio.h |
| B. | One of the basic datatypes in c |
| C. | Pointer to the structure defined in stdio.h |
| D. | It is a type name defined in stdio.h |
| Answer» E. | |
| 153. |
What is the output of this C code (when 4 and 5 are entered)? |
| A. | Error |
| B. | 4 junkvalue |
| C. | Junkvalue 5 |
| D. | 4 5 |
| Answer» E. | |
| 154. |
int sscanf(char *string, char *format, arg1, arg2, …) |
| A. | Scans the string according to the format in format and stores the resulting values through arg1, arg2, etc |
| B. | The arguments arg1,arg2 etc must be pointers |
| C. | Scans the string according to the format in format and stores the resulting values through arg1, arg2, etc, those arguments arg1,arg2 etc must be pointers |
| D. | None of the mentioned |
| Answer» D. None of the mentioned | |
| 155. |
Loss in precision occurs for typecasting from____________. |
| A. | char to short |
| B. | float to double |
| C. | long to float |
| D. | float to int |
| Answer» E. | |
| 156. |
If there is any error while opening a file, fopen will return |
| A. | Nothing |
| B. | EOF |
| C. | |
| D. | Depends on compiler |
| Answer» D. Depends on compiler | |
| 157. |
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» B. A pointer to long | |
| 158. |
scanf returns as its value |
| A. | Number of successfully matched and assigned input items |
| B. | Nothing |
| C. | Number of characters properly printed |
| D. | Error |
| Answer» B. Nothing | |
| 159. |
stderr is similar to? |
| A. | stdin |
| B. | stdout |
| C. | Both stdout and stdin |
| D. | None of the mentioned |
| Answer» C. Both stdout and stdin | |
| 160. |
What happens when we use? fprintf(stderr, “error: could not open filen”); |
| A. | The diagnostic output is directly displayed in the output |
| B. | The diagnostic output is pipelined to the output file |
| C. | The line which caused error is compiled again |
| D. | The program is immediately aborted |
| Answer» B. The diagnostic output is pipelined to the output file | |
| 161. |
What happens when we use fprintf(stderr, “error: could not open filen”); |
| A. | The diagnostic output is directly displayed in the output |
| B. | The diagnostic output is pipelined to the output file |
| C. | The line which caused error is compiled again |
| D. | The program is immediately aborted |
| Answer» B. The diagnostic output is pipelined to the output file | |
| 162. |
What is the output of this C code if there is no error in stream fp? |
| A. | Compilation error |
| B. | 0 |
| C. | 1 |
| D. | Any nonzero value |
| Answer» C. 1 | |
| 163. |
Within main, return expr statement is equivalent to |
| A. | abort(expr) |
| B. | exit(expr) |
| C. | ferror(expr) |
| D. | none of the mentioned |
| Answer» C. ferror(expr) | |
| 164. |
ftell |
| A. | is a function |
| B. | gives the current file position indicator |
| C. | can be used to find the size of a file |
| D. | All of the above |
| Answer» E. | |
| 165. |
stdout, stdin and stderr are |
| A. | File pointers |
| B. | File desciptors |
| C. | Streams |
| D. | Structure |
| Answer» B. File desciptors | |
| 166. |
In the following statement fprintf(fpt,"%n",i), the variable fpt is a/an |
| A. | Integer variable |
| B. | Arbitrarily assigned value |
| C. | Pointer to a file |
| D. | Special kind of variable called file |
| Answer» D. Special kind of variable called file | |
| 167. |
If a file is opened in w+ mode then |
| A. | after write operation reading is possible without closing and re-opening |
| B. | reading is possible |
| C. | writing is possible |
| D. | All of the above |
| Answer» E. | |
| 168. |
Predict the data type of the following mathematical operation? 2 * 9 + 3 / 2 . 0 |
| A. | int |
| B. | long |
| C. | float |
| D. | double |
| Answer» E. | |
| 169. |
What does the statement printf("%d",10?0?5:1:12); prints : |
| A. | 10 |
| B. | 5 |
| C. | 12 |
| D. | 1 |
| Answer» E. | |
| 170. |
Which is true about isalnum(c), where c is an int that can be represented as an unsigned char or EOF.isalnum(c) returns? |
| A. | Non-zero if isalpha(c) or isdigit(c) |
| B. | 0 if not isalpha(c) or not isdigit(c) |
| C. | Both Non-zero if isalpha(c) or isdigit(c) & 0 if not isalpha(c) or not isdigit(c) |
| D. | None of the mentioned |
| Answer» D. None of the mentioned | |
| 171. |
Which among the following is right? |
| A. | sizeof(struct stemp*) > sizeof(union utemp*) > sizeof(char *) |
| B. | sizeof(struct stemp*) < sizeof(union utemp*) < sizeof(char *) |
| C. | sizeof(struct stemp*) = sizeof(union utemp*) = sizeof(char *) |
| D. | the order Depends on the compiler |
| Answer» D. the order Depends on the compiler | |
| 172. |
The statement printf ("%d", ( a++) ) ; prints |
| A. | the current value of a |
| B. | the value of a + 1 |
| C. | an error message |
| D. | garbage |
| Answer» B. the value of a + 1 | |
| 173. |
Which among the following is correct function call for rand and random? |
| A. | rand() and random(); |
| B. | rand() and random(1); |
| C. | rand(1) and random(1); |
| D. | rand(1) and random(); |
| Answer» B. rand() and random(1); | |
| 174. |
fputs function writes a string to a file that only ends with a newline |
| A. | true |
| B. | false |
| C. | Depends on the standard |
| D. | Depends on the compiler |
| Answer» C. Depends on the standard | |
| 175. |
Find the output of the following :for (i=1,j=10;i |
| A. | 1 1 0 2 9 3 8 4 7 5 6 |
| B. | 1 2 3 4 5 1 0 9 8 7 6 |
| C. | 1 1 1 1 1 9 9 9 9 9 |
| D. | Infinite Loop |
| Answer» B. 1 2 3 4 5 1 0 9 8 7 6 | |
| 176. |
int i = 5; is a statement in a C program.Which of the following are true? |
| A. | during execution, value of i may change but not its address |
| B. | during execution both the affress and value may change |
| C. | repeated execution may result in different addresses for i |
| D. | i may not have an assosiated address |
| Answer» D. i may not have an assosiated address | |
| 177. |
Which among the following is never possible in C when members in a structure are same as that in a union? //Let P be a structure //Let Q be a union |
| A. | sizeof(P) is greater than sizeof(Q) |
| B. | sizeof(P) is equal to sizeof(Q) |
| C. | sizeof(P) is less than to sizeof(Q) |
| D. | none of the mentioned |
| Answer» D. none of the mentioned | |
| 178. |
The syntax of fgets is char *fgets(char *line, int maxline, FILE *fp). Which is true for fgets.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. | |
| 179. |
In function free(p), p is a |
| A. | int |
| B. | Pointer returned by malloc() |
| C. | Pointer returned by calloc() |
| D. | Pointer returned by malloc() & calloc() |
| Answer» E. | |
| 180. |
The syntax to print a % using printf statement can be done by |
| A. | % |
| B. | %%% |
| C. | ‘%’ |
| D. | %% |
| Answer» E. | |
| 181. |
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» C. char scanf(int format, …) | |
| 182. |
The correct way to generate numbers between minimum and maximum(inclusive) is _________________ |
| A. | minimum + (rand() % (maximum – minimum)); |
| B. | minimum + (rand() % (maximum – minimum + 1)); |
| C. | minimum * (rand() % (maximum – minimum)); |
| D. | minimum – (rand() % (maximum+minimum)); |
| Answer» C. minimum * (rand() % (maximum – minimum)); | |
| 183. |
The sizeof(void) in a 32-bit C is_____ |
| A. | 0 |
| B. | 1 |
| C. | 2 |
| D. | 4 |
| Answer» C. 2 | |
| 184. |
Which is true about isaplpha(c), where c is an int that can be represented as an unsigned char or EOF.isalpha(c) returns? |
| A. | Non-zero if c is alphabetic |
| B. | 0 if c is not alphabetic |
| C. | Both Non-zero if c is alphabetic & 0 if c is not alphabetic |
| D. | None of the mentioned |
| Answer» D. None of the mentioned | |
| 185. |
The first and second arguments of fopen are |
| 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 poniter & 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 | |
| 186. |
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 | |
| 187. |
Which among the following mathematical function do not have a “double” return-type? |
| A. | srand(x); |
| B. | ceil(x); |
| C. | floor(x); |
| D. | both ceil(x); and floor(x); |
| Answer» B. ceil(x); | |
| 188. |
cos(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» D. cosine of x where x is in degree | |
| 189. |
Which of the following operations can be performed on the file "NOTES.TXT" using the below code?FILE *fp;fp = fopen("NOTES.TXT", "r+"); |
| A. | Reading |
| B. | Writing |
| C. | Appending |
| D. | Read and Write |
| Answer» E. | |
| 190. |
What is the meant by ‘a’ in the following operation? fp = fopen(“Random.txt”, “a”); |
| A. | Attach |
| B. | Append |
| C. | Apprehend |
| D. | Add |
| Answer» C. Apprehend | |
| 191. |
Printf("%d"printf("tim")); |
| A. | Result in a syntax error |
| B. | Outputs tim3 |
| C. | Outputs garbage |
| D. | Prints tim and terminate abruptly |
| Answer» C. Outputs garbage | |
| 192. |
If a file is opened in r+ mode then |
| A. | reading is possible |
| B. | writing is possible |
| C. | both (a) & (b) |
| D. | all the above comments are true |
| Answer» D. all the above comments are true | |
| 193. |
The 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 | |
| 194. |
The statement printf ("%d", ++5) ; prints |
| A. | 5 |
| B. | 6 |
| C. | an error message |
| D. | garbage |
| Answer» D. garbage | |
| 195. |
Which of the following statements are FALSE about the below code?int main(int ac, char *av[]){} |
| A. | ac contains count of arguments supplied at command-line |
| B. | av[] contains addresses of arguments supplied at a command line |
| C. | In place of ac and av, argc and argv should be used. |
| D. | The variables ac and av are always local to main() |
| Answer» D. The variables ac and av are always local to main() | |
| 196. |
The fseek function |
| A. | needs 3 arguments |
| B. | makes the rewind function unnecessary |
| C. | is meant for checking whether a given file exists or not |
| D. | both (a) and (b) |
| Answer» E. | |
| 197. |
printf( "%c", 100); |
| A. | prints 100 |
| B. | prints ASCII equivalent of 100 |
| C. | prints garbage |
| D. | none of above |
| Answer» C. prints garbage | |
| 198. |
FILE is of type ______ |
| A. | int type |
| B. | char * type |
| C. | struct type |
| D. | None of the mentioned |
| Answer» D. None of the mentioned | |
| 199. |
What is the purpose of "rb" in fopen() function used below in the code?FILE *fp;fp = fopen("source.txt", "rb"); |
| A. | open "source.txt" in binary mode for reading |
| B. | open "source.txt" in binary mode for reading and writing |
| C. | Create a new file "source.txt" for reading and writing |
| D. | None of above |
| Answer» B. open "source.txt" in binary mode for reading and writing | |
| 200. |
Escape sequences are prefixed with |
| A. | % |
| B. | / |
| C. | ” |
| D. | None of the mentioned |
| Answer» E. | |