You are on page 1of 6

PAPER: HCL Placement Paper (C- Programming)

C Programming
1. Which of the following abot the following two !eclaration i" tre
i ) int #$()
ii) int (#$)()
Choice :
a) %oth are i!entical
b) &he fir"t i" a correct !eclaration an! the "econ! i" wrong
c) &he fir"t !eclaration i" a fnction retrning a pointer to an integer an! the "econ! i" a
pointer to fnction retrning int
!) %oth are !ifferent wa'" of !eclaring pointer to a fnction
An"wer : c) &he fir"t !e...
(. What are the )ale" printe! b' the following program*
+!efine !print(e,pr) printf(+e,pr -./!0n-1e,pr)
main()
2
int ,.34
int '.54
!printf(,6')4
7
Choice:
a) +( . ( b) e,pr.( c) ,6'.( !) none
An"wer: c),6'.(
5. Which of the following i" tre of the following program
main()
2
char #c4
int #ip4
c .(char #)malloc(188)4
ip.(int #)c4
free(ip)4
7
An": &he co!e fnction" properl' relea"ing all the memor' allocate!
9.otpt of the following.
main()
2
int i4
char #p4
i.8:;<4
p.(char #)i4
p==4
printf(-/,0n-1p)4
7
an":8:;A
>.which of the following i" not a A?@A C langage Be'wor!*
An": $nction.
C. When an arra' i" pa""e! a" parameter to a fnction1 which of the following "tatement i"
correct
choice:
a) &he fnction can change )ale" in the original arra'
b) An C parameter" are pa""e! b' )ale. &he fnction cannot change the original )ale in
the arra'
c) At re"lt" in compilation error when the fnction trie" to acce"" the element" in the
arra'
!) Re"lt" in a rn time error when the fnction trie" to acce"" the element" in the arra'
An"wer: a) &he f...
3. &he t'pe of the controlling e,pre""ion of a "witch "tatement cannot be of the t'pe
a) int b) char c) "hort !) float e) none
An"wer : !) float
;.What i" the )ale of the e,pre""ion (5DC) = (aDa)*
a) 5 b) > c) C !) a=1; e) ?one
An"wer : >
<. What i" the )ale a""igne! to the )ariable : if b i" 3 *
: . bE; * b FF5 : bE9 * bEE1:b4
a) 3 b) (; c) 5 !) 19 e) ?one
An": 54
18. Which i" the otpt pro!ce! b' the following program
main()
2
int n.(4
printf(-/! /!0n-1 ==n1 n#n)4
7
a) 51C b) 519 c) (19 !) cannot !etermine
An"wer : b) 519
11. What i" the otpt of the following program*
int ,. 8,C>4
main()
2
char ,4
printf(-/!0n-1,)
7
a) compilation error b) GAG c) C> !) ni!entifie!
an". !)
1(. What i" the otpt of the following program
main()
2
int a.184
int b.C4
if(a.5)
b==4
printf(-/! /!0n-1a1b==)4
7
a) 181C b)1813 c) 51C !) 513 e)
none
An"wer : !) 513
15. What can be "ai! of the following program*
main()
2
enm Honth" 2IA? .11$E%1HAR1APR74
Honth" : . IA?4
if(:..1)
2
printf(-Ian i" the fir"t month-)4
7
7
a) Joe" not print an'thing
b) Print" : Ian i" the fir"t month
c) Kenerate" compilation error
!) Re"lt" in rntime error
An"wer: b) Print" : Ian..
19. What i" the otpt of the following program*
main()
2
char #"rc . -Hello Worl!-4
char !"tL188M4
"trcp'(!"t1"rc)4
printf(-/"-1!"t)4
7
"trcp'(char #!"t1char #"rc)
2
while(#"rc) #!"t== . #"rc==4
7
a) -Hello Worl!- b)-Hello- c)-Worl!- !) ?NLL e)
ni!entifie!
An"wer: !) ?NLL
1>. What i" the otpt of the following program*
main()
2
int l.C4
"witch(l)
2 !efalt : l=.(4
ca"e 9: l.94
ca"e >: l==4
breaB4
7
printf(-/!-1l)4
7
a); b)C c)> !)9 e)none
An"wer : c)>
1C. What i" the otpt of the following program*
main()
2
int ,.(84
int '.184
"wap(,1')4
printf(-/! /!-1'1,=()4
7
"wap(int ,1int ')
2
int temp4
temp .,4
,.'4
'.temp4
7
a)181(8 b) (811( c) ((118 !)181((
e)none
An"wer:!)181((
13. What i" the otpt of the following problem *
+!efine A?C(:) :==
main()
2
int :.94
printf(-/!-1A?C(:==))4
7
a)9 b)> c)C !)compilation error e) rntime
error
An"wer : !) compilation error no ==== operator allowe!
1;. what can be "ai! of the following
"trct ?o!e 2
char #wor!4
int cont4
"trct ?o!e left4
"trct ?o!e right4
7
a) Ancorrect !efinition
b) "trctre" cannot refer to other "trctre
c) @trctre" can refer to them"el)e". Hence the "tatement i" OP
!) @trctre" can refer to ma,imm of one other "trctre
An"wer :c)
1<. What i" the "iQe of the following nion.
A""me that the "iQe of int .(1 "iQe of float .9 an!
"iQe of char .1.
Nnion &ag2
int a4
flaot b4
char c4
74
a)( b)9 c)1 !) 3
an" : b.)
(8) What i" the otpt of the following program* (. ha" been "e! to in!icate a "pace)
main()
2
char "LM.-Hello1.worl!-4
printf(/1>.18"-1")4
7
a)Hello1.Worl!...
b)....Hello1.Wor
c)Hello1.Wor.... (thi" option i" correct for
/"-1>.18")
!) ?one of the abo)e
An": b.) total 1> "pace" an! print onl' 18 character".