Explore topic-wise MCQs in C Programming.

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.

1.

What will be the output of the program ?_x000D_ #include_x000D_ _x000D_ int main()_x000D_ {_x000D_ FILE *fp;_x000D_ unsigned char ch;_x000D_ /* file 'abc.c' contains "This is IndiaBIX " */_x000D_ fp=fopen("abc.c", "r");_x000D_ if(fp == NULL)_x000D_ {_x000D_ printf("Unable to open file");_x000D_ exit(1);_x000D_ }_x000D_ while((ch=getc(fp)) != EOF)_x000D_ printf("%c", ch);_x000D_ _x000D_ fclose(fp);_x000D_ printf("\n", ch);_x000D_ return 0;_x000D_ }

A. This is IndiaBIX
B. This is
C. Infinite loop
D. Error
Answer» D. Error
2.

Which of the following statement is correct about the program?_x000D_ #include_x000D_ _x000D_ int main()_x000D_ {_x000D_ FILE *fp;_x000D_ char str[11], ch;_x000D_ int i=0;_x000D_ fp = fopen("INPUT.TXT", "r");_x000D_ while((ch=getc(fp))!=EOF)_x000D_ {_x000D_ if(ch == '\n' || ch == ' ')_x000D_ {_x000D_ str[i]='\0';_x000D_ strrev(str);_x000D_ printf("%s", str);_x000D_ i=0;_x000D_ }_x000D_ else_x000D_ str[i++]=ch;_x000D_ }_x000D_ fclose(fp);_x000D_ return 0;_x000D_ }

A. The code writes a text to a file
B. The code reads a text files and display its content in reverse order
C. The code writes a text to a file in reverse order
D. None of above
Answer» C. The code writes a text to a file in reverse order
3.

Which of the following statement is correct about the program?_x000D_ #include_x000D_ _x000D_ int main()_x000D_ {_x000D_ FILE *fp;_x000D_ char ch;_x000D_ int i=1;_x000D_ fp = fopen("myfile.c", "r");_x000D_ while((ch=getc(fp))!=EOF)_x000D_ {_x000D_ if(ch == '\n')_x000D_ i++;_x000D_ }_x000D_ fclose(fp);_x000D_ return 0;_x000D_ }

A. The code counts number of characters in the file
B. The code counts number of words in the file
C. The code counts number of blank lines in the file
D. The code counts number of lines in the file
Answer» E.
4.

Point out the correct statements about the program?_x000D_ #include_x000D_ _x000D_ int main()_x000D_ {_x000D_ FILE *fptr;_x000D_ char str[80];_x000D_ fptr = fopen("f1.dat", "w");_x000D_ if(fptr == NULL)_x000D_ printf("Cannot open file");_x000D_ else_x000D_ {_x000D_ while(strlen(gets(str))>0)_x000D_ {_x000D_ fputs(str, fptr);_x000D_ fputs("\n", fptr);_x000D_ }_x000D_ fclose(fptr);_x000D_ }_x000D_ return 0;_x000D_ }

A. The code copies the content of one file to another
B. The code writes strings that are read from the keyboard into a file.
C. The code reads a file
D. None of above
Answer» C. The code reads a file
5.

Point out the error in the program?_x000D_ #include_x000D_ _x000D_ int main()_x000D_ {_x000D_ char ch;_x000D_ int i;_x000D_ scanf("%c", &i);_x000D_ scanf("%d", &ch);_x000D_ printf("%c %d", ch, i);_x000D_ return 0;_x000D_ }

A. Error: suspicious char to in conversion in scanf()
B. Error: we may not get input for second scanf() statement
C. No error
D. None of above
Answer» C. No error
6.

What will be the output of the program ?_x000D_ #include_x000D_ _x000D_ int main()_x000D_ {_x000D_ int k=1;_x000D_ printf("%d == 1 is" "%s\n", k, k==1?"TRUE":"FALSE");_x000D_ return 0;_x000D_ }

A. k == 1 is TRUE
B. 1 == 1 is TRUE
C. 1 == 1 is FALSE
D. K == 1 is FALSE
Answer» C. 1 == 1 is FALSE
7.

Point out the error in the program?_x000D_ #include_x000D_ #include_x000D_ _x000D_ int main()_x000D_ {_x000D_ unsigned char;_x000D_ FILE *fp;_x000D_ fp=fopen("trial", "r");_x000D_ if(!fp)_x000D_ {_x000D_ printf("Unable to open file");_x000D_ exit(1);_x000D_ }_x000D_ fclose(fp);_x000D_ return 0;_x000D_ }

A. Error: in unsigned char statement
B. Error: unknown file pointer
C. No error
D. None of above
Answer» D. None of above
8.

What will be the output of the program ?_x000D_ #include_x000D_ _x000D_ int main()_x000D_ {_x000D_ float a=3.15529;_x000D_ printf("%2.1f\n", a);_x000D_ return 0;_x000D_ }

A. 3
B. 3.15
C. 3.2
D. 3
Answer» D. 3
9.

