Sei sulla pagina 1di 12

C Sample Test

This test consists of 50 questions.The Set Code for this paper is D. 1. The C language terminator is (a) semicolon (b) colon (c) period (d) exclamation mar !. "hat is false about the follo#ing $$ % compound statement is (a) % set of simple statments (b) Demarcated on either side b& curl& brac ets (c) Can be used in place of simple statement (d) % C function is not a compound statement. '. "hat is true about the follo#ing C (unctions (a) )eed not return an& *alue (b) Should al#a&s return an integer (c) Should al#a&s return a float (d) Should al#a&s return more than one *alue +. ,ain must be #ritten as (a) The first function in the program (b) Second function in the program (c) -ast function in the program (d) %n& #here in the program 5. "hich of the follo#ing about automatic *ariables #ithin a function is correct . (a) /ts t&pe must be declared before using the *ariable (b) Tthe& are local (c) The& are not initialised to 0ero (d) The& are global

1. "rite one statement equi*alent to the follo#ing t#o statements x2sqr(a)3 return(x)3 Choose from one of the alternati*es (a) return(sqr(a))3 (b) printf(4sqr(a)4)3 (c) return(a5a5a)3 (d) printf(46d47sqr(a))3 8. "hich of the follo#ing about the C comments is incorrect . (a) Ccommentscan go o*er multiple lines (b) Comments can start an& #here in the line (c) % line can contain comments #ith out an& language statements (d) Comments can occur #ithin comments 9. "hat is the *alue of & in the follo#ing code. x283 &203 if(x21) &283 else &213 (a) 8 (b) 0 (c) 1 (d) 1 :. ;ead the function con*() gi*en belo# con*(int t)< int u3 u25=: 5 (t$'!)3 return(u)3 > "hat is returned (a) 15 (b) 0 (c) 11.1 (d) !:

10. "hich of the follo#ing represents true statement either x is in the range of 10 and 50 or & is 0ero (a) x ?2 10 @@ x A2 50 BB & 2 2 0 (b) xA50 (c) &C210 @@ x?250 (d) )one of these 11. "hich of the follo#ing is not an infinite loop . (a) #hile(1)D< ....> (b) for(33) < ... > (c) x203 do< =5x unaltered #ithin the loop5= .....> #hile(x 2 2 0)3 (d) E define T;FG 0 ... #hile(T;FG)< ....>

1!. "hat does the follo#ing function print. func(int i) < if(i6!)return 03 else return 13> main() < int 2'3 i2func(i)3 i2func(i)3 printf(46d47i)3 > (a) ' (b) 1

(c) 0 (d) ! 1'. Ho# does the C compiler interpret the follo#ing t#o statements p2pIx3 q2qI&3 (a) p2pIx3 q2qI& (b)p2pIxq2qI& (c)p2pIxq3 q2qI& (d)p2pIx=q2qI&

