You are on page 1of 13

(TEST PAPER) TCS, C, C++ Language Paper

1. The C anguage termnator s


(a) semcoon (b) coon (c) perod (d) excamaton mark
2. What s fase about the foowng -- A compound statement s
(a) A set of smpe statements (b) Demarcated on ether sde by
cury brackets
(c) Can be used n pace of smpe statement (d) A C functon s not a
compound statement.
3. What s true about the foowng C Functons
(a) Need not return any vaue (b) Shoud aways return an
nteger
(c) Shoud aways return a oat (d) Shoud aways return more
than one vaue
4. Man must be wrtten as
(a) The rst functon n the program (b) Second functon n the
program
(c) Last functon n the program (d) Any where n the program
5. Whch of the foowng about automatc varabes wthn a functon s correct ?
(a) Its type must be decared before usng the varabe (b) They
are oca
(c) They are not ntazed to zero (d) They are
goba
6. Wrte one statement equvaent to the foowng two statements: x=sqr(a);
return(x); Choose from one of the aternatves
(a) return(sqr(a)); (b) prntf("sqr(a)");
(c) return(a*a*a); (d) prntf("%d",sqr(a));
7. Whch of the foowng about the C comments s ncorrect ?
(a) Comments can go over mutpe nes
(b) Comments can start any where n the ne
(c) A ne can contan comments wth out any anguage statements
(d) Comments can occur wthn comments
8. What s the vaue of y n the foowng code?
x=7;
y=0;
f(x=6) y=7;
ese y=1;
(a) 7 (b) 0 (c) 1 (d) 6
9. Read the functon conv() gven beow
conv(nt t)
{
nt u;
u=5/9 * (t-32);
return(u);
}
What s returned
(a) 15 (b) 0 (c) 16.1 (d) 29
10. Whch of the foowng represents true statement ether x s n the range of 10
and 50 or y s zero
(a) x >= 10 && x <= 50 || y = = 0 (b) x<50
(c) y!=10 && x>=50 (d) None of these
11. Whch of the foowng s not an nnte oop ?
(a) whe(1)\{ ....} (b) for(;;){...}
(c) x=0; (d) # dene TRUE 0
do{ /*x unatered
wthn the oop*/ ...
.....}whe(x = =
0); whe(TRUE){ ....}
12. What does the foowng functon prnt?
func(nt )
{
f(%2)return 0;
ese return 1;
}
man()
{
nt =3;
=func();
=func();
prntf("%d",);
}
(a) 3 (b) 1 (c) 0 (d) 2
13. How does the C comper nterpret the foowng two statements
p=p+x;
q=q+y;
(a) p= p+x; (b) p=p+xq=q+y; (c) p= p+xq; (d)
p=p+x/q=q+y;
q=q+y;
q=q+y;
For questons 14,15,16,17 use the foowng aternatves:
a. nt b. char c. strng d. oat
14. '9'
15. "1 e 02"
16. 10e05
17. 15
18. Read the foowng code
# dene MAX 100
# dene MIN 100
....
....
f(x>MAX)
x=1;
ese f(x<MIN)
x=-1;
x=50;
f the nta vaue of x=200,what s the vaue after executng ths code?
(a) 200 (b) 1 (c) -1 (d) 50
19. A memory of 20 bytes s aocated to a strng decared as char *s then the
foowng two statements are executed:
s="Entrance"
=stren(s);
what s the vaue of ?
(a)20 (b)8 (c)9 (d)21
20. Gven the pece of code
nt a|50|;
nt *pa;
pa=a;
To access the 6th eement of the array whch of the foowng s ncorrect?
(a) *(a+5) (b) a|5| (c) pa|5| (d) *(*pa + 5}
21. Consder the foowng structure:
struct num nam
{
nt no;
char name|25|;
}
struct num nam n1||={{12,"Fred"},{15,"Martn"},{8,"Peter"},{11,Nchoas"}};
.....
.....
prntf("%d%d",n1|2|,no,(*(n1 + 2),no) + 1);
What does the above statement prnt?
(a) 8,9 (b) 9,9 (c) 8,8 (d) 8, unpredctabe vaue
22. Identfy the n correct expresson
(a)a=b=3=4; (b)a=b=c=d=0; (c)oat a=nt b= 3.5; (d)nt a; oatb;a=b=3.5;
23. Regardng the scope of the varbes;dentfy the ncorrect statement:
(a) automatc varabes are automatcay ntazed to 0 (b) statc
varabes are are automatcay ntazed to 0
(c) the address of a regster varabe s not accessbe (d) statc varabes
cannot be ntazed wth any expresson
24. cond 1?cond 2?cond 3?:exp 1:exp 2:exp 3:exp 4; s equvaent to whch of the
foowng?
(a) f cond 1
exp 1;
ese f cond 2
exp 2;
ese f cond 3
exp 3;
ese exp 4;
(b) f cond 1
f cond 2
f cond 3
exp 1;
ese exp 2;
ese exp 3;
ese exp 4;
(c) f cond 1 && cond 2 && cond 3
exp 1 |exp 2|exp 3|exp 4;
(d) f cond 3
exp 1;
ese f cond 2 exp 2;
ese f cond 3 exp 3;
ese exp 4;
25. The operator for exponentaton s
(a) ** (b) (c) % (d) not avaabe
26. Whch of the foowng s nvad
(a) a+=b (b) a*=b (c) a>>=b (d) a**=b
27. What s y vaue of the code f nput x=10
y=5;
f (x==10)
ese f(x==9)
ese y=8;
(a)9 (b)8 (c)6 (d)7
28. What does the foowng code do?
fn(nt n, nt p, nt r)
{
statc nt a=p;
swtch(n)
{
case 4:a+=a*r;
case 3:a+=a*r;
case 2:a+=a*r;
case 1:a+=a*r;
}
}
(a) computes smpe nterest for one year (b) computes amount on
compound nterest for 1 to 4 years
(c) computes smpe nterest for four year (d) computes compound
nterest for 1 year
29.
a=0;
whe(a<5)
prntf("%d\\n",a++);
How many tmes does the oop occurs?
(a) nnte (b)5 (c)4 (d)6
30. How many tmes does the oop terated ?
for(=0;=10;+=2)
prntf("H\\n");
(a)10 (b) 2 (c) 5 (d) None of these
31. What s ncorrect among the foowng
A recursve functon
(a) cas tsef (b) s equvaent to a oop
(c) has a termnaton condton (d) does not have a return vaue at a
32. Whch of the foowng go out of the oop f expn 2 becomng fase
(a) whe(expn 1)\{...f(expn 2)contnue;} (b) whe(!expn
1)\{f(expn 2)contnue;...}
(c) do{..f(expn 1)contnue;..}whe(expn 2); (d) whe(!expn
2)\{f(expn 1)contnue;..\}
33. Consder the foowng program
man()
{
unsgned nt =10;
whe(>=0)
{
prntf("%u",)
--;
}
}
How many tmes the oop w get executed
(a)10 (b)9 (c)11 (d) nnte
34.Pck out the odd one out
(a) maoc() (b) caoc() (c) free() (d) reaoc()
35.Consder the foowng program
man()
{
nt a|5|={1,3,6,7,0};
nt *b;
b=&a|2|;
}
The vaue of b|-1| s
(a) 1 (b) 3 (c) -6 (d) none
36. # dene prod(a,b)=a*b
man()
{
nt x=2;
nt y=3;
prntf("%d",prod(x+2,y-10));
}
the output of the program s
(a) 8 (b) 6 (c) 7 (d) None
37.Consder the foowng program segment
nt n,sum=1;
swtch(n)
{
case 2:sum=sum+2;
case 3:sum*=2;
break;
defaut:sum=0;
}
If n=2, what s the vaue of sum
(a) 0 (b) 6 (c) 3 (d) None of these
38. Identfy the ncorrect one
1.f(c=1)
2.f(c!=3)
3.f(a<b)then
4.f(c==1)
(a) 1 ony (b) 1&3 (c) 3 ony (d) A of the above
39. The format speced for hexa decma s
(a) %d (b) %o (c) %x (d) %u
40. Fnd the output of the foowng program
man()
{
nt x=5, *p;
p=&x
prntf("%d",++*p);
}
(a) 5 (b) 6 (c) 0 (d) none of these
41.Consder the foowng C code
man()
{
nt =3,x;
whe(>0)
{
x=func();
--;
}
nt func(nt n)
{
statc sum=0;
sum=sum+n;
return(sum);
}
}
The na vaue of x s
(a) 6 (b) 8 (c) 1 (d) 3
42. Int *a|5| refers to
(a) array of ponters (b) ponter to an array (c) ponter to a ponter
(d) none of these
43.Whch of the foowng statements s ncorrect
(a) typedef struct new
{
nt n1;
char n2;
} DATA;
(b) typedef struct
{
nt n3;
char *n4;
}ICE;
(c) typedef unon
{
nt n5;
oat n6;
} UDT;
(d) #typedef unon
{
nt n7;
oat n8;
} TUDAT;

You might also like