You are on page 1of 13

Programming C MCQs

Contact @ 03027885074

Question 1
What is the correct value to return to the operating system upon the successful completion of a program? A. -1 B. 1 C. 0 D. Programs do not return a value.

Question 2
What is the only function all C programs must contain? A. start () B. system() C. main() D. program()

Question 3
What punctuation is used to signal the beginning and end of code blocks? A. { } B. -> and <C. BEGIN and END D. ( and )

Question 4
What punctuation ends most lines of C code? A. . (Dot) B. ; (semi-colon) C. : (colon) D. ' (single quote)

Question 5
Which of the following is a correct comment? A. */ Comments */ B. ** Comment ** C. /* Comment */ D. {Comment}

Question 6
Which of the following is not a correct variable type? A. float B. real C. int D. double

Contact: Muhammad Adnan Email: 08bitadnan@seecs.edu.pk

Programming C MCQs
Contact @ 03027885074

Question 7
Which of the following is the correct operator to compare two variables? A. := B. = C. equal D. ==

Question 8
Which of the following is true? A. 1 B. 66 C. .1 D. -1 E. All of the above //only 0 is False

Question 9
Which of the following is the Boolean operator for logical-and? A. & B. && C. | D. |&

Question 10
Evaluate! (1 &&! (0 || 1)) A. True B. False C. Unevaluatable

Question 11
Identify the correct statement A. Programmer can use comments to include short explanations within the source code itself. B. All lines beginning with two slash signs are considered comments. C. Comments very important effect on the behavior of the program D. both

