Вы находитесь на странице: 1из 59

Download all Placement papers/Technical questions in

www.technicalsymposium.com
Predict the output or error(s) for the following:
1. struct aaa{
struct aaa *prev;
int i; - 1 -
struct aaa *next;
;
main!"
{
struct aaa a#c$de%$&hi$'(l;
int x)1**;
a#c.i)*;a#c.prev)+'(l;
a#c.next)+de%;
de%.i)1;de%.prev)+a#c;de%.next)+&hi;
&hi.i),;&hi.prev)+de%;
&hi.next)+'(l;
'(l.i)-;'(l.prev)+&hi;'(l.next)+a#c;
x)a#c.next-.next-.prev-.next-.i;
print%!/0d/$x";
}
Answer:
2
Explanation:
above all statements form a double circular lined list!
abc"next#$next#$prev#$next#$i
this one points to %ghi% node the value of at particular node is 2"
,. struct point
{
int x;
int y;
;
struct point ori&in$*pp;
main!"
{
pp)+ori∈
print%!/ori&in is!0d0d"1n/$!*pp".x$!*pp".y";
print%!/ori&in is !0d0d"1n/$pp-.x$pp-.y";


Answer:
origin is(&'&)
origin is(&'&)
Explanation:
(
Download all Placement papers/Technical questions in
www.technicalsymposium.com
pp is a pointer to structure" we can access the elements of the structure either with arrow
mar or with indirection operator"
)ote:
*ince structure point is globall+ declared x , + are initiali-ed as -eroes
-. main!"
{
int i)2l2a#c!1*";
print%!/0d1n/$--i";
}
int 2l2a#c!int i"
{
return!i33";
}
Answer:
.
Explanation:
return(i//) it will first return i and then increments" i"e" (& will be returned"
4. main!"
{
char *p;
int *q;
lon& *r;
p)q)r)*;
p33;
q33;
r33;
print%!/0p...0p...0p/$p$q$r";
}
Answer:
&&&("""&&&2"""&&&0
Explanation:
// operator when applied to pointers increments address according to their
corresponding data#t+pes"
5. main!"
{
char c)6 6$x$convert!7";
&etc!c";
i%!!c.)6a6" ++ !c8)676""
x)convert!c";
2
Download all Placement papers/Technical questions in
www.technicalsymposium.com
print%!/0c/$x";
}
convert!7"
{
return 7--,;
}
Answer:
1ompiler error
Explanation:
declaration of convert and format of getc() are wrong"
9. main!int ar&c$ char **ar&v"
{
print%!/enter the character/";
&etchar!";
sum!ar&v:1;$ar&v:,;";
}
sum!num1$num,"
int num1$num,;
{
return num13num,;
}
Answer:
1ompiler error"
Explanation:
argv2(3 , argv223 are strings" 4he+ are passed to the function sum without converting it
to integer values"
<. = include
int one2d:;){1$,$-;
main!"
{
int *ptr;
ptr)one2d;
ptr3)-;
print%!/0d/$*ptr";
}
Answer:
garbage value
5
Download all Placement papers/Technical questions in
www.technicalsymposium.com
Explanation:
ptr pointer is pointing to out of the arra+ range of one6d"
Predict the output or error(s) for the following:
>. = include
aaa!" {
print%!/hi/";

###!"{
print%!/hello/";

ccc!"{
print%!/TechPreparation.com/";

main!"
{
int !*ptr:-;"!";
ptr:*;)aaa;
ptr:1;)###;
ptr:,;)ccc;
ptr:,;!";
}
Answer:
4echPreparation"com
Explanation:
ptr is arra+ of pointers to functions of return t+pe int"ptr2&3 is assigned to address of the
function aaa" *imilarl+ ptr2(3 and ptr223 for bbb and ccc respectivel+" ptr223() is in effect
of writing ccc()' since ptr223 points to ccc"
?. =include
main!"
{
@ABC *ptr;
char i;
ptr)%open!/777.c/$/r/";
while!!i)%&etch!ptr""D)CE@"
print%!/0c/$i";
}
Answer:
0
Download all Placement papers/Technical questions in
www.technicalsymposium.com
contents of ---"c followed b+ an infinite loop
Explanation:
4he condition is checed against E78' it should be checed against )9::"
1*. main!"
{
int i )*;')*;
i%!i ++ '33"
print%!/0d..0d/$i33$'";
print%!/0d..0d$i$'";
}
Answer:
&""&
Explanation:
4he value of i is &" *ince this information is enough to determine the truth value of the
boolean expression" *o the statement following the if statement is not executed" 4he
values of i and ; remain unchanged and get printed"
11. main!"
{
int i;
i ) a#c!";
print%!/0d/$i";
}
a#c!"
{
2FG ) 1***;
}
Answer:
(&&&
Explanation:
)ormall+ the return value from the function is through the information from the
accumulator" <ere 6A< is the pseudo global variable denoting the accumulator" <ence'
the value of the accumulator is set (&&& so the function returns value (&&&"
1,. int i;
main!"{
int t;
%or ! t)4;scan%!/0d/$+i"-t;print%!/0d1n/$i""
print%!/0d--/$t--";

=
Download all Placement papers/Technical questions in
www.technicalsymposium.com
// A% the inputs are *$1$,$- %ind the o/p
Answer:
0##&
5##(
2##2
Explanation:
:et us assume some x> scanf(%?d%',i)#t the values during execution
will be'
t i x
0 & #0
5 ( #2
2 2 &
1-. main!"{
int a) *;int # ) ,*;char x )1;char y )1*;
i%!a$#$x$y"
print%!/hello/";

Answer:
hello
Explanation:
4he comma operator has associativit+ from left to right" 7nl+ the rightmost value is
returned and the other values are evaluated and ignored" 4hus the value of last variable +
is returned to chec in if" *ince it is a non -ero value if becomes true so' %hello% will be
printed"
14. main!"{
unsi&ned int i;
%or!i)1;i.-,;i--"
print%!/c aptitude/";
}
Explanation:
i is an unsigned integer" @t is compared with a signed value" *ince the both t+pes doesnAt
match' signed is promoted to unsigned value" 4he unsigned eBuivalent of #2 is a huge
value so condition becomes false and control comes out of the loop"
15. An the %ollowin& p&m add a stmt in the %unction %un such that the address o%
6a6 &ets stored in 6'6.
main!"{
int * ';
void %un!int **";
%un!+'";
C
Download all Placement papers/Technical questions in
www.technicalsymposium.com

void %un!int **(" {
int a )*;
/* add a stmt here*/