What does fp point to in the program ?_x000D_ #include_x000D_ _x000D_ int main()_x000D_ {_x000D_ FILE *fp;_x000D_ fp=fopen("trial", "r");_x000D_ return 0;_x000D_ }

A. The first character in the file
B. A structure which contains a char pointer which points to the first character of a file.
C. The name of the file.
D. The last character in the file.
Answer» C. The name of the file.
10.

What will be the output of the program ?_x000D_ #include_x000D_ _x000D_ int main()_x000D_ {_x000D_ int a=250;_x000D_ printf("%1d \n", a);_x000D_ return 0;_x000D_ }

A. 1250
B. 2
C. 50
D. 250
Answer» E.
11.

Which is the invalid variable name in MATLAB?

A. x6
B. last
C. 6x
D. z
Answer» D. z
12.

To stop the execution of a MATLAB command, used keys?

A. ctrl+c
B. ctrl+s
C. ctrl+b
D. ctrl+enter
Answer» B. ctrl+s
13.

Executing in the editor window the following code returns.

A. 0.4815
B. 0.8415
C. 1
D. 0.9093View Answer
Answer» C. 1
14.

Command is used to save command window text to file.

A. saveas
B. texttofile
C. diary
D. todiary
Answer» D. todiary
15.

Executing in the command window the following code returns.

A. error message
B. 1 3
C. 3 1
D. 31View Answer
Answer» D. 31View Answer
16.

Which of the following statements shows the result of executing the following line in the editor window?

A. error
B. 1 3
C. 3 1
D. 3 3View Answer
Answer» B. 1 3
17.

Command used to display the value of variable x.

A. displayx
B. disp(x)
C. disp x
D. vardisp(‘x’)
Answer» C. disp x
18.

To determine whether an input is MATLAB keyword, command is?

A. iskeyword
B. key word
C. inputword
D. isvarname
Answer» B. key word
19.

Which command is used to clear a command window?

A. clear
B. close all
C. clc
D. clear all
Answer» D. clear all
20.

MATLAB stands for?

A. matrix laboratory
B. math library
C. matric library
D. matrix library
Answer» B. math library
21.

According to the rules followed in the above steps, which of the following would be step IV for the input given below?Input: ram accessing the office computer through his ID.

A. accessing computer ram the office through his ID
B. accessing ram the office computer through his ID
C. accessing computer his ram the office through ID
D. accessing computer his ID ram the office through
Answer» E.
22.

According to the rules followed in the above steps, which of the following will be step II for the input given below?Input: ram accessing the office computer through his ID.

A. accessing the office computer through his ID.
B. accessing computer ram the office through his ID.
C. accessing computer his ID ram the office through
D. accessing ram the office computer through his ID.
Answer» C. accessing computer his ID ram the office through
23.

Choose the odd numeral pair/group in each of the following questions.

A. 72 : 12
B. 114 : 19
C. 78 : 13
D. 119 : 17
Answer» E.
24.

Input: Keep 20 116 honey dell 68 54 yarnHow many steps will be required to complete the rearrangement?

A. Three
B. Four
C. Five
D. Six
E. None of these
Answer» D. Six
25.

As per the rules followed in the above steps, How many steps will be required to complete the rearrangement for the input given below?Input : Year 41 stock 48 honest for 93 55

A. V
B. III
C. IV
D. VI
Answer» E.
26.

How many words/numbers are there in between of 25 and 19 in step III?

A. 2
B. 3
C. 4
D. 5
E. None
Answer» D. 5
27.

In the last step of the input given below, three of the following four options are alike in a way and therefore form a group. Which one is not a part of that group?Input: Janmashtami 95 Holi 36 Chathurth 80 Diwali 68 Dushera 12 Navratri 54

A. Janmashtami 80
B. Chathurth 36
C. Dushere 54
D. Navratri 95
Answer» C. Dushere 54
28.

According to the rules followed in the above steps, how many elements are there between '46' and 'right' in the last step of the input given below?Input: 87 volt right 19 38 make cart hate gate 46 33 torn 63 95

A. Seven
B. Five
C. Eight
D. Six
Answer» B. Five
29.

According to the rules followed in the above steps, which word / number will be 7th from the right end in step VI of the input given below?Input 87 volt right 19 38 make cart hate gate 46 33 torn 63 95

A. volt
B. 95
C. 19
D. cart
Answer» C. 19
30.

According to the rules followed in the above steps, which step number is the following output for the input given below?38 33 19 87 volt right make 46 torn 63 95 cart gate hate?Input 87 volt right 19 38 make cart hate gate 46 33 torn 63 95

A. Step V
B. Step III
C. Step IV
D. Step VI
Answer» C. Step IV
31.

As per the rules followed in the above steps, answer the following question.If Step II of an Input is “highest 70 store paid 35 44 14 there”, which of the following will be step VI?

A. There will be no such step
B. Highest to paid 35 44 store 14 there
C. Highest to paid 44 store 35 there 14
D. Highest to paid 44 store 35 14 there
Answer» B. Highest to paid 35 44 store 14 there
32.

