C Programming and Problem Solving
Questions 21 to 30
21.
|
What is
the output of the following statements?
int I = 0;
printf(“%d %d ”, I, I++);
(a) 01 (b) 10 (c) 00 (d) 11 (e) Junk value.
|
22.
|
What is
the output of the following statements?
for(I =
10; I++; I<15)
printf(“%d”, I);
(a) 1011121314 (b) 101112131415
(c) 910111213 (d) It will go to infinite loop
(e) None of the above.
|
23.
|
The size
of an int must be greater than or equal to that of a _________
(a) Long int (b) Short int
(c) Float (d) Double (e) Char.
|
24.
|
Which of
the following is a LOOP statement of a C language?
(a) Repeat-Until (b) For (c) While-Do
(d) Do-while (e) Both (b) and (d) above.
|
25.
|
What is
the output of the following statements?
int b = 5, c = 15, d = 8, e = 8,a;
a = b>c?c>d?12:d>e?13:14:15;
printf(“%d”,
a);
(a) 13 (b) 14 (c) 15 (d) Garbage value (e) 12.
|
26.
|
What is
the output of the following piece of code?
for (i = 0;
i<10; i++);
printf(“%d”,i);
(a) 10 (b) 0123456789 (c)
Syntax error (d) 0 (e) Infinite loop.
|
27.
|
What
value does srarray [5][4][0] in the sample code below contain?
int srarray[2][2][2] =
{1,2,3,4,5,6,7,8,9,10,11,12};
(a) 3 (b) 5 (c) 7
(d) 9 (e) Garbage value.
|
28.
|
What
number would be shown on the screen after the following statements of C are
executed?
char ch; int
I; ch=’G’; I=ch-‘A’;
pirntf(“%d”, I);
(a) 6 (b) 7 (c)
8 (d) 5
(e) 9.
|
29.
|
Which of
following is not a valid name for
a C variable?
(a) Hairaj (b) Hello_raj
(c) Hello raj
(d) Both (a) and (b) above (e) None of the above.
|
30.
|
What
value would be stored in an integer variable “i” as a result of the following
expression?
int
i, j = 3; i = 4 + 2 * j/(j-1);
(a) 1 (b) 7 (c) 9 (d) 8
(e) 2.
|
Answers
21.
|
Answer : (b)
Reason: Since the evaluation is from right to left.
|
22.
|
Answer : (d)
Reason: Since the condition is always true it will
go to infinite loop.
|
23.
|
Answer : (b)
Reason: The size of int is grater than or equal to
short int.
|
24.
|
Answer : (e)
Reason:
|
25.
|
Answer : (c)
Reason:
|
26.
|
Answer : (a)
Reason: After 10 iterations for loop terminated and
the result is 10.
|
27.
|
Answer : (e)
Reason: Since that many number of rows and columns are not actually
represented the garbage value is printed.
|
28.
|
Answer : (a)
Reason: Since the ASCII value of G is 71 and the
garbage value if A is 65 and hence the difference is 6.
|
29.
|
Answer : (c)
Reason: No spaces are allowed in the variable names.
|
30.
|
Answer : (b)
Reason: According to operator precedence rule the
output is 7.
|
How can the answer of question no 22 is d (It will go to infinite loop)
ReplyDeletebecause when I will be equal to 14 and then after next increment value of I will be 15 and condition will wrong and loop will end.
I thought ans of 22 should be (a).
Any suggestion would be appreciated.
Great Article. Thank you for sharing! Really an awesome post for every one.
DeleteD2D Communications Meet Mobile Edge Computing for Enhanced Computation Capacity in Cellular Networks Project For CSE
Deep Reinforcement Learning for Online Computation Offloading in Wireless Powered Mobile Edge Computing Networks Project For CSE
Design and development of a mobile robotic CT system for intraoperative use Project For CSE
Energy Efficient Computation Offloading for Secure UAV Edge Computing Systems Project For CSE
Fog Computing for 5G Tactile Industrial Internet of Things QoE Aware Resource Allocation Model Project For CSE
Games and Graphics Code Examples
ReplyDeletethank you.
ReplyDeletec++ tutorial
java tutorial