Answer:
D > ,a
Explanation:
4he argument of the function is a pointer to a pointer"
19. Hhat are the %ollowin& notations o% de%inin& %unctions (nown asI
i. int a#c!int a$%loat #"
{
/* some code */

ii. int a#c!a$#"
int a; %loat #;
{
/* some code*/

Answer:
i" A)*@ 1 notation
ii" Eernighan , Fitche notation
Predict the output or error(s) for the following:
19. main!"
{
char *p;
p)/0d1n/;
p33;
p33;
print%!p-,$-**";
}
Answer:
5&&
Explanation:
4he pointer points to ? since it is incremented twice and again decremented b+ 2' it
points to A?dGnA and 5&& is printed"
H
Download all Placement papers/Technical questions in
www.technicalsymposium.com
1<. main!"{
char a:1**;;
a:*;)6a6;a:1;;)6#6;a:,;)6c6;a:4;)6d6;
a#c!a";
}
a#c!char a:;"{
a33;
print%!/0c/$*a";
a33;
print%!/0c/$*a";
}
Explanation:
4he base address is modified onl+ in function and as a result a points to AbA then after
incrementing to AcA so bc will be printed"
1>. %unc!a$#"
int a$#;
{
return! a) !a))#" ";
}
main!"
{
int process!"$%unc!";
print%!/The value o% process is 0d D1n /$process!%unc$-$9"";
}
process!p%$val1$val,"
int !*p%" !";
int val1$val,;
{
return!!*p%" !val1$val,"";

Answer:
4he value if process is & I
Explanation:
4he function AprocessA has 5 parameters # (' a pointer to another function 2 and 5'
integers" Jhen this function is invoed from main' the following substitutions for formal
parameters tae place: func for pf' 5 for val( and C for val2" 4his function returns the
result of the operation performed b+ the function AfuncA" 4he function func has two integer
parameters" 4he formal parameters are substituted as 5 for a and C for b" since 5 is not
eBual to C' a>>b returns &" therefore the function returns & which in turn is returned b+
the function AprocessA"
K
Download all Placement papers/Technical questions in
www.technicalsymposium.com
1?. void main!"
{
static int i)5;
i%!--i"{
main!";
print%!/0d /$i";

}
Answer:
& & & &
Explanation:
4he variable %@% is declared as static' hence memor+ for @ will be allocated for
onl+ once' as it encounters the statement" 4he function main() will be called recursivel+
unless @ becomes eBual to &' and since main() is recursivel+ called' so the value of static @
ie"' & will be printed ever+ time the control is returned"
,*. void main!"
{
int ()ret!si7eo%!%loat"";
print%!/1n here value is 0d/$33(";
}
int ret!int ret"
{
ret 3) ,.5;
return!ret";
}
Answer:
<ere value is H
Explanation:
4he int ret(int ret)' ie"' the function name and the argument name can be the same"
8irstl+' the function ret() is called in which the si-eof(float) ie"' 0 is passed' after
the first expression the value in ret will be C' as ret is integer hence the value stored in ret
will have implicit t+pe conversion from float to int" 4he ret is returned in main() it is
printed after and preincrement"
,1. void main!"
{
char a:;)/1,-451*/;
int i)strlen!a";
print%!/here in - 0d1n/$33i";
}
.
Download all Placement papers/Technical questions in
www.technicalsymposium.com
Answer:
here in 5 C
Explanation:
4he char arra+ AaA will hold the initiali-ed string' whose length will be counted from & till
the null character" <ence the A@A will hold the value eBual to =' after the pre#increment in
the printf statement' the C will be printed"
,,. void main!"
{
unsi&ned &iveit)-1;
int &otit;
print%!/0u /$33&iveit";
print%!/0u 1n/$&otit)--&iveit";
}
Answer:
& C==5=
,-. void main!"
{
int i;
char a:;)/1*/;
i%!print%!/0s1n/$a""
print%!/E( here 1n/";
else
print%!/@or&et it1n/";
}
Answer:
7 here
Explanation:
Printf will return how man+ characters does it print" <ence printing a null character
returns ( which maes the if statement true' thus %7 here% is printed"
Predict the output or error(s) for the following:
,4. void main!"
{
void *v;
int inte&er),;
int *i)+inte&er;
v)i;
(&
Download all Placement papers/Technical questions in
www.technicalsymposium.com
print%!/0d/$!int*"*v";
}
Answer:
1ompiler Error" Je cannot appl+ indirection on t+pe voidD"
Explanation:
Loid pointer is a generic pointer t+pe" )o pointer arithmetic can be done on it" Loid
pointers are normall+ used for'
(" Passing generic pointers to functions and returning such pointers"
2" As a intermediate pointer t+pe"
5" 9sed when the exact pointer t+pe will be nown at a later point of time"
,5. void main!"
{
int i)i33$')'33$()(33;
print%!J0d0d0dK$i$'$(";
}
Answer:
Marbage values"
Explanation:
An identifier is available to use in program code from the point of its declaration"
*o expressions such as i > i// are valid statements" 4he i' ; and are automatic variables
and so the+ contain some garbage value" Marbage in is garbage out (M@M7)"
,9. void main!"
{
static int i)i33$ ')'33$ ()(33;
print%!Ji ) 0d ' ) 0d ( ) 0dK$ i$ '$ (";
}
Answer:
i > ( ; > ( > (
Explanation:
*ince static variables are initiali-ed to -ero b+ default"
,<. void main!"
{
while!1"{
i%!print%!/0d/$print%!/0d/"""
#rea(;
else
continue;
((
Download all Placement papers/Technical questions in
www.technicalsymposium.com

}
Answer:
Marbage values
Explanation:
4he inner printf executes first to print some garbage value" 4he printf returns no of
characters printed and this value also cannot be predicted" *till the outer printf prints
something and so returns a non#-ero value" *o it encounters the brea statement and
comes out of the while statement"
,>. main!"
{
unsi&ned int i)1*;
while!i--.)*"
print%!/0u /$i";

}
Answer:
(& . K H C = 0 5 2 ( & C==5= C==50N""
Explanation:
*ince i is an unsigned integer it can never become negative" *o the expression i## $>&
will alwa+s be true' leading to an infinite loop"
,?. =include
main!"
{
int x$y),$7$a;
i%!x)y0," 7),;
a),;
print%!/0d 0d /$7$x";
}
Answer:
Marbage#value &
Explanation:
4he value of +?2 is &" 4his value is assigned to x" 4he condition reduces to if (x) or in
other words if(&) and so - goes uninitiali-ed"
4humb Fule: 1hec all control paths to write bug free code"
-*. main!"
{
(2
Download all Placement papers/Technical questions in
www.technicalsymposium.com
int a:1*;;
print%!/0d/$*a31-*a3-";
}
Answer:
0
Explanation:
Da and #Da cancels out" 4he result is as simple as ( / 5 > 0 I
-1. =de%ine prod!a$#" a*#
main!"
{
int x)-$y)4;
print%!/0d/$prod!x3,$y-1"";
}
Answer:
(&
Explanation:
4he macro expands and evaluates to as:
x/2D+#( >$ x/(2D+)#( >$ (&
-,. main!"
{
unsi&ned int i)95***;
while!i33D)*";
print%!/0d/$i";
}
Answer:
(
Explanation:
)ote the semicolon after the while statement" Jhen the value of i becomes & it comes out
of while loop" Oue to post#increment on i the value of i while printing is ("
L Fptitude Muestions and Fnswers
(5
Download all Placement papers/Technical questions in
www.technicalsymposium.com
Predict the output or error(s) for the following:
--. main!"
{
int i)*;
while!3!3i--"D)*"
i-)i33;
print%!/0d/$i";
}
Answer:
#(
Explanation:
9nar+ / is the onl+ dumm+ operator in 1" *o it has no effect on the expression and now
the while loop is' while(i##I>&) which is false and so breas out of while loop" 4he
value P( is printed due to the post#decrement operator"
-4. main!"
{
%loat %)5$&)1*;
enum{i)1*$'),*$()5*;
print%!/0d1n/$33(";
print%!/0%1n/$%88,";
print%!/0l%1n/$%0&";
print%!/0l%1n/$%mod!%$&"";
}
Answer:
:ine no =: Error: :value reBuired
:ine no C: 1annot appl+ leftshift to float
:ine no H: 1annot appl+ mod to float
Explanation:
Enumeration constants cannot be modified' so +ou cannot appl+ //"
Qit#wise operators and ? operators cannot be applied on float values"
fmod() is to find the modulus values for floats as ? operator is for ints"
-5. main!"
{
int i)1*;
void pascal %!int$int$int";
%!i33$i33$i33";
print%!/ 0d/$i";
}
void pascal %!inte&er Ni$inte&erN'$inte&er N("
{
(0
Download all Placement papers/Technical questions in
www.technicalsymposium.com
write!i$'$(";
}
Answer:
1ompiler error: unnown t+pe integer
1ompiler error: undeclared function write
Explanation:
Pascal e+word doesnRt mean that pascal code can be used" @t means that the function
follows Pascal argument passing mechanism in calling the functions"
-9. void pascal %!int i$int '$int ("
{
print%!J0d 0d 0dK$i$ '$ (";
}
void cdecl %!int i$int '$int ("
{
print%!J0d 0d 0dK$i$ '$ (";
}
main!"
{
int i)1*;
%!i33$i33$i33";
print%!/ 0d1n/$i";
i)1*;
%!i33$i33$i33";
print%!/ 0d/$i";
}
Answer:
(& (( (2 (5
(2 (( (& (5
Explanation:
Pascal argument passing mechanism forces the arguments to be called from left to right"
cdecl is the normal 1 argument passing mechanism where the arguments are passed from
right to left"
-<. Hhat is the output o% the pro&ram &iven #elow

main!"
{
si&ned char i)*;
%or!;i.)*;i33" ;
print%!/0d1n/$i";

(=
Download all Placement papers/Technical questions in
www.technicalsymposium.com
Answer
#(2K
Explanation
)otice the semicolon at the end of the for loop" 4<e initial value of the i is set to &" 4he
inner loop executes to increment the value from & to (2H (the positive range of char) and
then it rotates to the negative value of #(2K" 4he condition in the for loop fails and so
comes out of the for loop" @t prints the current value of i that is #(2K"
->. main!"
{
unsi&ned char i)*;
%or!;i.)*;i33" ;
print%!/0d1n/$i";

Answer
infinite loop
Explanation
4he difference between the previous Buestion and this one is that the char is declared to
be unsigned" *o the i// can never +ield negative value and i$>& never becomes false so
that it can come out of the for loop"
-?. main!"
{
char i)*;
%or!;i.)*;i33" ;
print%!/0d1n/$i";


Answer:
Qehavior is implementation dependent"
Explanation:
4he detail if the char is signedSunsigned b+ default is implementation dependent" @f the
implementation treats the char to be signed b+ default the program will print P(2K and
terminate" 7n the other hand if it considers char to be unsigned b+ default' it goes to
infinite loop"
Fule:
Tou can write programs that have implementation dependent behavior" Qut dont write
programs that depend on such behavior"
(C
Download all Placement papers/Technical questions in
www.technicalsymposium.com
4*. As the %ollowin& statement a declaration/de%inition. @ind what does it meanI
int !*x":1*;;
Answer
Oefinition"
x is a pointer to arra+ of(si-e (&) integers"

Appl+ cloc#wise rule to find the meaning of this definition"
41. Hhat is the output %or the pro&ram &iven #elow

typede% enum errorType{warnin&$ error$ exception$error;
main!"
{
error &1;
&1)1;
print%!/0d/$&1";

Answer
1ompiler error: Uultiple declaration for error
Explanation
4he name error is used in the two meanings" 7ne means that it is a enumerator constant
with value (" 4he another use is that it is a t+pe name (due to t+pedef) for enum
error4+pe" Miven a situation the compiler cannot distinguish the meaning of error to
now in what sense the error is used:
error g(!
g(>error!
SS which error it refers in each caseV
Jhen the compiler can distinguish between usages then it will not issue error (in pure
technical terms' names can onl+ be overloaded in different namespaces)"
)ote: the extra comma in the declaration'
enum error4+pe{warning' error' exception'}
is not an error" An extra comma is valid and is provided ;ust for programmerRs
convenience"
4,. typede% struct error{int warnin&$ error$ exception;error;
main!"
{
error &1;
&1.error )1;
print%!/0d/$&1.error";


Answer
(H
Download all Placement papers/Technical questions in
www.technicalsymposium.com
(
Explanation
4he three usages of name errors can be distinguishable b+ the compiler at an+ instance'
so valid (the+ are in different namespaces)"
4+pedef struct error{int warning' error' exception!}error!
4his error can be used onl+ b+ preceding the error b+ struct a+word as in:
struct error someError!
t+pedef struct error{int warning' error' exception!}error!
4his can be used onl+ after " (dot) or #$ (arrow) operator preceded b+ the variable
name as in :
g("error >(!
printf(%?d%'g("error)!
t+pedef struct error{int warning' error' exception!}error!
4his can be used to define variables without using the preceding struct e+word as in:
error g(!
*ince the compiler can perfectl+ distinguish between these three usages' it is perfectl+
legal and valid"

)ote
4his code is given here to ;ust explain the concept behind" @n real programming donRt use
such overloading of names" @t reduces the readabilit+ of the code" Possible doesnRt mean
that we should use itI
Predict the output or error(s) for the following:
4-. =i%de% somethin&
int some)*;
=endi%

main!"
{
int thin& ) *;
print%!/0d 0d1n/$ some $thin&";
}

Answer:
1ompiler error : undefined s+mbol some
Explanation:
4his is a ver+ simple example for conditional compilation" 4he name something is not
alread+ nown to the compiler maing the declaration
int some > &!
effectivel+ removed from the source code"
(K
Download all Placement papers/Technical questions in
www.technicalsymposium.com
44. =i% somethin& )) *
int some)*;
=endi%

main!"
{
int thin& ) *;
print%!/0d 0d1n/$ some $thin&";
}

Answer
& &
Explanation
4his code is to show that preprocessor expressions are not the same as the ordinar+
expressions" @f a name is not nown the preprocessor treats it to be eBual to -ero"
45. Hhat is the output %or the %ollowin& pro&ram

main!"
{
int arr,D:-;:-;;
print%!/0d1n/$ !!arr,D))* arr,D"++!* arr,D )) arr,D:*;"" ";

Answer
(
49. void main!"
{
i%!O* )) !unsi&ned int"-1"
print%!JPou can answer this i% you (now how values are represented in memoryK";

Answer
Tou can answer this if +ou now how values are represented in memor+
Explanation
W (tilde operator or bit#wise negation operator) operates on & to produce all ones to fill the
space for an integer" P( is represented in unsigned value as all (Rs and so both are eBual"
4<. int swap!int *a$int *#"
{
*a)*a3*#;*#)*a-*#;*a)*a-*#;
}
main!"
{
(.
Download all Placement papers/Technical questions in
www.technicalsymposium.com
int x)1*$y),*;
swap!+x$+y";
print%!/x) 0d y ) 0d1n/$x$y";
}
Answer
x > 2& + > (&
Explanation
4his is one wa+ of swapping two values" *imple checing will help understand this"
4>. main!"
{
char *p ) JayqmK;
print%!J0cK$33*!p33"";
}
Answer:
b
4?. main!"
{
int i)5;
print%!/0d/$33i33";

Answer:
1ompiler error: :value reBuired in function main
Explanation:
//i +ields an rvalue" 8or postfix // to operate an lvalue is reBuired"
5*. main!"
{
char *p ) JayqmK;
char c;
c ) 33*p33;
print%!J0cK$c";
}
Answer:
b
Explanation:
4here is no difference between the expression //D(p//) and //Dp//" Parenthesis ;ust
wors as a visual clue for the reader to see which expression is first evaluated"
2&
Download all Placement papers/Technical questions in
www.technicalsymposium.com
51.
int aaa!" {print%!JQiK";
int ###!"{print%!JhelloK";
iny ccc!"{print%!J#yeK";

main!"
{
int ! * ptr:-;" !";
ptr:*; ) aaa;
ptr:1; ) ###;
ptr:,; )ccc;
ptr:,;!";
}
Answer:
b+e
Explanation:
int (D ptr253)() sa+s that ptr is an arra+ of pointers to functions that taes no arguments
and returns the t+pe int" Q+ the assignment ptr2&3 > aaa! it means that the first function
pointer in the arra+ is initiali-ed with the address of the function aaa" *imilarl+' the other
two arra+ elements also get initiali-ed with the addresses of
the functions bbb and ccc" *ince ptr223 contains the address of the function ccc' the call to
the function ptr223() is same as calling ccc()" *o it results in printing %b+e%"
5,.
main!"
{
int i)5;
print%!J0dK$i)33i ))9";
}

Answer:
(
Explanation:
4he expression can be treated as i > (//i>>C)' because >> is of higher precedence than >
operator" @n the inner expression' //i is eBual to C +ielding true(()" <ence the result"
Predict the output or error(s) for the following:
5-. main!"
{
char p: ;)/0d1n/;
2(
Download all Placement papers/Technical questions in
www.technicalsymposium.com
p:1; ) 6c6;
print%!p$95";
}
Answer:
A
Explanation:
Oue to the assignment p2(3 > XcR the string becomes' Y?cGnZ" *ince this string becomes
the format string for printf and A*1@@ value of C= is XAR' the same gets printed"
54. void ! * a#c! int$ void ! *de%" !" " " !";

Answer::
abc is a ptr to a function which taes 2 parameters "(a)" an integer variable"(b)" a
ptrto a funtion which returns void" the return t+pe of the function is void"
Explanation:
Appl+ the cloc#wise rule to find the result"
55. main!"
{
while !strcmp!JsomeK$Ksome1*K""
print%!JRtrin&s are not equal1nK";

Answer:
)o output
Explanation:
Ending the string constant with G& explicitl+ maes no difference" *o YsomeZ and
YsomeG&Z are eBuivalent" *o' strcmp returns & (false) hence breaing out of the while
loop"
59. main!"
{
char str1:; ) {SsT$ToT$TmT$TeT;
char str,:; ) {SsT$ToT$TmT$TeT$T1*T;
while !strcmp!str1$str,""
print%!JRtrin&s are not equal1nK";
}
Answer:
Y*trings are not eBualZ
Y*trings are not eBualZ
N"
22
Download all Placement papers/Technical questions in
www.technicalsymposium.com
Explanation:
@f a string constant is initiali-ed explicitl+ with characters' XG&R is not appended
automaticall+ to the string" *ince str( doesnRt have null termination' it treats whatever the
values that are in the following positions as part of the string until it randoml+ reaches a
XG&R" *o str( and str2 are not the same' hence the result"
5<. main!"
{
int i ) -;
%or !;i33)*;" print%!J0dK$i";
}

Answer:
1ompiler Error: :value reBuired"
Explanation:
As we now that increment operators return rvalues and hence it cannot appear on the
left hand side of an assignment operation"
5>. void main!"
{
int *mptr$ *cptr;
mptr ) !int*"malloc!si7eo%!int"";
print%!J0dK$*mptr";
int *cptr ) !int*"calloc!si7eo%!int"$1";
print%!J0dK$*cptr";
}
Answer:
garbage#value &
Explanation:
4he memor+ space allocated b+ malloc is uninitiali-ed' whereas calloc returns the
allocated memor+ space initiali-ed to -eros"
5?. void main!"
{
static int i;
while!i8)1*"
!i.,"Ii33Ni--;
print%!J0dK$ i";
}
Answer:
52HCH
25
Download all Placement papers/Technical questions in
www.technicalsymposium.com
Explanation:
*ince i is static it is initiali-ed to &" @nside the while loop the conditional operator
evaluates to false' executing i##" 4his continues till the integer value rotates to positive
value (52HCH)" 4he while condition becomes false and hence' comes out of the while
loop' printing the i value"
9*. main!"
{
int i)1*$'),*;
' ) i$ 'I!i$'"IiN'N';
print%!/0d 0d/$i$'";
}

Answer:
(& (&
Explanation:
4he 4ernar+ operator ( V : ) is eBuivalent for if#then#else statement" *o the
Buestion can be written as:
if(i';)
{
if(i';)
; > i!
else
; > ;!
}
else
; > ;!
91. 1. const char *a;
,. char* const a;
-. char const *a;
-Di%%erentiate the a#ove declarations.

Answer:
(" AconstA applies to char D rather than AaA ( pointer to a constant char )
Da>A8A : illegal
a>%<i% : legal

2" AconstA applies to AaA rather than to the value of a (constant pointer to char )
Da>A8A : legal
a>%<i% : illegal

5" *ame as ("
20
Download all Placement papers/Technical questions in
www.technicalsymposium.com
9,. main!"
{
int i)5$')1*;
i)i+)'++1*;
print%!/0d 0d/$i$'";
}

Answer:
( (&
Explanation:
4he expression can be written as i>(i,>(;,,(&))! 4he inner expression (;,,(&)
evaluates to ( because ;>>(&" i is =" i > =,( is (" <ence the result"
Predict the output or error(s) for the following:
9-. main!"
{
int i)4$')<;
' ) ' UU i33 ++ print%!/PEV LFW/";
print%!/0d 0d/$ i$ '";
}

Answer:
0 (
Explanation:
4he boolean expression needs to be evaluated onl+ till the truth value of the expression is
not nown" ; is not eBual to -ero itself means that the expressionRs truth value is ("
Qecause it is followed b+ [[ and true [[ (an+thing) >$ true where (an+thing) will not be
evaluated" *o the remaining expression is not evaluated and so the value of i remains the
same"
*imilarl+ when ,, operator is involved in an expression' when an+ of the operands
become false' the whole expressionRs truth value becomes false and hence the remaining
expression will not be evaluated"
false ,, (an+thing) >$ false where (an+thing) will not be evaluated"
94. main!"
{
re&ister int a),;
print%!/Fddress o% a ) 0d/$+a";
print%!/Xalue o% a ) 0d/$a";
}
Answer:
2=
Download all Placement papers/Technical questions in
www.technicalsymposium.com
1ompier Error: A,A on register variable
Fule to Femember:
, (address of ) operator cannot be applied on register variables"
95. main!"
{
%loat i)1.5;
switch!i"
{
case 1N print%!/1/";
case ,N print%!/,/";
de%ault N print%!/*/";

}
Answer:
1ompiler Error: switch expression not integral
Explanation:
*witch statements can be applied onl+ to integral t+pes"
99. main!"
{
extern i;
print%!/0d1n/$i";
{
int i),*;
print%!/0d1n/$i";

}
Answer:
:iner Error : 9nresolved external s+mbol i
Explanation:
4he identifier i is available in the inner bloc and so using extern has no use in resolving
it"
9<. main!"
{
int a),$*%1$*%,;
%1)%,)+a;
*%,3)*%,3)a3),.5;
print%!/1n0d 0d 0d/$a$*%1$*%,";
}
2C
Download all Placement papers/Technical questions in
www.technicalsymposium.com
Answer:
(C (C (C
Explanation:
f( and f2 both refer to the same memor+ location a" *o changes through f( and f2
ultimatel+ affects onl+ the value of a"
9>. main!"
{
char *p)/YEED/;
char a: ;)/YEED/;
print%!/1n si7eo%!p" ) 0d$ si7eo%!*p" ) 0d$ strlen!p" ) 0d/$ si7eo%!p"$ si7eo%!*p"$
strlen!p"";
print%!/1n si7eo%!a" ) 0d$ strlen!a" ) 0d/$ si7eo%!a"$ strlen!a"";
}
Answer:
si-eof(p) > 2' si-eof(Dp) > (' strlen(p) > 0
si-eof(a) > =' strlen(a) > 0
Explanation:
si-eof(p) >$ si-eof(charD) >$ 2
si-eof(Dp) >$ si-eof(char) >$ (
*imilarl+'
si-eof(a) >$ si-e of the character arra+ >$ =
Jhen si-eof operator is applied to an arra+ it returns the si-eof the arra+ and it is not the
same as the si-eof the pointer variable" <ere the si-eof(a) where a is the character arra+
and the si-e of the arra+ is = because the space necessar+ for the terminating )9::
character should also be taen into account"
9?. =de%ine DAZ! array$ type" si7eo%!array"/si7eo%!type"
main!"
{
int arr:1*;;
print%!JThe dimension o% the array is 0dK$ DAZ!arr$ int"";
}
Answer:
(&
Explanation:
4he si-e of integer arra+ of (& elements is (& D si-eof(int)" 4he macro expands to
si-eof(arr)Ssi-eof(int) >$ (& D si-eof(int) S si-eof(int) >$ (&"
<*. int DAZ!int array:;"
{
2H
Download all Placement papers/Technical questions in
www.technicalsymposium.com
return si7eo%!array"/si7eo%!int ";
}
main!"
{
int arr:1*;;
print%!JThe dimension o% the array is 0dK$ DAZ!arr"";
}
Answer:
(
Explanation:
Arra+s cannot be passed to functions as arguments and onl+ the pointers can be passed"
*o the argument is eBuivalent to int D arra+ (this is one of the ver+ few places where 23
and D usage are eBuivalent)" 4he return statement becomes' si-eof(int D)S si-eof(int) that
happens to be eBual in this case"
<1. main!"
{
static int a:-;:-;){1$,$-$4$5$9$<$>$?;
int i$';
static *p:;){a$a31$a3,;
%or!i)*;i8-;i33"
{
%or!')*;'8-;'33"

print%!/0d1t0d1t0d1t0d1n/$*!*!p3i"3'"$
*!*!'3p"3i"$*!*!i3p"3'"$*!*!p3'"3i"";

}
Answer:
( ( ( (
2 0 2 0
5 H 5 H
0 2 0 2
= = = =
C K C K
H 5 H 5
K C K C
. . . .
Explanation:
D(D(p/i)/;) is eBuivalent to p2i32;3"
2K
Download all Placement papers/Technical questions in
www.technicalsymposium.com
Predict the output or error(s) for the following:
<,. main!"
{
void swap!";
int x)1*$y)>;
swap!+x$+y";
print%!/x)0d y)0d/$x$y";
}
void swap!int *a$ int *#"
{
*a [) *#$ *# [) *a$ *a [) *#;

Answer:
x>(& +>K
Explanation:
9sing \ lie this is a wa+ to swap two variables without using a temporar+ variable and
that too in a single statement"
@nside main()' void swap()! means that swap is a function that ma+ tae an+ number of
arguments (not no arguments) and returns nothing" *o this doesnRt issue a compiler error
b+ the call swap(,x',+)! that has two arguments"
4his convention is historicall+ due to pre#A)*@ st+le (referred to as Eernighan and
Fitchie st+le) st+le of function declaration" @n that st+le' the swap function will be defined
as follows'
void swap()
int Da' int Db
{
Da \> Db' Db \> Da' Da \> Db!
}
where the arguments follow the ()" *o naturall+ the declaration for swap will loo lie'
void swap() which means the swap can tae an+ number of arguments"
<-. main!"
{
int i ) ,5<;
int *iPtr ) +i;
print%!/0d 0d/$ *!!char*"iPtr"$ *!!char*"iPtr31" ";
}
Answer:
( (
Explanation:
2.
Download all Placement papers/Technical questions in
www.technicalsymposium.com
4he integer value 2=H is stored in the memor+ as' &&&&&&&( &&&&&&&(' so the individual
b+tes are taen b+ casting it to char D and get printed"
<4. main!"
{
int i ) ,5>;
int *iPtr ) +i;
print%!/0d 0d/$ *!!char*"iPtr"$ *!!char*"iPtr31" ";


Answer:
2 (
Explanation:
4he integer value 2=H can be represented in binar+ as' &&&&&&&( &&&&&&&(" Femember
that the @)4E: machines are Xsmall#endianR machines" *mall#endian means that the lower
order b+tes are stored in the higher memor+ addresses and the higher order b+tes are
stored in lower addresses" 4he integer value 2=K is stored in memor+ as: &&&&&&&(
&&&&&&(&"
<5. main!"
{
int i)-**;
char *ptr ) +i;
*33ptr),;
print%!/0d/$i";
}
Answer:
==C
Explanation:
4he integer value 5&& in binar+ notation is: &&&&&&&( &&(&((&&" @t is stored in memor+
(small#endian) as: &&(&((&& &&&&&&&(" Fesult of the expression D//ptr > 2 maes the
memor+ representation as: &&(&((&& &&&&&&(&" *o the integer corresponding to it is
&&&&&&(& &&(&((&& >$ ==C"
<9. =include
main!"
{
char * str ) /hello/;
char * ptr ) str;
char least ) 1,<;
while !*ptr33"
least ) !*ptr
print%!/0d/$least";
5&
Download all Placement papers/Technical questions in
www.technicalsymposium.com
}
Answer:
&
Explanation:
After XptrR reaches the end of the string the value pointed b+ XstrR is XG&R" *o the value of
XstrR is less than that of XleastR" *o the value of XleastR finall+ is &"
<<. Declare an array o% W pointers to %unctions returnin& pointers to %unctions
returnin& pointers to charactersI
Answer:
(charD(D)( )) (Dptr2)3)( )!
<>. main!"
{
struct student
{
char name:-*;;
struct date do#;
stud;
struct date
{
int day$month$year;
;
scan%!/0s0d0d0d/$ stud.rollno$ +student.do#.day$ +student.do#.month$
+student.do#.year";
}
Answer:
1ompiler Error: 9ndefined structure date
Explanation:
@nside the struct definition of XstudentR the member of t+pe struct date is given" 4he
compiler doesnRt have the definition of date structure (forward reference is not allowed
in 1 in this case) so it issues an error"
<?. main!"
{
struct date;
struct student
{
char name:-*;;
struct date do#;
stud;
struct date
5(
Download all Placement papers/Technical questions in
www.technicalsymposium.com
{
int day$month$year;
;
scan%!/0s0d0d0d/$ stud.rollno$ +student.do#.day$ +student.do#.month$
+student.do#.year";
}
Answer:
1ompiler Error: 9ndefined structure date
Explanation:
7nl+ declaration of struct date is available inside the structure definition of XstudentR but
to have a variable of t+pe struct date the definition of the structure is reBuired"
>*. There were 1* records stored in Jsome%ile.datK #ut the %ollowin& pro&ram
printed 11 names. Hhat went wron&I
void main!"
{
struct student
{
char name:-*;$ rollno:9;;
stud;
@ABC *%p ) %open!Jsome%ile.datK$KrK";
while!D%eo%!%p""
{
%read!+stud$ si7eo%!stud"$ 1 $ %p";
puts!stud.name";
}
}
Explanation:
fread reads (& records and prints the names successfull+" @t will return E78 onl+ when
fread tries to read another record and fails reading E78 (and returning E78)" *o it prints
the last record again" After this onl+ the condition feof(fp) becomes false' hence comes
out of the while loop"
Predict the output or error(s) for the following:
>1. As there any di%%erence #etween the two declarations$
1. int %oo!int *arr:;" and
,. int %oo!int *arr:,;"
Answer:
)o
52
Download all Placement papers/Technical questions in
www.technicalsymposium.com
Explanation:
8unctions can onl+ pass pointers and not arra+s" 4he numbers that are allowed inside the
23 is ;ust for more readabilit+" *o there is no difference between the two declarations"
>,. Hhat is the su#tle error in the %ollowin& code se&mentI
void %un!int n$ int arr:;"
{
int *p)*;
int i)*;
while!i33
p ) +arr:i;;
*p ) *;
}
Answer , Explanation:
@f the bod+ of the loop never executes p is assigned no address" *o p remains )9::
where Dp >& ma+ result in problem (ma+ rise to runtime error Y)9:: pointer
assignmentZ and terminate the program)"
>-. Hhat is wron& with the %ollowin& codeI
int *%oo!"
{
int *s ) malloc!si7eo%!int"1**";
assert!s D) WVBB";
return s;
}
Answer , Explanation:
assert macro should be used for debugging and finding out bugs" 4he chec s I> )9:: is
for errorSexception handling and for that assert shouldnRt be used" A plain if and the
corresponding remed+ statement has to be given"
>4. Hhat is the hidden #u& with the %ollowin& statementI
assert!val33 D) *";
Answer , Explanation:
Assert macro is used for debugging and removed in release version" @n assert' the
experssion involves side#effects" *o the behavior of the code becomes different in case of
debug version and the release version thus leading to a subtle bug"
Fule to Femember:
OonRt use expressions that have side#effects in assert statements"
>5. void main!"
{
55
Download all Placement papers/Technical questions in
www.technicalsymposium.com
int *i ) *x4**; // i points to the address 4**
*i ) *; // set the value o% memory location pointed #y i;
}
Answer:
9ndefined behavior
Explanation:
4he second statement results in undefined behavior because it points to some location
whose value ma+ not be available for modification" 4his t+pe of pointer in which the
non#availabilit+ of the implementation of the referenced location is nown as Aincomplete
t+peA"
>9. =de%ine assert!cond" i%!D!cond"" 1
!%print%!stderr$ /assertion %ailedN 0s$ %ile 0s$ line 0d 1n/$=cond$1
22@ABC22$22BAWC22"$ a#ort!""

void main!"
{
int i ) 1*;
i%!i))*"
assert!i 8 1**";
else
print%!/This statement #ecomes else %or i% in assert macro/";
}
Answer:
)o output
Explanation:
4he else part in which the printf is there becomes the else for if in the assert macro"
<ence nothing is printed"
4he solution is to use conditional operator instead of if statement'
]define assert(cond) ((cond)V(&): (fprintf (stderr' %assertion failed: G ?s' file ?s' line
?d Gn%']cond' 668@:E66'66:@)E66)' abort()))

)ote:
<owever this problem of Ymatching with nearest elseZ cannot be solved b+ the usual
method of placing the if statement inside a bloc lie this'
]define assert(cond) { G
if(I(cond)) G
(fprintf(stderr' %assertion failed: ?s' file ?s' line ?d Gn%']cond'G
668@:E66'66:@)E66)' abort()) G
}
50
Download all Placement papers/Technical questions in
www.technicalsymposium.com
><. As the %ollowin& code le&alI
struct a
{
int x;
struct a #;

Answer:
)o
Explanation:
@s it not legal for a structure to contain a member that is of the same
t+pe as in this case" Qecause this will cause the structure declaration to be recursive
without end"
>>. As the %ollowin& code le&alI
struct a
{
int x;
struct a *#;

Answer:
Tes"
Explanation:
Db is a pointer to t+pe struct a and so is legal" 4he compiler nows' the si-e of the pointer
to a structure even before the si-e of the structure
is determined(as +ou now the pointer to an+ t+pe is of same si-e)" 4his t+pe of structures
is nown as Xself#referencingR structure"
Predict the output or error(s) for the following:
>?. As the %ollowin& code le&alI
typede% struct a
{
int x;
aType *#;
aType
Answer:
)o
Explanation:
5=
Download all Placement papers/Technical questions in
www.technicalsymposium.com
4he t+pename a4+pe is not nown at the point of declaring the structure (forward
references are not made for t+pedefs)"
?*. As the %ollowin& code le&alI
typede% struct a aType;
struct a
{
int x;
aType *#;
;
Answer:
Tes
Explanation:
4he t+pename a4+pe is nown at the point of declaring the structure' because it is alread+
t+pedefined"
?1. As the %ollowin& code le&alI
void main!"
{
typede% struct a aType;
aType someXaria#le;
struct a
{
int x;
aType *#;
;
}
Answer:
)o
Explanation:
Jhen the declaration'
t+pedef struct a a4+pe!
is encountered bod+ of struct a is not nown" 4his is nown as Xincomplete t+pesR"
?,. void main!"
{
print%!Jsi7eo% !void *" ) 0d 1nJ$ si7eo%! void *"";
print%!Jsi7eo% !int *" ) 0d 1nK$ si7eo%!int *"";
print%!Jsi7eo% !dou#le *" ) 0d 1nK$ si7eo%!dou#le *"";
print%!Jsi7eo%!struct un(nown *" ) 0d 1nK$ si7eo%!struct un(nown *"";

5C
Download all Placement papers/Technical questions in
www.technicalsymposium.com
Answer :
si-eof (void D) > 2
si-eof (int D) > 2
si-eof (double D) > 2
si-eof(struct unnown D) > 2
Explanation:
4he pointer to an+ t+pe is of same si-e"
?-. char inputRtrin&:1**; ) {*;
To &et strin& input %rom the (ey#oard which one o% the %ollowin& is #etterI
1" &ets!inputRtrin&"
," %&ets!inputRtrin&$ si7eo%!inputRtrin&"$ %p"
Answer , Explanation:
4he second one is better because gets(input*tring) doesnAt now the si-e of the string
passed and so' if a ver+ big input (here' more than (&& chars) the charactes will be written
past the input string" Jhen fgets is used with stdin performs the same operation as gets
but is safe"
?4. Hhich version do you pre%er o% the %ollowin& two$
1" print%!J0sK$str"; // or the more curt one
," print%!str";
Answer , Explanation:
Prefer the first one" @f the str contains an+ format characters lie ?d then it will result in
a subtle bug"
?5. void main!"
{
int i)1*$ '),;
int *ip) +i$ *'p ) +';
int ( ) *ip/*'p;
print%!J0dK$(";


Answer:
1ompiler Error: Y9nexpected end of file in comment started in line =Z"
Explanation:
4he programmer intended to divide two integers' but b+ the Ymaximum munchZ rule' the
compiler treats the operator seBuence S and D as SD which happens to be the starting of
comment" 4o force what is intended b+ the programmer'
int > DipS D;p!
SS give space explicit+ separating S and D
SSor
5H
Download all Placement papers/Technical questions in
www.technicalsymposium.com
int > DipS(D;p)!
SS put braces to force the intention
will solve the problem"
?9. void main!"
{
char ch;
%or!ch)*;ch8)1,<;ch33"
print%!J0c 0d 1nJ$ ch$ ch";
}
Answer:
@mplemention dependent
Explanation:
4he char t+pe ma+ be signed or unsigned b+ default" @f it is signed then ch// is executed
after ch reaches (2H and rotates bac to #(2K" 4hus ch is alwa+s smaller than (2H"
?<. As this code le&alI
int *ptr;
ptr ) !int *" *x4**;
Answer:
Tes
Explanation:
4he pointer ptr will point at the integer in the memor+ location &x0&&"
?>. main!"
{
char a:4;)/QCBBE/;
print%!/0s/$a";


Answer:
1ompiler error: 4oo man+ initiali-ers
Explanation:
4he arra+ a is of si-e 0 but the string constant reBuires C b+tes to get stored"
??. main!"
{
char a:4;)/QCBB/;
print%!/0s/$a";
}
5K
Download all Placement papers/Technical questions in
www.technicalsymposium.com
Answer:
<E::?^IW^I^VVV^WWI
Explanation:
4he character arra+ has the memor+ ;ust enough to hold the string Y<E::Z and doesnt
have enough space to store the terminating null character" *o it prints the <E:: correctl+
and continues to print garbage values till it accidentall+ comes across a )9::
character"
Predict the output or error(s) for the following:
1**. main!"
{
int a)1*$*';
void *(;
')()+a;
'33;
(33;
print%!/1n 0u 0u /$'$(";

Answer:
1ompiler error: 1annot increment a void pointer
Explanation:
Loid pointers are generic pointers and the+ can be used onl+ when the t+pe is not nown
and as an intermediate address storage t+pe" )o pointer arithmetic can be done on it and
+ou cannot appl+ indirection operator (D) on void pointers"
1*1. Print% can #e implemented #y usin& 2222222222 list.
Answer:
Lariable length argument lists
1*,. char *some@un!"
{
char *temp ) Jstrin& constant/;
return temp;

int main!"
{
puts!some@un!"";

Answer:
5.
Download all Placement papers/Technical questions in
www.technicalsymposium.com
string constant
Explanation:
4he program suffers no problem and gives the output correctl+ because the
character constants are stored in codeSdata area and not allocated in stac' so this doesnRt
lead to dangling pointers"
1*-. char *some@un1!"
{
char temp: ; ) Jstrin&/;
return temp;

char *some@un,!"
{
char temp: ; ) {SsT$ StT$TrT$TiT$TnT$T&T;
return temp;

int main!"
{
puts!some@un1!"";
puts!some@un,!"";

Answer:
Marbage values"
Explanation:
Qoth the functions suffer from the problem of dangling pointers" @n some8un(()
temp is a character arra+ and so the space for it is allocated in heap and is initiali-ed with
character string YstringZ" 4his is created d+namicall+ as the function is called' so is also
deleted d+namicall+ on exiting the function so the string data is not available in the
calling function main() leading to print some garbage values" 4he function some8un2()
also suffers from the same problem but the problem can be easil+ identified in this case"
1*4. There were 1* records stored in Jsome%ile.datK #ut the %ollowin& pro&ram
printed 11 names. Hhat went wron&I
void main!"
{
struct student
{
char name:-*;$ rollno:9;;
stud;
@ABC *%p ) %open!Jsome%ile.datK$KrK";
while!D%eo%!%p""
{
0&
Download all Placement papers/Technical questions in
www.technicalsymposium.com
%read!+stud$ si7eo%!stud"$ 1 $ %p";
puts!stud.name";
}
}
Explanation:
fread reads (& records and prints the names successfull+" @t will return E78 onl+ when
fread tries to read another record and fails reading E78 (and returning E78)" *o it prints
the last record again" After this onl+ the condition feof(fp) becomes false' hence comes
out of the while loop"
Predict the output or error(s) for the following:
15. #include
main()
{
char s[]={a!"!c!#n!c!#$%&
char 'p!'str!'str1&
p=(s[)]&
str=p&
str1=s&
printf(*+d*!,,'p , ,,'str1-).)&
}
Answer:
77
Explanation:
p is pointing to character '\n'. str1 is pointing to character 'a' ++*p. "p is pointing
to '\n'
and that is incremented ! one." the A"#$$ %al&e o' '\n' is 1() which is then
incremented
to 11. *he %al&e o' ++*p is 11. ++*str1) str1 is pointing to 'a' that is incremented
! 1
and it ecomes ''. A"#$$ %al&e o' '' is +,.
-ow per'orming .11 + +, / 012) we get 77."3"24
"o we get the o&tp&t 77 :: "3" .Ascii is 772.
1/. #include
main()
{
int a[.][.][.] = { {1$!.!)!0%! {5!/!1!2% %&
int 'p!'3&
p=(a[.][.][.]&
'3='''a&
printf(*+d----+d*!'p!'3)&
}
Answer:
"ome5arage6al&e7771
Explanation:
p89a:1;:1;:1; !o& declare onl! two 1< arra!s) &t !o& are tr!ing to access the
third
0(
Download all Placement papers/Technical questions in
www.technicalsymposium.com
1<.which !o& are not declared2 it will print garage %al&es. *=8***a starting
address o'
a is assigned integer pointer. -ow = is pointing to starting address o' a. $' !o&
print *=) it
will print >rst element o' 0< arra!.
11. #include
main()
{
struct 44
{
int 4=)&
char name[]=*hello*&
%&
struct 44 's&
printf(*+d*!s-54)&
printf(*+s*!s-5name)&
}
Answer:
#ompiler Error
Explanation:
?o& sho&ld not initiali@e %ariales in declaration
12. #include
main()
{
struct 44
{
int 4&
struct 66
{
char s&
struct 44 'p&
%&
struct 66 '3&
%&
}
Answer:
#ompiler Error
Explanation:
*he str&ct&re !! is nested within str&ct&re xx. Aence) the elements are o' !! are
to e
accessed thro&gh the instance o' str&ct&re xx) which needs an instance o' !! to
e
Bnown. $' the instance is created a'ter de>ning the str&ct&re the compiler will not
Bnow
ao&t the instance relati%e to xx. Aence 'or nested str&ct&re !! !o& ha%e to
declare
memer.
17. main()
{
printf(*#na"*)&
printf(*#"si*)&
printf(*#rha*)&
02
Download all Placement papers/Technical questions in
www.technicalsymposium.com
}
Answer:
hai
Explanation:
\n 7 newline
\ 7 acBspace
\r 7 line'eed
.$. main()
{
int i=5&
printf(*+d+d+d+d+d+d*!i,,!i--!,,i!--i!i)&
}
Answer:
CDDCD
Explanation:
*he arg&ments in a '&nction call are p&shed into the stacB 'rom le't to right. *he
e%al&ation is ! popping o&t 'rom the stacB. and the e%al&ation is 'rom right to
le't)
hence the res&lt.
.1. #de8ne s3uare(4) 4'4
main()
{
int i&
i = /09s3uare(0)&
printf(*+d*!i)&
}
Answer:
EC
Explanation:
the macro call s=&are.C2 will s&stit&ted ! C*C so the expression ecomes i 8
ECFC*C .
"ince F and * has e=&al priorit! the expression will e e%al&ated as .ECFC2*C i.e.
1E*C 8
EC
... main()
{
char 'p=*hai friends*!'p1&
p1=p&
while('p:=#$) ,,'p,,&
printf(*+s +s*!p!p1)&
}
Answer:
iGHgsG'oet
Explanation:
++*p++ will e parse in the gi%en order
I *p that is %al&e at the location c&rrentl! pointed ! p will e taBen
I ++*p the retrie%ed %al&e will e incremented
I when 4 is enco&ntered the location will e incremented that is p++ will e
exec&ted
05
Download all Placement papers/Technical questions in
www.technicalsymposium.com
Aence) in the while loop initial %al&e pointed ! p is JhK) which is changed to JiK !
exec&ting ++*p and pointer mo%es to point) JaK which is similarl! changed to JK
and so
on. "imilarl! lanB space is con%erted to JHK. *h&s) we otain %al&e in p ecomes
LiGH
gsG'oetM and since p reaches J\(K and p1 points to p th&s p1doesnot print
an!thing.
.). #include
#de8ne a 1$
main()
{
#de8ne a 5$
printf(*+d*!a)&
}
Answer:
D(
Explanation:
*he preprocessor directi%es can e rede>ned an!where in the program. "o the
most
recentl! assigned %al&e will e taBen.
.0. #de8ne clrscr() 1$$
main()
{
clrscr()&
printf(*+d#n*!clrscr())&
}
Answer:
1((
Explanation:
Nreprocessor exec&tes as a seperate pass e'ore the exec&tion o' the compiler.
"o
text&al replacement o' clrscr.2 to 1(( occ&rs.*he inp&t program to compiler looBs
liBe
this :
main.2
{
1((4
print'."Od\n")1((24
}
-ote:
1((4 is an exec&tale statement &t with no action. "o it doesn't gi%e an!
prolem
Predict the output or error(s) for the following:
.5. main()
{
printf(*+p*!main)&
}
Answer:
"ome address will e printed.
00
Download all Placement papers/Technical questions in
www.technicalsymposium.com
Explanation:
P&nction names are G&st addresses .G&st liBe arra! names are addresses2.
main.2 is also a '&nction. "o the address o' '&nction main will e printed. Op in
print'
speci>es that the arg&ment is an address. *he! are printed as hexadecimal
n&mers.
./. main()
{
clrscr()&
}
clrscr()&
Answer:
-o o&tp&tFerror
Explanation:
*he >rst clrscr.2 occ&rs inside a '&nction. "o it ecomes a '&nction call. $n the
second
clrscr.24 is a '&nction declaration .eca&se it is not inside an! '&nction2.
.1. enum colors {;<=>?!;<@A!BCAAD%
main()
{
printf(*+d..+d..+d*!;<=>?!;<@A!BCAAD)&
return(1)&
}
Answer:
(..1..1
Explanation:
en&m assigns n&mers starting 'rom () i' not explicitl! de>ned.
.2. Eoid main()
{
char far 'farther!'farthest&
printf(*+d..+d*!siFeof(farther)!siFeof(farthest))&
%
Answer:
C..1
Explanation:
the second pointer is o' char t!pe and not a 'ar pointer
.7. main()
{
int i=0$$!G=)$$&
printf(*+d..+d*)&
}
Answer:
C((..0((
Explanation:
print' taBes the %al&es o' the >rst two assignments o' the program. An! n&mer
o'
print''s ma! e gi%en. All o' them taBe onl! the >rst two %al&es. $' more n&mer
o'
assignments gi%en in the program) then print' will taBe garage %al&es.
0=
Download all Placement papers/Technical questions in
www.technicalsymposium.com
)$. main()
{
char 'p&
p=*Hello*&
printf(*+c#n*!'('p)&
}
Answer:
A
Explanation:
* is a dere'erence operator 9 is a re'erence operator. *he! can e applied an!
n&mer o' times pro%ided it is meaning'&l. Aere p points to the >rst character in
the
string "Aello". *p dere'erences it and so its %al&e is A. Again 9 re'erences it to an
address and * dere'erences it to the %al&e A.
)1. main()
{
int i=1&
while (iI=5)
{
printf(*+d*!i)&
if (i5.)
goto here&
i,,&
%
}
fun()
{
here:
printf(*PP*)&
}
Answer:
#ompiler error: Qnde>ned lael 'here' in '&nction main
Explanation:
Raels ha%e '&nctions scope) in other words *he scope o' the laels is limited to
'&nctions . *he lael 'here' is a%ailale in '&nction '&n.2 Aence it is not %isile in
'&nction
main.
).. main()
{
static char names[5][.$]={*pascal*!*ada*!*co"ol*!*fortran*!*perl*%&
int i&
char 't&
t=names[)]&
names[)]=names[0]&
names[0]=t&
for (i=$&iI=0&i,,)
print'."Os")names:i;24
}
Answer:
0C
Download all Placement papers/Technical questions in
www.technicalsymposium.com
#ompiler error: R%al&e re=&ired in '&nction main
Explanation:
Arra! names are pointer constants. "o it cannot e modi>ed.
)). Eoid main()
{
int i=5&
printf(*+d*!i,, , ,,i)&
}
Answer:
S&tp&t #annot e predicted exactl!.
Explanation:
"ide eTects are in%ol%ed in the e%al&ation o' i
)0. Eoid main()
{
int i=5&
printf(*+d*!i,,,,,i)&
}
Answer:
#ompiler Error
Explanation:
*he expression i+++++i is parsed as i ++ ++ + i which is an illegal comination
o'
operators.
)5. #include
main()
{
int i=1!G=.&
switch(i)
{
case 1: printf(*BJJK*)&
"reaL&
case G: printf(*;=K*)&
"reaL&
%
}
Answer:
#ompiler Error: #onstant expression re=&ired in '&nction main.
Explanation:
*he case statement can ha%e onl! constant expressions .this implies that we
cannot
&se %ariale names directl! so an error2.
-ote:
En&merated t!pes can e &sed in case statements.
Predict the output or error(s) for the following:
)/. main()
{
int i&
printf(*+d*!scanf(*+d*!(i))& 99 Ealue 1$ is giEen as input here
}
0H
Download all Placement papers/Technical questions in
www.technicalsymposium.com
Answer:
1
Explanation:
"can' ret&rns n&mer o' items s&ccess'&ll! read and not 1F(. Aere 1( is gi%en as
inp&t
which sho&ld ha%e een scanned s&ccess'&ll!. "o n&mer o' items read is 1.
)1. #de8ne f(g!g.) g##g.
main()
{
int Ear1.=1$$&
printf(*+d*!f(Ear!1.))&
%
Answer:
1((
)2. main()
{
int i=$&
for(&i,,&printf(*+d*!i)) &
printf(*+d*!i)&
}
Answer:
1
Explanation:
e'ore entering into the 'or loop the checBing condition is "e%al&ated". Aere it
e%al&ates
to ( .'alse2 and comes o&t o' the loop) and i is incremented .note the semicolon
a'ter
the 'or loop2.
)7. #include
main()
{
char s[]={a!"!c!#n!c!#$%&
char 'p!'str!'str1&
p=(s[)]&
str=p&
str1=s&
printf(*+d*!,,'p , ,,'str1-).)&
}
Answer:
3
Explanation:
p is pointing to character '\n'.str1 is pointing to character 'a' ++*p meAnswer:"p
is
pointing to '\n' and that is incremented ! one." the A"#$$ %al&e o' '\n' is 1(. then
it is
incremented to 11. the %al&e o' ++*p is 11. ++*str1 meAnswer:"str1 is pointing
to 'a'
that is incremented ! 1 and it ecomes ''. A"#$$ %al&e o' '' is +,. oth 11 and
+, is
0K
Download all Placement papers/Technical questions in
www.technicalsymposium.com
added and res&lt is s&tracted 'rom 01.
i.e. .11++,7012877."3"24
0$. #include
main()
{
struct 44
{
int 4=)&
char name[]=*hello*&
%&
struct 44 's=malloc(siFeof(struct 44))&
printf(*+d*!s-54)&
printf(*+s*!s-5name)&
}
Answer:
#ompiler Error
Explanation:
$nitiali@ation sho&ld not e done 'or str&ct&re memers inside the str&ct&re
declaration
01. #include
main()
{
struct 44
{
int 4&
struct 66
{
char s&
struct 44 'p&
%&
struct 66 '3&
%&
%
Answer:
#ompiler Error
Explanation:
in the end o' nested str&ct&re !! a memer ha%e to e declared
0.. main()
{
e4tern int i&
i=.$&
printf(*+d*!siFeof(i))&
}
Answer:
RinBer error: &nde>ned s!mol 'Ui'.
Explanation:
extern declaration speci>es that the %ariale i is de>ned somewhere else. *he
compiler
0.
Download all Placement papers/Technical questions in
www.technicalsymposium.com
passes the external %ariale to e resol%ed ! the linBer. "o compiler doesn't >nd
an
error. <&ring linBing the linBer searches 'or the de>nition o' i. "ince it is not 'o&nd
the
linBer Vags an error.
0). main()
{
printf(*+d*! out)&
}
int o&t81((4
Answer:
#ompiler error: &nde>ned s!mol o&t in '&nction main.
Explanation:
*he r&le is that a %ariale is a%ailale 'or &se 'rom the point o' declaration. E%en
tho&gh
a is a gloal %ariale) it is not a%ailale 'or main. Aence an error
Predict the output or error(s) for the following:
00. main()
{
e4tern out&
printf(*+d*! out)&
}
int out=1$$&
Answer:
1((
Explanation:
*his is the correct wa! o' writing the pre%io&s program.
05. main()
{
show()&
}
Eoid show()
{
printf(*Mm the greatest*)&
}
Answer:
#ompier error: *!pe mismatch in redeclaration o' show.
Explanation:
When the compiler sees the '&nction show it doesn't Bnow an!thing ao&t it. "o
the
de'a&lt ret&rn t!pe .ie) int2 is ass&med. X&t when compiler sees the act&al
de>nition o'
show mismatch occ&rs since it is declared as %oid. Aence the error.
*he sol&tions are as 'ollows:
1. declare %oid show.2 in main.2 .
1. de>ne show.2 e'ore main.2.
0. declare extern %oid show.2 e'ore the &se o' show.2.
0/. main( )
{
=&
Download all Placement papers/Technical questions in
www.technicalsymposium.com
int a[.][)][.] = {{{.!0%!{1!2%!{)!0%%!{{.!.%!{.!)%!{)!0%%%&
printf(N+u +u +u +d #nO!a!'a!''a!'''a)&
printf(N+u +u +u +d #nO!a,1!'a,1!''a,1!'''a,1)&
%
Answer:
1(() 1(() 1(() 1
11C) 1(C) 1(1) 0
01. main( )
{
int a[ ] = {1$!.$!)$!0$!5$%!G!'p&
for(G=$& GI5& G,,)
{
printf(N+dO !'a)&
a,,&
%
p = a&
for(G=$& GI5& G,,)
{
printf(N+d O !'p)&
p,,&
%
%
Answer:
#ompiler error: l%al&e re=&ired.
Explanation:
Error is in line with statement a++. *he operand m&st e an l%al&e and ma! e
o' an!
o' scalar t!pe 'or the an! operator) arra! name onl! when s&scripted is an
l%al&e.
"impl! arra! name is a non7modi>ale l%al&e.
02. main( )
{
static int a[ ] = {$!1!.!)!0%&
int 'p[ ] = {a!a,1!a,.!a,)!a,0%&
int ''ptr = p&
ptr,,&
printf(N#n +d +d +dO! ptr-p! 'ptr-a! ''ptr)&
'ptr,,&
printf(N#n +d +d +dO! ptr-p! 'ptr-a! ''ptr)&
',,ptr&
printf(N#n +d +d +dO! ptr-p! 'ptr-a! ''ptr)&
,,'ptr&
printf(N#n +d +d +dO! ptr-p! 'ptr-a! ''ptr)&
}
Answer:
111
111
000
0CC
=(
Download all Placement papers/Technical questions in
www.technicalsymposium.com
07. main( )
{
Eoid 'Ep&
char ch = PgQ! 'cp = Ngoof6O&
int G = .$&
Ep = (ch&
printf(N+cO! '(char ')Ep)&
Ep = (G&
printf(N+dO!'(int ')Ep)&
Ep = cp&
printf(N+sO!(char ')Ep , ))&
}
Answer:
g1('!
Explanation:
"ince a %oid pointer is &sed it can e t!pe casted to an! other t!pe pointer. %p 8
9ch
stores address o' char ch and the next statement prints the %al&e stored in %p
a'ter t!pe
casting it to the proper data t!pe pointer. the o&tp&t is JgK. "imilarl! the o&tp&t
'rom
second print' is J1(K. *he third print' statement t!pe casts it to print the string
'rom the
Cth %al&e hence the o&tp&t is J'!K.
5$. main ( )
{
static char 's[ ] = {N"lacLO! NwhiteO! N6ellowO! NEioletO%&
char ''ptr[ ] = {s,)! s,.! s,1! s%! '''p&
p = ptr&
'',,p&
printf(N+sO!'--',,p , ))&
}
Answer:
cB
Explanation:
$n this prolem we ha%e an arra! o' char pointers pointing to start o' C strings.
*hen we
ha%e ptr which is a pointer to a pointer o' t!pe char and a %ariale p which is a
pointer
to a pointer to a pointer o' t!pe char. p hold the initial %al&e o' ptr) i.e. p 8 s+0.
*he
next statement increment %al&e in p ! 1 ) th&s now %al&e o' p 8 s+1. $n the
print'
statement the expression is e%al&ated *++p ca&ses gets %al&e s+1 then the pre
decrement is exec&ted and we get s+1 / 1 8 s . the indirection operator now gets
the
%al&e 'rom the arra! o' s and adds 0 to the starting address. *he string is printed
starting 'rom this position. *h&s) the o&tp&t is JcBK.
51. main()
=2
Download all Placement papers/Technical questions in
www.technicalsymposium.com
{
int i! n&
char '4 = NgirlO&
n = strlen(4)&
'4 = 4[n]&
for(i=$& i
{
printf(N+s#nO!4)&
4,,&
%
%
Answer:
.lanB space2
irl
rl
l
Explanation:
Aere a string .a pointer to char2 is initiali@ed with a %al&e LgirlM. *he strlen
'&nction
ret&rns the length o' the string) th&s n has a %al&e C. *he next statement assigns
%al&e
at the nth location .J\(K2 to the >rst location. -ow the string ecomes L\(irlM . -ow
the
print' statement prints the string a'ter each iteration it increments it starting
position.
Roop starts 'rom ( to C. *he >rst time x:(; 8 J\(K hence it prints nothing and
pointer
%al&e is incremented. *he second time it prints 'rom x:1; i.e LirlM and the third
time it
prints LrlM and the last time it prints LlM and the loop terminates.
Predict the output or error(s) for the following:
5.. int i!G&
for(i=$&iI=1$&i,,)
{
G,=5&
assert(iI5)&
%
Answer:
Y&ntime error: Anormal program termination.
assert 'ailed .iZD2) )
Explanation:
asserts are &sed d&ring de&gging to maBe s&re that certain conditions are
satis>ed. $'
assertion 'ails) the program will terminate reporting the same. A'ter de&gging
&se)
[&nde' -<EXQ5
and this will disale all the assertions 'rom the so&rce code. Assertion
is a good de&gging tool to maBe &se o'.
5). main()
=5
Download all Placement papers/Technical questions in
www.technicalsymposium.com
{
int i=-1&
,i&
printf(*i = +d! ,i = +d #n*!i!,i)&
%
Answer:
i 8 71) +i 8 71
Explanation:
Qnar! + is the onl! d&mm! operator in #. Where7e%er it comes !o& can G&st
ignore it
G&st eca&se it has no eTect in the expressions .hence the name d&mm!
operator2.
50. Rhat are the 8les which are automaticall6 opened when a > 8le is
e4ecutedS
Answer:
stdin) stdo&t) stderr .standard inp&t)standard o&tp&t)standard error2.
55. what will "e the position of the 8le marLerS
a: 'seeB.ptr)()"EE\U"E*24
: 'seeB.ptr)()"EE\U#QY24
Answer :
a: *he "EE\U"E* sets the >le position marBer to the starting o' the >le.
: *he "EE\U#QY sets the >le position marBer to the c&rrent position
o' the >le.
5/. main()
{
char name[1$]!s[1.]&
scanf(* #*+[T#*]#**!s)&
%
How scanf will e4ecuteS
Answer:
Pirst it checBs 'or the leading white space and discards it.*hen it matches with a
=&otation marB and then it reads all character &pto another =&otation marB.
51. Rhat is the pro"lem with the following code segmentS
while ((fgets(receiEing arra6!5$!8leUptr)) := AJV)
4
Answer 9 Explanation:
'gets ret&rns a pointer. "o the correct end o' >le checB is checBing 'or H8 -QRR.
52. main()
{
main()&
%
Answer:
Y&ntime error : "tacB o%erVow.
Explanation:
main '&nction calls itsel' again and again. Each time the '&nction is called its
ret&rn
address is stored in the call stacB. "ince there is no condition to terminate the
'&nction
=0
Download all Placement papers/Technical questions in
www.technicalsymposium.com
call) the call stacB o%erVows at r&ntime. "o it terminates the program and res&lts
in an
error.
57. main()
{
char 'cptr!c&
Eoid 'Eptr!E&
c=1$& E=$&
cptr=(c& Eptr=(E&
printf(*+c+E*!c!E)&
%
Answer:
#ompiler error .at line n&mer C2: si@e o' % is QnBnown.
Explanation:
?o& can create a %ariale o' t!pe %oid * &t not o' t!pe %oid) since %oid is an
empt!
t!pe. $n the second line !o& are creating %ariale %ptr o' t!pe %oid * and % o' t!pe
%oid
hence an error.
/$. main()
{
char 'str1=*a"cd*&
char str.[]=*a"cd*&
printf(*+d +d +d*!siFeof(str1)!siFeof(str.)!siFeof(*a"cd*))&
%
Answer:
1 D D
Explanation:
$n >rst si@eo') str1 is a character pointer so it gi%es !o& the si@e o' the pointer
%ariale.
$n second si@eo' the name str1 indicates the name o' the arra! whose si@e is D
.incl&ding the '\(' termination character2. *he third si@eo' is similar to the second
one.
/1. main()
{
char not&
not=:.&
printf(*+d*!not)&
%
Answer:
(
Explanation:
H is a logical operator. $n # the %al&e ( is considered to e the oolean %al&e
PAR"E) and
an! non7@ero %al&e is considered to e the oolean %al&e *YQE. Aere 1 is a non7
@ero
%al&e so *YQE. H*YQE is PAR"E .(2 so it prints (.
/.. #de8ne V=<WA -1
#de8ne XC@A 1
==
Download all Placement papers/Technical questions in
www.technicalsymposium.com
#de8ne D@<< $
main() {
if(D@<<)
puts(*D@<<*)&
else if(V=<WA)
puts(*XC@A*)&
else
puts(*V=<WA*)&
%
Answer:
*YQE
Explanation:
*he inp&t program to the compiler a'ter processing ! the preprocessor is)
main.2{
i'.(2
p&ts."-QRR"24
else i'.712
p&ts."*YQE"24
else
p&ts."PAR"E"24
}
Nreprocessor doesn't replace the %al&es gi%en inside the do&le =&otes. *he
checB ! i'
condition is oolean %al&e 'alse so it goes to else. $n second i' 71 is oolean %al&e
tr&e
hence "*YQE" is printed.
Predict the output or error(s) for the following:
/). main()
{
int L=1&
printf(*+d==1 is **+s*!L!L==1S*XC@A*:*V=<WA*)&
%
Answer:
1881 is *YQE
Explanation:
When two strings are placed together .or separated ! white7space2 the! are
concatenated .this is called as "stringi@ation" operation2. "o the string is as i' it is
gi%en
as "Od881 is Os". *he conditional operator. ]: 2 e%al&ates to "*YQE".
/0. main()
{
int 6&
scanf(*+d*!(6)& 99 input giEen is .$$$
if( (6+0==$ (( 6+1$$ := $) YY 6+1$$ == $ )
printf(*+d is a leap 6ear*)&
else
printf(*+d is not a leap 6ear*)&
%
Answer:
=C
Download all Placement papers/Technical questions in
www.technicalsymposium.com
1((( is a leap !ear
Explanation:
An ordinar! program to checB i' leap !ear or not.
/5. #de8ne ma4 5
#de8ne int arr1[ma4]
main()
{
t6pedef char arr.[ma4]&
arr1 list={$!1!.!)!0%&
arr. name=*name*&
printf(*+d +s*!list[$]!name)&
%
Answer:
#ompiler error .in the line arr1 list 8 {()1)1)0)C}2
Explanation:
arr1 is declared o' t!pe arra! o' si@e D o' characters. "o it can e &sed to declare
the
%ariale name o' the t!pe arr1. X&t it is not the case o' arr1. Aence an error.
Y&le o' *h&m:
[de>nes are &sed 'or text&al replacement whereas t!pede's are &sed 'or
declaring new
t!pes.
//. int i=1$&
main()
{
e4tern int i&
{
int i=.$&
{
const Eolatile unsigned i=)$&
printf(*+d*!i)&
%
printf(*+d*!i)&
%
printf(*+d*!i)&
%
Answer:
0()1()1(
Explanation:
'{' introd&ces new locB and th&s new scope. $n the innermost locB i is declared
as)
const %olatile &nsigned
which is a %alid declaration. i is ass&med o' t!pe int. "o print' prints 0(. $n the
next
locB) i has %al&e 1( and so print' prints 1(. $n the o&termost locB) i is declared
as
extern) so no storage space is allocated 'or it. A'ter compilation is o%er the linBer
resol%es it to gloal %ariale i .since it is the onl! %ariale %isile there2. "o it
prints i's
=H
Download all Placement papers/Technical questions in
www.technicalsymposium.com
%al&e as 1(.
/1. main()
{
int 'G&
{
int i=1$&
G=(i&
%
printf(*+d*!'G)&
}
Answer:
1(
Explanation:
*he %ariale i is a locB le%el %ariale and the %isiilit! is inside that locB onl!.
X&t the
li'etime o' i is li'etime o' the '&nction so it li%es &pto the exit o' main '&nction.
"ince the
i is still allocated space) *G prints the %al&e stored in i since G points i.
/2. main()
{
int i=-1&
-i&
printf(*i = +d! -i = +d #n*!i!-i)&
%
Answer:
i 8 71) 7i 8 1
Explanation:
7i is exec&ted and this exec&tion doesn't aTect the %al&e o' i. $n print' >rst !o&
G&st print
the %al&e o' i. A'ter that the %al&e o' the expression 7i 8 7.712 is printed.
/7. #include
main()
{
const int i=0&
Zoat G&
G = ,,i&
printf(*+d +f*! i!,,G)&
%
Answer:
#ompiler error
Explanation:
i is a constant. !o& cannot change the %al&e o' constant
1$. #include
main()
{
int a[.][.][.] = { {1$!.!)!0%! {5!/!1!2% %&
int 'p!'3&
p=(a[.][.][.]&
'3='''a&
=K
Download all Placement papers/Technical questions in
www.technicalsymposium.com
printf(*+d..+d*!'p!'3)&
}
Answer:
garage%al&e..1
Explanation:
p89a:1;:1;:1; !o& declare onl! two 1< arra!s. &t !o& are tr!ing to access the
third
1<.which !o& are not declared2 it will print garage %al&es. *=8***a starting
address o'
a is assigned integer pointer. now = is pointing to starting address o' a.i' !o& print
*=
meAnswer:it will print >rst element o' 0< arra!.
11. #include
main()
{
register i=5&
char G[]= *hello*&
printf(*+s +d*!G!i)&
}
Answer:
hello D
Explanation:
i' !o& declare i as register compiler will treat it as ordinar! integer and it will taBe
integer %al&e. i %al&e ma! e stored either in register or in memor!.
1.. main()
{
int i=5!G=/!F&
printf(*+d*!i,,,G)&
%
Answer:
11
Explanation:
the expression i+++G is treated as .i++ + G2
=.

Вам также может понравиться