According to the rules given in the above steps, find the fourth term from the left in the third step in the following input.Input: 82 hertz 54 flake 34 rancid 94 appeal 18.

A. 34
B. Appeal
C. rancid
D. 18
Answer» B. Appeal
33.

According to the rules given in the above steps, find the third term from the right end to the left of the fourth in the third step of the following input.Input: 82 hertz 54 flake 34 rancid 94 appeal 18.

A. 54
B. rancid
C. 82
D. 34
Answer» B. rancid
34.

According to the rules applied in the above steps, which of the following will be fifth to the right of the ninth position from the right end in step IV of the input given below?Input: Janmashtami 95 Holi 36 Chathurth 80 Diwali 68 Dushera 12 Navratri 54

A. 36
B. 12
C. 80
D. 54
Answer» C. 80
35.

In the ultimate step, which of the following would be at 6th position from the right?

A. Soblen
B. Dnbounu
C. 38
D. 42
E. None of these
Answer» C. 38
36.

As per the rules followed in the above steps, which word / number is second to the right of fourth from the right end in the fourth step of the input given below?Input : Year 41 stock 48 honest for 93 55

A. 93
B. honest
C. 48
D. stock
Answer» E.
37.

How many words start with a vowel in Step III?

A. One
B. Two
C. Three
D. Four
E. None
Answer» F.
38.

According to the rules followed in the steps above, how many steps will be required to complete the reconstruction for the input below?Input: Near 55 Pound 85 15 Tallest 01 Push Gold 42

A. 4
B. 7
C. 8
D. 5
Answer» C. 8
39.

When comparing java.io.BufferedWriter and java.io.FileWriter, which capability exist as a method in only one of two ?

A. losing the stream
B. lushing the stream
C. ritting to the stream
D. ritting a line separator to the stream
E. one of these
Answer» E. one of these
40.

Which of these classes defined in java.io and used for file-handling are abstract?A. InputStreamB. PrintStreamC. ReaderD. FileInputStreamE. FileWriter

A. nly A
B. nly C
C. and C
D. and D
E. , B and E
Answer» D. and D
41.

try{File f = new File("a.txt");}catch(Exception e){}catch(IOException io){}Is this code create new file name a.txt ?

A. rue
B. alse
C. ompilation Error
D. one of these
Answer» D. one of these
42.

System class is defined in .................

A. ava.util package
B. ava.lang package
C. ava.io package
D. ava.awt package
E. one of these
Answer» C. ava.io package
43.

91 is related to 21 in step III in the same way 11 is related to 32 in the step I then 92 is related to which of the following in step IV in the same way?

A. 66
B. 84
C. 11
D. 51
E. 91
Answer» D. 51
44.

Input: belly 57 catch 21 book 43 boy 7Which of the following steps will be the last but one?

A. V
B. IV
C. VII
D. VI
E. None of these
Answer» E. None of these
45.

A number-arrangement machine, when given an input string of numbers, arranges them following a particular pattern. The following is the illustration of an input and its arrangement.Input:3497611Step I916814936121Step II1220905642132Step III1725956147137Step IV1523935945135 As per the rules followed in the above steps, find the appropriate answerWhat is the input if the following is the arrangement of Step IV?9, 75, 113, 213, 33, 5

A. 2, 10, 8, 14, 5, 3
B. 2, 10, 8, 13, 5, 1
C. 2, 8, 10, 14, 5, 1
D. 3, 8, 9, 13, 5, 1
Answer» D. 3, 8, 9, 13, 5, 1
46.

According to the rules applied in the above steps, which word/number will come in the sixth position from the left end in step 7 of the input given below?Input: 92 46 Cake All best 35 81 beauty 24 length.

A. 81
B. 35
C. Best
D. Beauty
Answer» C. Best
47.

According to the rules applied in the above steps, which option would be step 8 for the input given below?Input: 92 46 Cake All best 35 81 beauty 24 length.

A. Length Cake Beauty 46 All Best 35 24 81 92
B. Length Cake Beauty All Best 35 24 46 81 92
C. Length Cake Best Beauty All 24 35 46 81 92
D. Length Cake Beauty Best All 35 24 46 81 92
Answer» D. Length Cake Beauty Best All 35 24 46 81 92
48.

According to the rules applied in the above steps, if the input is: "92 46 Cake All best 35 81 beauty 24 length" then which step will be output?

A. 6
B. 5
C. 7
D. 8
Answer» E.
49.

According to the rules followed in the above steps, find the word/number from the left to the sixth position in step 5 for the input given below.Input: Near 55 Pound 85 15 Tallest 01 push gold 42

A. 15
B. 55
C. pound
D. 42
Answer» E.
50.

According to the rules followed in the above steps, find the 4th step for the input given below.Input: Near 55 Pound 85 15 Tallest 01 Push Gold 42

A. Pound 15 Near 01 Gold 42 Push Tallest 55 65
B. Push Tallest 55 85 42 01 Gold 15 Near Pound
C. 85 55 Tallest Push 42 Gold 01 Near 15 Pound
D. Gold 01 Near 15 Pound 55 85 Tallest Push 42
Answer» E.