c fundamentals test
Post on 04-Jun-2018
217 Views
Preview:
TRANSCRIPT
-
8/13/2019 C Fundamentals Test
1/5
IACSD
C Programming Fundamentals
Duration : 60 Minutes Max. Marks: 40Question 1:Fill in the blanks [ 5 ]1. Every C program execution starts from the ____________ function.
2. In printf() function the format specifier used for string variable is _________.
. _____________ are names that are given to various program elements! such as variables!
functions and arrays.
". #fter compiling any C source code the resultant file has ____________ extension.
$. _____________ is a collection of data elements of same type.
Question 2:Select most correct option [ 10 ]1) %he C language is suitable for
a) #pplication programmingb) &ystem 'rogrammingc) oth of the aboved) one of the above
2) %he programming language consisting of english li*e +ords is *no+n asa) ,o+ level languageb) -igh level languagec) #ssembly languaged) achine language
) /hich one of the follo+ing statement is 0#,&Ea) %he compound statement must start +ith braces i.e. and end +ith .b) %he compound statement must be used only +ith if! +hile! do3+hile and
s+itch3.case statement.c) %he statements if! +hile! do3+hile and s+itch3.case etc. can be +ritten +ithout using
compound statement.d) %he statements if! +hile! do3+hile! for can be +ritten compound statement ! but
s+itch3.case and function etc. can not be +ritten +ithout using compound statement.
") %he variable in Ca) ust start +ith an alphabet.b) ust not contain sapce and special character except underscore.c) Can contain digitsd) #ll of the above
$) /hich of the follo+ing is used as logical #4 operator
a) 55b) 6 6c) 7d) one of the above
8) /hich one of the follo+ing bit+ise operator gives %9:E output only +hen there aredissimilar inputsa) 6b) ;c) 5d) i?@Aa?$A+hile( i B 2@)
aAi?aA
a) %he above loop executes 2@ timesb) %he above loop executes 1D timesc) %he above loop executes 1$ timesd) %he above loop is infinite loop.
) /hich one of the follo+ing is not valid string constanta) F>1$ '. .Gb) H9ed! /hite and luec) HChap. (CountJ Fd)d) H1.eK12
D) If i?= ! f?.1= and c? F+G then expression c 7? FpG 6 6 i f B? 1@ +ill return>a) %9:Eb) 0#,&Ec) one of the above
1@) If a?1! b?2! c? then after execution of follo+ing expression! +hat +ill be the value of thevariable c L
c ? (a M @ 55 a B?1@) L a > aNbAa) 2$b) $c) @.$d) @
Question 3:State TRU!F"#S [ 10 ]1) In C ! every string is terminated +ith FJ@G character.
2) %here is absolutely no difference bet+een builtKin ,ibrary functions getch() and getche().
) %he for loop is post tested loop.
") If a?$! then a and a +ill produce same result.
$) If char arrO$P ? HQood! then printf(HRc!arrO"P) +ill display character FdG.
8) %he logical errors are sho+n by compiler.
=) %he continue statement is used to bypass the remainder of the current pass through loop.
) %he dimension of the array can be a constant or it can be variable.
D) C language allo+s arrays of more than t+oKdimension.
1@) In C the comment symbols are JS and SJ.
Page 2 of 5
-
8/13/2019 C Fundamentals Test
3/5
Question $:Fin% the errors i& an' in the &ollo(in) pro)rams *(rite onl' errors+ [ 10 ]
1. T includeBstdio.hM
void ain()float a ? 2.2! b ? K8.2! x1 ? .@@$!
x2 ? K12.A
printf(HUR".2f R=.1fRR! a! b)Aprintf(Hx1?R=.f x2 ? R=.f!
x1 x2)Agetch()
2. T includeBstdio.hMvoid main()
printf(HJnEnter theColor(9N/N))A
&+itch( toupper(getchar))Case F9G > printf(9E4)A
brea*ACase F/G > printf(/-I%E)A
brea*ACase FG > printf(,:E)A
brea*A
. TincludeBstdio.hMvoid main()
int a?1@@A
b?a 2@Aprintf(HRc! b)A
". TincludeBstdio.hMvoid main()
long int arrO$P ? 1@! 2@! @! "@!
$@A for(i?1A i B? $A i)printf(HRd Nt! arrOiP)A
$. TincludeBstdio.hMvoid main()
char stringOP ? a!b!c!d!eAi?@A+hile( string OiP 7? FJ@G)
printf(HRc!stringOiP)A
Page 3 of 5
-
8/13/2019 C Fundamentals Test
4/5
Question 5:Fin% the output o& the &ollo(in) pro)rams:
1. TincludeBstdio.hM[ 2 ]
void main() int abcO P ? 2! 12! "$! "! 2@A
int i?@!V?@! tAfor(i ? @A iB"A i)for(V?i1A VB$A V)
t ? abcOiPAabcOiP ? abcOVPAabcOVP ? tA
for(i?@A i B $A i)
printf(HRdJt! abcOiP)Agetch()A
2. void main()[ 3 ]
char s1O1$P?HQood! s2O1@P?Hetter! sO$P?HestAint first?@!i ! length1! length2Aint *?@A V?@A
i ? @Alength1? strlen(s1)Alength2 ? strlen(s2)A
+hile( 1 )
if(s2OVP ?? FJ@G) i?@A first?1A
else
*? length1 iAif (7first)
s1O*P ? s2OiPAiA
else*? length1 length1 iAs1O*P ? sOVPA
VA
NS end of +hile SN
s1O*P ? FJ@GAputs(s1)A
Page 4 of 5
-
8/13/2019 C Fundamentals Test
5/5
getch()A
Page 5 of 5
top related