Question 12
The directives for the preprocessors begin with A. Ampersand symbol (&) B. Two Slashes (//) C. Number Sign (#) D. Less than symbol (<)

Contact: Muhammad Adnan Email: 08bitadnan@seecs.edu.pk

Programming C MCQs
Contact @ 03027885074

Question 13
The file stdio includes A. B. C. D. The declarations of the basic standard input-output library. getch() and getche() math library None of these

Question 14
There is a unique function in C program by where all C programs start their execution A. B. C. D. Start () Begin () main () Output ()

Question 15
Every function in C are followed by A. Parameters B. C. D. Parenthesis Curly braces None of these

Question 16
Every statement in C program should end with A. B. C. D. A full stop (.) A Comma (,) A Semicolon (;) A colon (:)

Question 17
Which of the following statement is false about preprocessor directives? A. B. These are lines read and processed by the preprocessor They do not produce any code by themselves

C. These must be written on their own line D. They end with a semicolon

Question 18
A block comment can be written by A. Starting every line with double slashes (//) B. Starting with /* and ending with */ C. Starting with //* and ending with *//

Contact: Muhammad Adnan Email: 08bitadnan@seecs.edu.pk

Programming C MCQs
Contact @ 03027885074
D. Starting with <! - And ending with -!>

Question 19
When writing comments you can A. B. C. D. Use code and /* comment on the same line Use code and // comments on the same line Use code and //* comments on the same line Use code and <! - Comments on the same line

Question 20
A variable is/are A. String that varies during program execution B. C. D. A portion of memory to store a determined value The numbers which are frequently required in programs None of these

Question 21
Which of the following can not be used as identifiers (variable Name)? A. B. Letters Digits

C. Underscores D. Spaces

Question 22
The difference between x and x is A. B. C. D. The first one refers to a variable whose identifier is x and the second one refers to the character constant x The first one is a character constant x and second one is the string literal x Both are same None of above

Question 23
Which of the following is not a valid escape code? a. \t b. c. d. \v \f \w

Contact: Muhammad Adnan Email: 08bitadnan@seecs.edu.pk

Programming C MCQs
Contact @ 03027885074

Question 24
Which of the following statement is true? A. String Literals can extend to more than a single line of code by putting a backslash sign at the end of Each unfinished line. B. C. D. You can also concatenate several string constants separating them by one or several blank spaces Tabulators, newline or any other valid blank character If we want the string literal to explicitly made of wide characters, we can precede the constant with the L prefix All of above

Question 25
Regarding following statement which of the statements is true? A. B. C. D. Declares a variable pathwidth with 100 as its initial value Declares a construction pathwidth with 100 as its initial value Declares a constant pathwidth whose value will be 100 Constructs an integer type variable with pathwidth as identifier and 100 as value Const int pathwidth=100;

Question 26
In an assignment statement (statement which includes =) A. B. C. D. The left value must always be a variable The right value might be a constant, a variable, an expression or any combination of these The assignment always takes place from right to left and never the other way All of above

Question 27
In an assignment statement a=b; which of the following statement is true? A. The variable a and b are equal. B. C. D. The value of b is assigned to variable a but the later changes on variable b will not affect the value Of variable a The value of b is assigned to variable a and the later changes on variable b will effect the value of variable a The value of variable a is assigned to variable b and the value of variable b is assigned to variable a.

Question 28
All of the following are valid expressions in C A = 2 + (b = 5); B = b = c = 5; C = 11 % 3 A. B. True False

Contact: Muhammad Adnan Email: 08bitadnan@seecs.edu.pk

Programming C MCQs
Contact @ 03027885074

Question 29
To increase the value of c by one which of the following statement is wrong? A. B. C. D. c++; c = c + 1; c + 1 => c; c += 1

Question 30
When following piece of code is executed, what happens? b = 3; a = b++; A. B. C. D. a contains 3 and b contains 4 a contains 4 and b contains 4 a contains 4 and b contains 3 a contains 3 and b contains 3

Question 31
The result of a Relational operation is always A. B. C. D. either True or False is less than or is more than is equal or less or more All of these

Question 32
Which of the following is not a valid relational operator? A. B. C. D. == => >= >= //because= has lowest precedence

Question 33
What is the final value of x when the code int x; A. 10 B. 9 C. 0 D. 1 for(x=0; x<10; x++) {} is run?

Contact: Muhammad Adnan Email: 08bitadnan@seecs.edu.pk

Programming C MCQs
Contact @ 03027885074

Question 34
When does the code block following if(x<100) execute? A. When x is less than one hundred B. When x is greater than one hundred C. When x is equal to one hundred D. While it wishes

Question 35:
Which of the following is output function in C? A. default B. scanf C. print f D. cin

Question 36
Which of the following is input function in C? A. scanf B. printf C. default D. none of above

Question 37
By default, the standard output device for C programs is A. Printer B. Monitor (Screen of Computer) C. Modem D. Disk

Question 38
By default, the standard input device for C program is A. Keyboard B. Mouse C. Scanner D. None of these

Contact: Muhammad Adnan Email: 08bitadnan@seecs.edu.pk

Programming C MCQs
Contact @ 03027885074

Question 39
The return 0; statement in main function indicates A. The program did nothing; completed 0 tasks B. C. D. The program worked as expected without any errors during its execution not to end the program yet. None of above

Question 40
Which of the following is not a reserve keyword in C? A. int B. C. D. default readable switch

Question 41
The size of following variable is not 4 bytes in 32 bit systems A. int B. long int C. short int D. float

Question 42
Find out the error in following block of code. If (x = 100) printf( x is 100); A. 100 should be enclosed in quotations B. There is no semicolon at the end of first line C. Equals to operator mistake D. Variable x should not be inside quotation

Question 43
Which of the following is not a looping statement in C? A. while B. until C. do D. for

Contact: Muhammad Adnan Email: 08bitadnan@seecs.edu.pk

Programming C MCQs
Contact @ 03027885074

Question 44
Which of the following is not a jump statement in C? A. break B. goto C. exit D. switch

Question 45
Which of the following is selection statement in C? A. break B. goto C. exit D. switch

Question 46
Consider the following two pieces of codes and choose the best answer CODE 1: switch (x) { case 1: printf(x is 1); break; case 2: printf(x is 2); break; default: printf(value of x unknown) ;} CODE 2 If (x==1) printf(x is 1); else if (x==2){printf( x is 2);} else printf(value of x unknown); A. Both of the above code fragments have the same behaviour B. Both of the above code fragments produce different effects C. The first code produces more results than second D. The second code produces more results than first.

Question 47
Observe the following block of code and determine what happens when x=2? switch (x){case 1:case 2:case 3: printf( "x is 3, so jumping to third branch"); goto thirdBranch; default: cout<<"x is not within the range, so need to say Thank You!";} A. Program jumps to the end of switch statement since there is nothing to do for x=2 B. The code inside default will run since there is no task for x=2, so, default task is run C. Will display x is 3, so jumping to third branch and jumps to third Branch. Because we have not use breaks to stop D. None of above

Contact: Muhammad Adnan Email: 08bitadnan@seecs.edu.pk

Programming C MCQs
Contact @ 03027885074

Question 48
Which of the following is false for switch statement in C? A. It uses labels instead of blocks B. we need to put break statement at the end of the group of statement of a condition C. we can put range for case such as case 1...3 D. None of above

Question 49
Which operation is performed in which order in the following case. Indicate the precedence in both the case by numbering each operator?

a) Z = A * B % C + D / E F
1 2 4 3 5

b) Z = A * (B + C) + C *(D + E) 3 1 5 4 2

Question 50
Select best possible option from multiple choices What must be true for else statement A . It must contain a logical test. B . It must appear immediately after an if() statement in the program structure. C . It is associated with the closest if() statement above it D . It must be properly indented for the compiler to determine which If() statement is controlling it.

Question 51
Variables Declared but not initialized (does not given any value, no value is assigned to them) have value A. B. C. D. zero empty 1 Garbage Value

Contact: Muhammad Adnan Email: 08bitadnan@seecs.edu.pk

Programming C MCQs
Contact @ 03027885074

Question 52
Guess out put of following code int n = 2; switch (n) { case 1: { n = n + 1; break; } case 2: { n = n + 1; } case 3: { n = n + n; } default: { n = n - 1; } } cout<< "The value of n is << n;

The value of n is 5, because logic takes case 2 route then falls through case 3 and default.

Question 52
Determine output of this code int A = 1; int B = 2; if ( ((A == 1) || (B == 2)) && (B == 0)) cout "This exam was difficult \n"; else cout<<"This exam was easy \n";

This exam was easy

Contact: Muhammad Adnan Email: 08bitadnan@seecs.edu.pk

Programming C MCQs
Contact @ 03027885074

Question 53
Consider the following program segment If n=2, what is the value of sum? int n,sum=1; switch(n) { case 2:sum=sum+2; case 3:sum*=2; break; default:sum=0; } A. 0 B. 6 C. 3 D. 2

Question 54
Switch expression cannot be what A . Float B. Long C. both A and B D . none of above switch(expression)

Question 55
What will be value of this expression (!((4-4%3)<5 && (6/4>3))) A.0 B. 2 C. 1 D . Invalid

Question 56
Convert the following nested if statement into an equivalent switch statement

if (Grade == 'A') || (Grade == 'B') assignPassingWithHonors(); else if (Grade == 'C') || (Grade = 'D') assignPassingGrade(); else assignFailingGrade(); char grade; scanf(%c,grade); switch(grade) { case A: case B: assignPassingWithHonors();break; case C: case D: assignPassingGrade(); break; default: assignFailingGrade();

Contact: Muhammad Adnan Email: 08bitadnan@seecs.edu.pk

Programming C MCQs
Contact @ 03027885074

Question 57
The Smallest element in C language is called A . Integer B. header file C. class D . Token

Question 58
Which of the followings is not a reserved word (or key word? A . Main (main is reserver word but not Main) B. if C. int D . none of these

Question 59
Which of the followings are true if( number) when num= A. 1 B. -1 C. 10 D. 0 E. (First 3 are correct A, B, C) In c language only 0 means false other values means true

Question 60
Which statement will be printed on screen Num1=3,Num2=5 If(Num1=Num2) Printf (Both numbers are equal); else Print (The numbers are different); A. Both numbers are equal B. The numbers are different Note Because Num2 is 0 so this value is assigned to Num1 0 means fale in c language so when we chech if(Num1=Num2) it means if(0) or if(0) which is if (false) ,we know that whenever if condition is false, the control moves to else condition and output will be that of else statement

Contact: Muhammad Adnan Email: 08bitadnan@seecs.edu.pk

You might also like