(or questions 1+715711718 use the follo#ing alternati*es a.int b.char c.string d.float 1+. J:J 15. 41 e 0!4 11. 10e05 18. 15

19. ;ead the folllo#ing code E define ,%K 100 E define ,/) 100 .... .... if(x?,%K) x213 else if(xA,/)) x2$13 x2503 if the initial *alue of x2!007#hat is the *alue after executing this code.

(a) !00 (b) 1 (c) $1 (d) 50 1:. % memor& of !0 b&tes is allocated to a string declared as char 5s then the follo#ing t#o statements are executedL s24Gntrance4 l2strlen(s)3 #hat is the *alue of l . (a)!0 (b)9 (c): (d)!1 !0. Mi*en the piece of code int aN50O3 int 5pa3 pa2a3 To access the 1th element of the arra& #hich of the follo#ing is incorrect. (a) 5(aI5) (b) aN5O (c) paN5O (d) 5(5pa I 5> !1. Consider the follo#ing structureL struct num nam< int no3 char nameN!5O3 > struct num nam n1NO2<<1!74(red4>7<1574,artin4>7<974Peter4>7<117)icholas4>>3 ..... ..... printf(46d6d47n1N!O7no7(5(n1 I !)7no) I 1)3 "hat does the abo*e statement print.

(a) 97: (b) :7: (c) 979 (d) 97unpredictable *alue !!. /dentif& the in correct expression (a) a2b2'2+3 (b) a2b2c2d203 (c)float a2int b2'.53 (d)int a3 float b3 a2b2'.53 !'. ;egarding the scope of the *aribles3identif& the incorrect statementL (a)automatic *ariables are automaticall& initialised to 0 (b)static *ariables are are automaticall& initialised to 0 (c)the address of a register *ariable is not accessiable (d)static *ariables cannot be initialised #ith an& expression !+. cond 1.cond !.cond '.Lexp 1Lexp !Lexp 'Lexp +3 is equi*alent to #hich of the follo#ing. (a)if cond 1 exp 13 else if cond ! exp !3 else if cond ' exp '3 else exp +3 (b) if cond 1 if cond ! if cond ' exp 13 else exp !3 else exp '3 else exp +3 (c) if cond 1 @@ cond ! @@ cond ' exp 1 Bexp !Bexp 'Bexp +3 (d) if cond ' exp 13

else if cond ! exp !3 else if cond ' exp '3 else exp +3

!5. The operator for exponencation is (a) 55 (b) Q (c) 6 (d) not a*ailable !1. "hich of the follo#ing is in*alid (a) aI2b (b) a52b (c) a??2b (d) a552b !8. "hat is & *alue of the code if input x210 &253 if (x2210) else if(x22:) else &293 (a): (b)9 (c)1 (d)8 !9. "hat does the follo#ing code do. fn(int n7int p7int r)< static int a2p3 s#itch(n)< case +LaI2a5r3 case 'LaI2a5r3 case !LaI2a5r3 case 1LaI2a5r3>>

(a)computes simple interest for one &ear (b)computes amount on compound interest for 1 to + &ears (c)computes simple interest for four &ear (d)computes compound interst for 1 &ear !:. a203 #hile(aA5) printf(46dDDn47aII)3 Ho# man& times does the loop occurs. (a)infinite (b)5 (c)+ (d)1 '0. Ho# man& times does the loop iterated . for (i203i2103iI2!) printf(4HiDDn4)3 (a)10 (b) ! (c) 5 (d) )one of these '1. "hat is incorrect among the follo#ing % recursi*e function (a) calls itself (b) is equi*alent to a loop (c) has a termination condition (d) does not ha*e a return *alue at all

'!. "hich of the follo#ing go out of the loop if expn ! becoming false (a) #hile(expn 1)D<...if(expn !)continue3> (b) #hile(Cexpn 1)D<if(expn !)continue3...> (c) do<..if(expn 1)continue3..>#hile(expn !)3 (d) #hile(Cexpn !)D<if(expn 1)continue3..D>

''. Consider the follo#ing program main() <unsigned int i2103 #hile(i?20)< printf(46u47i) i$$3> > Ho# man& times the loop #ill get executed (a)10 (b): (c)11 (d)infinite '+.Pic out the add one out (a) malloc() (b) calloc() (c) free() (d) realloc() '5.Consider the follo#ing program main()< int aN5O2<17'717870>3 int 5b3 b2@aN!O3 > The *alue of bN$1O is (a) 1 (b) ' (c) $1 (d) none '1. E define prod(a7b)2a5b main()< int x2!3 int &2'3 printf(46d47prod(xI!7&$10))3 >

the output of the program is (a) 9 (b) 1 (c) 8 (d) )one '8.Consider the follo#ing program segment int n7sum213 s#itch(n)< case !Lsum2sumI!3 case 'Lsum52!3 brea 3 defaultLsum203> /f n2!7 #hat is the *alue of sum (a) 0 (b) 1 (c) ' (d) )one of these '9. /dentif& the incorrect one 1.if(c21) !.if(cC2') '.if(aAb)then +.if(c221) (a) 1 onl& (b) 1@' (c) ' onl& (d) %ll of the abo*e ':. The format specified for hexa decimal is (a) 6d (b) 6o (c) 6x (d) 6u

+0. (ind the output of the follo#ing program main()< int x257 5p3 p2@x printf(46d47II5p)3 > (a) 5 (b) 1 (c) 0 (d) none of these +1.Consider the follo#ing C code main()< int i2'7x3 #hile(i?0)< x2func(i)3 i$$3 > int func(int n)< static sum203 sum2sumIn3 return(sum)3> The final *alue of x is (a) 1 (b) 9 (c) 1 (d) ' +'. /nt 5aN5O refers to (a) arra& of pointers (b) pointer to an arra& (c) pointerto a pointer (d) none of these ++."hich of the follo#ing statements is incorrect

(a) t&pedef struct ne#< int n13 char n!3 > D%T%3 (b) t&pedef struct < int n'3 char 5n+3>/CG3 (c) t&pedef union< int n53 float n13> FDT3 (d) Et&pedef union < int n83

Potrebbero piacerti anche