MCQs
MCQs
MCQs
ii) A pointer is
a) a value
b) a variable containing the address of a variable
c) a memory location
d) none of these.
Ans: b)
vi) What will be the value of i and m after executing the following code segment ?
int i=5, m;
m=i++;
a) 5 and 6 b) 6 and 5
c) 5 and 5 d) 6 and 6.
Ans: b)
Explanation : here, for loop is ended with a ;, the for statement becomes
for(i= l ;i<5;i++)
{;}
So, when the loop will be terminated the value of i becomes 5.
main ( )
{
int d = 0 ;
if (d=5)
printf("Right");
else
printf("Wrong");
}
a) Right b) Wrong
c) WrongRight d) None of these.
Ans: a)
Explanation: Instead of comparison at the if statement, 5 will be assigned to d and the if
statement become if(5) which is true.
x) An array is a collection of
a) different data types scattered throughout memory
b) same data type scattered throughout memory
c) different data types placed next to each other in memory
d) same data type placed next to each other in memory.
Ans: d)
Set –II
Ans: b)
Explanation : a = 2+3*2+3
= 2+6+3
= 11
}
a) 01234 b) 024
c) compiler error d) none of these.
Ans: b)
iii) Output of the following code is
main ( )
{
int a[2][3] = { l, 2, 3, 4, 5, 6};
printf (“%d”, *(*(a+l)+2) );
}
a) 6 b) 2
c) compiler error d) none of these.
Ans: a)
Ans: d)
Explanation : The ASCII value difference of ‘a’ and ‘A’ is 32. So, output will be 32.
viii) When applied to a variable, what does the unary “&” operator yield ?
a) the variable’s address
b) the variable’s right value
c) the variable’s binary form
d) the variable’s value.
Ans: a)
a) *p++
b) ++p
c) (*p)++
d) all.
Ans: c)
Explanation : A constant object cannot be modified.
Set –III
fn(m+1);
}
a) finite b) infinite
c) stack overflow d) can’t say.
Ans: c)
ix) Which of the user defined data types store(s) different types of data in a single location?
a) Structure b) Union
c) Both (a) and (b) d) None of these.
Ans: b)
x) The fopen( ) function returns ………….. when the file is not opened.
a) -1 b) 1
c) NULL d) None of these.
Ans: c)
Set –IV
a) 1 b) 0
c) compiler dependent d) 2.
Ans: b)
ii) Which of the following operators that doesn't associate from left ?
a) ? : b) &&
c) , d) | |
Ans: a)
iii) int i, f = l;
for ( i = l ; i<=5; i++);
f = f * i;
printf ( “%d”, f);
. results in the printing of
a) 0 b) 5
c) 120 d) 6.
Ans: d)
iv) The expression 4 + 6/3*2-2 +7%3 evaluates to
a) 3 b) 4
c) 6 d) 7.
Ans: d)
vi) Data type of the controlling statement of a SWITCH statement cannot of the type
a) int b) char
c) short d) float.
Ans: d)
vii) main ( )
{
int a = 3;
printf ( “%d%d%d%d%d”, a++, ++a, ++a, a++);
}
a) 3566 b) 6653
c) 3565 d) 6666
Ans: b)
x) How many times the message Hello will be printed in the following program?
void main( )
{
int x;
for (x = -1;x<=10;x++)
{
if(x<5)
continue;
else
break;
printf(“Hello”);
}
}
a) 11 times b) 10 times
c) once d) 0 times.
Ans: d)
Set –V
vii) Assume that x = 50. Then what is the value of y where y = x = = x++; ?
a) 0 b) 1
c) 51 d) 50
Ans: b)
Ans: b)