Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
C mcq practice test 3
1. Q1.What is the output of this code segment?
int age = 40;
if(age)
cout<< "Boy that is old!";
else
cout<< "Some day you will be old too";
a. Boy that is old!
b. Some day you will be old too
c. nothing—syntax error
d. prints something—but not choice a or b
ans a
Q2.
How many time the following function be called
main( )
{
int j;
j=10;
fun(j);
}
fun(int j)
{
if(j!=5)
fun(j-1);
}
a.
b.
c.
d.
10 times
5 times
6 times
Infinite loop
For more Questions Visit www.csemcq.com
2. Ans:-b
Q3 .What will be the output of the program?
#include<stdio.h>
int reverse(int);
int main()
{
int no=5;
reverse(no);
return 0;
}
int reverse(int no)
{
if(no == 0)
return 0;
else
printf("%d,", no);
reverse (no--);
}
A.
Print 5, 4, 3, 2, 1
B.
Print 1, 2, 3, 4, 5
C.
Print 5, 4, 3, 2, 1, 0
D.
Infinite loop
Ans:-D
Q4. Struct {int x,Float y, char z} will allocate _____________ bytes of memory
A.
B.
C.
D.
12
7
8
9
Answer B
Q5 The value of mango in the following enumeration will be:
For more Questions Visit www.csemcq.com
3. enum fruits{ apple=3, banana=2, mango, papaya=4, guava};
a) 0
b) 1
c) 2
d) 3
Ans: d
Q6. What will happen if in C program you assign a value to an array element
whose subscript exceeds the size of array?
a) The element will be set to 0
b) The complier would report an error
c) The program may crash if some important data gets overwritten
d) The array size would approximately grow
ans: C
Q7. int j[4] the sizeof(j) and sizeof(int) will display
a) 8,2
b) 2,8
c)2,2
d)2,4
ans: a
Q8 Find the output.
main( ) {
printf ( "n%d%d%d", sizeof ( ‘3’ ), sizeof ( "3" ), sizeof ( 3 ) ) ;
}
For more Questions Visit www.csemcq.com
4. A. 122
B.123
C.1234
D. Error
Ans a
Q9. int x[5]={2,3,4,5,6};
The base address is 65564 then the location of element 2 is:
a) 65564
b) 65566
c) 65568
d) None of these
Ans: a
Q10 Which is the formatted input function
a.
getch();
b.
scanf();
c.
gets();
d.
getche();
ans b
Ans b
Q9 Which of the following statement is correct?
A.
strcmp(s1, s2) returns a number less than 0 if s1>s2
For more Questions Visit www.csemcq.com
5. B.
strcmp(s1, s2) returns a number greater than 0 if s1<s2
C.
strcmp(s1, s2) returns 0 if s1==s2
D.
strcmp(s1, s2) returns 1 if s1==s2
Ans c
For more Questions Visit www.csemcq.com