Type Here to Get Search Results !

C Programming MCQs ( Multiple Choice Questions ) with Answers - Set II

0

 C Programming MCQs ( Multiple Choice Questions ) with Answers - Set II

     



Q1. What is the output of the following program?

#include<stdio.h>
int c [10]={1,2,3,4,5,6,7,8,9,10};  
       main ()
      { int a,b=0;
        for(a=0;a<10;++a)
if(c[a]%2= =1)
 b+=c[a];
 printf (‘%d”, b);
}

a) 20

b) 24

c) 25

d) 30

Answer is c) 25
Explanation : The remainder is 1 for only 1, 3, 5, 7, 9 numbers and the sum of these four numbers is 25.

 

Q2. What is the fifth element of the array int a[3][4]={1,2,3,4,5,6,7,8,9,10,11}; ?

a) 4

b) 6

c) 5

d) 7

Answer is c) 5
Explanation : In the two dimensional array representation there will be 3 rows and 4 columns. The elements are stored in row wise first. Hence the fifth element is 5.

 

Q3. int a [5]={1,2,3} what is the value of a[4]?

a) 3

b) 0

c) 1

d) Garbage value

Answer is d) Garbage value
Explanation : In the fourth location of an array contains garbage value since we are storing only three elements in the first three locations.

 

Q4. Information will be passed to the function via special identifier is

a) Arguments

b) Parameters

c) Both (a) and (b)

d) Elements

Answer is c) Both (a) and (b)
Explanation : We can call them as function arguments or parameters.

 

Q5. What is the associatively of the conditional operator?

a) Left to Right

b) Right to Left

c) Top to Bottom

d) Bottom to Top

Answer is d)
Explanation : For explanation Join the discussion below

 

Q6. What is the output of the following statement? 

printf(“%v”, 12);

a) 12

b) 12.0

c) %v

d) Garbage value

Answer is c) %v
Explanation : The control string %v is printed.

 

Q7. What is the output of the following statements?

for(int I = 10; I++; I<15)
 printf(“%d”, I);

a) 1011121314

b) 101112131415

c) 910111213

d) It will go to infinite loop

Answer is d) It will go to infinite loop
Explanation : Since the condition is always true it will go to infinite loop.

 

Q8. What is the output of the following statements?

int I = 0;
printf(“%d %d ”, I, I++);

a) 01

b) 10

c) 00

d) 11

Answer is b) 10
Explanation : Since the evaluation is from right to left.

 

Q9. 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

Answer is b) Short int
Explanation : The size of int is grater than or equal to short int.

 

Q10. Which of the following is a LOOP statement of a C language?

a) Repeat-Until

b) For

c) Do-While

d) Both b and c

Answer is d) Both b and c
Explanation : For loops and Do-While loop are a part of C programming

 

Q11. 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

Answer is c) 15
Explanation : For explanation Join the discussion below

 

Q12. What is the output of the following piece of code? <10 d="" i="" printf="" strong="">

for (int i = 0; i<10; i++)
printf(“%d”,i);

a) 10

b) 0123456789

c) Syntax error

d) 0

Answer is b) 0123456789
Explanation : for loop will run from i=0 to i<10 9="" i.e="" p="">

 

Q13. What value does srarray [5][4][0] in the sample code below contain?
int array[2][2][2] = {1,2,3,4,5,6,7,8,9,10,11,12};

a) 3

b) 5

c) 7

d) Garbage value

Answer is d) Garbage value
Explanation : Since that many number of rows and columns are not actually represented the garbage value is printed.

 

Q14. 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’;

a) 6

b) 7

c) 8

d) 5

Answer is a) 6
Explanation : The ASCII value of G is 71 and the garbage value if A is 65 and hence the difference is 6.

 

Q15. Which of following is not a valid name for a C variable?

a) HelloCodingHumans

b) Hello_CodingHumans

c) Hello CodingHumans

d) Both (a) and (b) above

Answer is c) Hello CodingHumans
Explanation : No Space are allowed in a variable names

 



If you have any doubts join the discussion below ,our Moderator will reply to your Queries


Post a Comment

0 Comments

Top Post Ad

Below Post Ad