Pic 22413 MCQ Unit 3
Pic 22413 MCQ Unit 3
Pic 22413 MCQ Unit 3
1. In the following loop construct, which one is executed only once always.   Â
for(exp1; exp2; exp3)
A. exp1
B. exp3
C. exp1 and exp3
D. exp1, exp2 and exp3
Ans : A
A. for
B. while
C. do while
D. switch
Ans : D
A. return
B. break
C. exit
D. both A and B
Ans : A
A. TRUE
B. FALSE
C. May Be
D. Can't Say
Ans : B
A. if (if (a == 1)){}
B. if (a){}
C. if ((char) a){}
D. if (func1 (a)){}
Ans : A
A. int
B. char
C. long
D. All of the above
Ans : D
A. for
B. while
C. do while
D. None of the above
Ans : C
A. ;
B. :
C. ,
D. =
Ans : B
A. One
B. Zero
C. Non - zero
D. None of the above
Ans : B
10. c = (n) ? a : b; can be rewritten as exp1 ? exp2 : exp3;
11. The C code ‘for(;;)’ represents an infinite loop. It can be terminated by ___________
a) break
b) exit(0)
c) abort()
d) terminate
Answer: a
12. What will be the correct syntax for running two variable for loop simultaneously?
a)
Answer: b
13. Which for loop has a range of similar indexes of ‘i’ used in for (i = 0;i < n; i++)?
Answer: d
14. Which of the following cannot be used as LHS of the expression in for (exp1;exp2;
exp3)?
a) variable
b) function
c) typedef
d) macros
Answer: d
1. #include <stdio.h>
2. int main()
3. {
4. short i;
5. for (i = 1; i >= 0; i++)
6. printf("%d\n", i);
7.
8. }
a) The control won’t fall into the for loop
b) Numbers will be displayed until the signed limit of short and throw a runtime error
c) Numbers will be displayed until the signed limit of short and program will successfully
terminate
d) This program will get into an infinite loop and keep printing numbers with no errors
Answer: c
1. #include <stdio.h>
2. void main()
3. {
4. int k = 0;
5. for (k)
6. printf("Hello");
7. }
a) Compile time error
b) hello
c) Nothing
d) Varies
Answer: a
1. #include <stdio.h>
2. void main()
3. {
4. int k = 0;
5. for (k < 3; k++)
6. printf("Hello");
7. }
a) Compile time error
c) Nothing
d) Varies
Answer: a
1. #include <stdio.h>
2. void main()
3. {
4. double k = 0;
5. for (k = 0.0; k < 3.0; k++)
6. printf("Hello");
7. }
a) Run time error
Answer: b
Happy Learning!
cwipedia.in