View
214
Download
0
Category
Preview:
Citation preview
8/11/2019 1000 Ques
1/349
1.typedef struct{char *;nodeptr next;} * nodeptr;
what does nodeptr stand for?ans:
2.int *x[](); means
ans:expl: Elments of an array can't befunctions.
3.struct list{int x;struct list *next;}*head;the struct head.x !""#ns: a$o%e is correct & wron'expl: Before using the ptr type struct variablewe have to give memoryto that .An also when ever the struct
variable is ptr then we access themembers by !"#! operator.
$.main()
{int i;i!;ii*i;
printf(d+i);}ans: $
%.main(){
,-/ *fp!+*fp; fp!fopen(0one0+0w0)
8/11/2019 1000 Ques
2/349
fpfopen(0one0+0w0) fputc(1#1+fp!) fputc(121+fp) fclose(fp!)
fclose(fp)} a.error $. c. d. ans: no error. But &t will over writes on samefile.*****n
.3include4malloc.h5 char *f() {char *smalloc(6); strcpy(s+0'ood$ye0);}
main() { char *f(); printf(0c0+*f()1#1);} o&p?
for strcpy function string.h heaer fileshoul be inclue semicolon is missing in strcpy function
leftsie function call can come when it isreturning some pointer so (p)*A*+
7. 3define 8#x(x+y) (x)5(y)?(x):(y)
main()
{ int i!"+9+"; 8#
8/11/2019 1000 Ques
3/349
6. main() { int a!"+$+ c=+d=; if (a4$)>>(cd)
printf(d d d d@+ a+$+c+d); else
printf(0d d d d@+ a+$+c+d); }
ans: 1, % 3 3 -ote: if conition shoul be inbraces
A. main()
{ int i !"; printf(0 d d d Bn0+ i+ i+ i); }
ans: 13 11 11!". main() { int *p+ *c+ i;
i ; p (int*) (malloc(siCeof(i))); printf(0Bnd0+*p); *p !"; printf(0Bnd d0+i+*p); c (int*) calloc(); printf(0BndBn0+*c); }
-ote: calloc function has less parameterscallocn/ elemsi0e
main()
{int *p+ *c+ i;
8/11/2019 1000 Ques
4/349
i ;p (int*) (malloc(siCeof(i)));printf(0Bnd0+*p);*p !";
printf(0Bnd d0+i+*p);c (int*) calloc(+);printf(0BndBn0+*c);}
ans: garbage/ %/ 1,/ , malloc gives garbage ancalloc initiali0es with 0eros
!!. 3define 8#
8/11/2019 1000 Ques
5/349
ans: lvalue reuire for ternary operator
!E. 3define FG-HI(int) printf(0int d 0+int) main()
{ int x+y+C; x"=;y";C"!; FG-HI(xJx); C44=;FG-HI(x); y55=;FG-HI(y); }
ans: int ) , int ) 3 int ) ,
!. main() { char s[] 02ouKuets and 2ric$ats0; printf(0Bnc+ 0+*(>s[])); printf(0Bns+ 0+s);
printf(0Bns+0+s); printf(0Bnc0+*(s)); }
ans: u/ets an Bricbats/Bouuets an Bricbats/
u!L. main()
{struct s!{
char *str;struct s! *ptr;};static struct s! arr[] { {0Mydera$ad0+arr!}+
{02an'alore0+arr}+{0Nelhi0+arr}};
8/11/2019 1000 Ques
6/349
struct s! *p[=];int i;for(i";i4;i)p[i] arr[i].ptr;
printf(0sBn0+(*p)O5str);printf(0sBn0+(*p)O5str);printf(0sBn0+((*p))O5str);
}
ans: Bangalore 4elhi
4elhi
!7. main(){char *p 0hello worldP0;p["] 1M1;printf(0s0+p);}
ans: 5ello worl
!6. main(){int x!+y!;while( (x 5 ") >> (y 5 ") ){ printf(0!Ld!Ld0+x+y); x y;
y x; }}
8/11/2019 1000 Ques
7/349
ans: here x ) x6y an y ) x62y when y goesbeyon 3277 it falls in 8ve sie an loopbreas
!A. int f(int p)
{
int i "+ t !+ s !; while( s 4 p)
{
i;
t ;
s s;
}
return i;
}
ans: this function gives the no. of bits
reuire to represent a number in binary
form
". remo%e the duplicate from a sorted array.
!. fi$onacci series upto !"" recursi%ely.
8/11/2019 1000 Ques
8/349
. main()
{
char c[]={ " enter" , "first" , "print" ,
"new" }.;
char **cp[]={c+3, c+2, c+1, c};
char ***cpp[]=cp;
printf("%s", ++*cp);
printf("%s",--*++cp);
}
ans: lvalue reuire for secon printfstatement
=. QRN and R8 pro'rams
E. Srite a pro'ram to print!
= = =E E E E .
ans:main
9int i/+
fori)1+i;)%+i66 9 printf!
8/11/2019 1000 Ques
9/349
8/11/2019 1000 Ques
10/349
printf!
6. write a function maxsu$strin'(str+alpha+theta) str is thesource strin' and ha%e to return maximum su$strin'which starts with alpha and ends with theta.
ans:
main9int i/),/+
char st ) 'x'+char en ) 'y'+char p?@)!abxabcyxabcabcyabcxabyc!+char (str+
fori),+p?i@)'
8/11/2019 1000 Ques
11/349
>
A. Mow do you write a pro'ram which produces its own
source code as its output?
Mow can - find the day of the wee 'i%en the date?
Shy doesn1t R ha%e nested functions?
Shat is the most efficient way to count the num$er of$its which are set in a %alue?
ans: C. Ditchie
Mow can - con%ert inte'ers to $inary or hexadecimal?
ans: C. DitchieMow can - call a function+ 'i%en its name as a strin'?
ans: function pointers
Mow do - access commandOline ar'uments?
Mow can - return multiple %alues from a function?
ans: using pointer or structures
Mow can - in%oe another pro'ram from within a R
pro'ram?ans: using system function
Mow can - access memory located at a certain address?
Mow can - allocate arrays or structures $i''er thanLET?
Mow can - find out how much memory is a%aila$le?
Mow can - read a directory in a R pro'ram?
Mow can - increase the allowa$le num$er ofsimultaneously open files?
Shat1s wron' with the call 0fopen(0c:BnewdirBfile.dat0+0r0)0?
=". main()
8/11/2019 1000 Ques
12/349
{int x!"+y!;xx;yy;
printf(0d dBn0+x+y);}
ans: 11 1
=!. int x;main()
{
int x";{int x!";x;chan'eD%alue(x);x;8odifyD%alue();printf(0,irst output: dBn0+x);}
x;chan'eD%alue(x);printf(0Uecond Vutput : dBn0+x);8odifyD%alue();printf(0Ihird Vutput : dBn0+x);}
8odifyD%alue(){
return (x!");}
chan'eD%alue(){return(x!);}
8/11/2019 1000 Ques
13/349
ans:
irst output : 12
Fecon output : 1Ghir output : 1
=. main(){int x"+y=;x y x;y y x;printf(0d dBn0+x+y);
}
ans: %7 H$
==. main(){char *p!0Hame0;char *p;
p(char *)malloc(");while(*p*p!);printf(0sBn0+p);}
ans: -o output since p2 is at null character toget output moify the program given below.-ote: ;malloc.h# shoul be inclue
{char *p!0Hame0;char *p+*p=;p(char *)malloc(");p=p;while(*p*p!);printf(0sBn0+p=);
8/11/2019 1000 Ques
14/349
8/11/2019 1000 Ques
15/349
=L. main(){ char *ptr 0Gamco Uystems0;(*ptr);printf(0sBn0+ptr);
ptr;printf(0sBn0+ptr);}
ans:Famco Fystemsamco Fystems
=7. main(){ char s![]0Gamco0;char s[]0Uystems0;s!s;printf(0s0+s!);}
ans: lvalue reuire s1 is base aress ofarray
=6. main(){char *p!;char *p;p!(char *) malloc();p(char *) malloc();strcpy(p!+0Gamco0);
strcpy(p+0Uystems0);strcat(p!+p);printf(0s0+p!);}
ans: DamcoFystems -ote: ;malloc.h#shoul be inclue
8/11/2019 1000 Ques
16/349
=A. # code lie this is 'i%en.a. for(i";i4num;i)$. for(inum;i5";iOO)
#ssumin' no code optimiCation and assume that themicroprocessorhas fla's etc. which one is faster.
Ans: b will execute faster.
E". main(){int a!+$+c=;
printf(0d+d0+a+$+c);}
ans: 1/ 2
E!. main(){struct{
char a[=];int $;}x;char *cp;printf(d d@+siCeof(cp)+siCeof(x));}
ans: $ % since pointer cp storesaress32"bit $ bytes it taes an
an x taes % bytes3 for character array aan 2 for int b
E. main(){int p=+KE;
8/11/2019 1000 Ques
17/349
K shw(>p);printf(0d d0+p+K);}
int shw(int *a){*a !";}
ans: 1, garbage
E=. write 7*a interms of +O+44
ans: x;;3"x
EE. main(){char *s! 0hello0+*s 0a$ce0;strcpy(s!+00);s["] s!["];printf(0dd0+strlen(s!)+strlen(s));
}
ans: , ,
E. main(){int i!";printf(0ddd0+i+i+i);
}
ans: 12 11 11 compiler epenent
8/11/2019 1000 Ques
18/349
EL. const char *char * constShat is the differnce $etween the a$o%e two?
ans: const char ( pointer to a constantcharacter char ( const constant pointer pointingto a character
E7. main(){char *x0new0;char *y0dictonary0;
char (t+%oid swap (char * + char *);swap (x+y);printf(0(s+ s)0+x+y);
char (t+tx;xy;yt;
printf(0O(s+ s)0+x+y);}%oid swap (char *x+char *y){char *t;yx;xy;yt;}
ans: multiple eclaration of t an alleclarations shoul be before executablestatementerrors
E6. main()
8/11/2019 1000 Ques
19/349
{char p[]0strin'0;char t;int i+9;
for(i"+9strlen(p);i49;i){tp[i];p[i]p[9Oi];p[9Oi]t;}printf(0s0+p);}
ans: will not print anything since p will bepointing to a null string
EA. main(){int i!";printf(0d d d0+i+i+i);}
ans: 12 12 1, compiler epenent
". main(){%oid f(int+int);int i!";f(i+i);}
%oid f(int i+int 9){if(i5")return;i9;f(i+9);printf(0d+0+i);
8/11/2019 1000 Ques
20/349
}
ans: %1 $1 31 21 i)11/ )1, for function If*
!. main(){%oid f(int+int);int i!";f(i+i);}%oid f(int i+int 9){if(i5")
return;i9;f(i+9);printf(0d+0+i);}
ans: %% $$ 33 22 i)11/ )11 for function If*
. main()
{char *s0hello world0;int i7;printf(0.*s0+i+s);}
ans: hello w
=. main()
{int a+$;printf(0enter two num$ers :0);scanf(0dd0+a+$);printf(0ddd0+a+$+a$);}
8/11/2019 1000 Ques
21/349
ans: will generate run time error Jcoreump
E. main(){union{int x;char y;struct {char x;char y;int xy;}p;
}K;printf(0Bn d+d0+siCeof(K)+siCeof(int));}
ans: $/2
. main(){char *x0Utrin'0;
char y[] 0add0;char *C;C(char *) malloc(siCeof(x)siCeof(y)!);strcpy(C+y);strcat(C+x);printf(0sss0+y+x+C);}
ans: a6Ftring)aFtring
L. an arrey of n pointers to function returnin' pointers tofunctions returnin' pointers to characters
ans: char ( ( *x?n@
8/11/2019 1000 Ques
22/349
pointer to array of int+ char etc.+ this is arraypointer
ans: int (x?@ char (x?@
array of pointer to int+ char etc.+ this is pointerarray
ans: int (x?@ char (x?@
function returnin' pointer to int+ char etc.+
ans: int (x char (x
pointer to function returnin' int+ char etc.+
ans: int (x char (x
function returnin' pointer to array of pointer to functionreturnin' char
ans: char ((x ?@
array of pointer to function returnin' pointer to array ofchar
ans: char ((x?@ ?@
7. main(){
enum num$er { aO!+ $ E+c+d+e};printf(0d0+e);}
ans: 7
6. main()
8/11/2019 1000 Ques
23/349
8/11/2019 1000 Ques
24/349
ans: 1 no. of ones
L!. which one will o%er flow 'i%en two pro'ramspro' !: pro':
main() main{ {int fact; int fact),lon' int x; fori)1+i;)n+i66factfactoral(x); fact)fact(i+} }
int factorial(lon' int x)
{if(x5!) return(x*factorial(xO!);}
ans: program 1 program 2 is always 0ero sincefact ),
L. main(){
char str[]0hello0;if(strHW) printf(0strin' null0);else printf(0strin' not null0);}
ans: string not null
L=. %oid f(int %alue){
for (i";i4!L;i){if(%alue >"x6"""55!) printf(0!0)else printf(0"0);}}
8/11/2019 1000 Ques
25/349
ans: binary output of value
LE. %oid f(int *p){
static %al!"";%al>p;}main(){int a!";printf(0d 0+a);f(>a);printf(0d 0+a);
}
ans: nonportable pointer conversion wecan*t store aress in integer variable/ wehave to tae pointer to store aress
L. main(){
int x+ *y;x y;printf(d@+x);}
ans: nonportable pointer conversion
LL. 3 define f(a+$) a$3define '(c+d) c*d
find %alue of f(E+'(+L))
ans: 3$
L7. main(){
8/11/2019 1000 Ques
26/349
char a[!"]0hello0;strcpy(a+1B"1);printf(0s0+a);}
ans: arguments must be a string constant orcharacter array variablehere it is constat character not a stringconstant. 5ence program error
L6. char a[][!];int $[][!];address of a "x!""" and $ is "x""" find address of
a[=][E] and $[=][E]inter'er taes =O$its and character taes 6O$its
ans: a?3@?$@ ) ,x1,31 b?3@?$@ ) ,x2,K$-ote: aresses are in hexaecimal
LA. Qi%en an inter'er in $inary form+find the num$er ofones in
that num$er without countin' each $it.(Ihis Kuestin isnotmultiple choice Kuestion. Ihis Kuestion carries moremars. Uo please tae care for this Kuestion.)
ans: C.Ditchie
7". main(){
a;$=;xUW8(a+$)*;printf(0xdBn0+x);}
ans: L
8/11/2019 1000 Ques
27/349
7!. num$er(int i){num$er;
printf(0dBn0+num$er);}
main(){static int i";num$er(i);}
ans: lvalue reuire function name is anaress. Fo 66 operator shoul not be applie
7. main(){unsi'ned char i;int sum;for(i"; i4=""; i)sum i;
printf(0BnUum dBn0+ sum);}
ans: infinite loop
7=. %oid fn(int *p){static int %al !"";p >%al;
}
main(){int i!";printf(0idBn0+ i);fn(>i);
8/11/2019 1000 Ques
28/349
printf(0idBn0+ i);}
ans: i)1,
i)1,
7E. Uwappin' without usin' a temporary %aria$les. (=methods)
ans:
x ) x6y+y ) x"y+
x ) x"y+
x ) xMy+y ) xMy+x ) xMy+
x ) x(y+y ) xJy+x ) xJy+
7. Rode ! :for(i"; i4!"""; i)for(9"; 94!""; 9)x y;
Rode :for(i"; i4!""; i)for(9"; 94!"""; 9)
x y;
Shich code will execute faster
ans: Koe2 Koe 1 ) 1/,1,,, incrementoperations
8/11/2019 1000 Ques
29/349
Koe 2 ) 1/,,1,, incrementoperations
7L. main()
{int a[!"] {!+ + =+ E+ + L+ 7+ 6+ A+ !"}+ i+ x!"+temp;for(i"; i4x; i){temp a[i];a[i] a[xOiO!];a[xOiO!] temp;}
ans: remains same
77. main("{int i !;for();for();printf(0Bni dBn0+ i!);}
ans: $ printfs will occur an i ) 2
76. 3define 8#
8/11/2019 1000 Ques
30/349
{int i!";for();for();
for();printf(0d@+i);}
ans: L printfs will occur an i ) 1, 2 powerno. of fors times printfs
6". 3define f(a+$) a$3define '(a+$) a*$
main(){int m;m*f(=+'(E+));printf(0Bn m is d0+m);}
ans: m is 2
6!. main(){char a[!"];strcpy(a+0B"0);if (aHW)printf(0Ba is null0);elseprintf(0Bn a is not null0);
}
ans: a is not null
6. main(){char a[]0hello0;
8/11/2019 1000 Ques
31/349
printf(0s0+a);}
ans: array si0e is small it shoul be
6=. main(){unsi'ned int xO!;int y;y X";if(x y)printf(0same0);else
printf(0not same0);}
ans: same "1 is store in 2*s complementform
6E. char *'xxx(){static char xxx[!"E];
return xxx;}
main(){char *'0strin'0;strcpy('xxx()+');' 'xxx();strcpy('+0oldstrin'0);
printf(0Ihe strin' is : s0+'xxx());}
ans: Ghe string is : olstring
6. %oid myalloc(char *x+ int n){
8/11/2019 1000 Ques
32/349
x (char *)malloc(n*siCeof(char));memset(x+1B"1+n*siCeof(char));}main()
{char *'0Utrin'0;myalloc('+");strcpy('+0Vldstrin'0);printf(0Ihe strin' is s0+');}
ans: Ghe string is Nlstring
6L. main(){char p[]0Utrin'0;int x";if(p0Utrin'0){printf(0Fass !0);if(p[siCeof(p)O]1'1)printf(0Fass 0);
elseprintf(0,ail 0);}else{printf(0,ail !0);if(p[siCeof(p)O]1'1)printf(0Fass 0);else
printf(0,ail 0);}
ans: ail 1Oass 2
67. # code which had some declarations of some dataitems. Ihere were a couple of normal data items (char+
8/11/2019 1000 Ques
33/349
int..) and some pointers as well and a malloc call. Youha%e to find the total memory taen up in the stac(Mint: Fointers and all are allocated in heap+ not instac+ so donZt count them).#lso in most of
these Kuestions+ they were specifyin' that the VU was= $it.
66. # structure was 'i%en and it contained normal data aswell as some $itOwise data. You had to find the totalsiCe taen up $y the structure
6A. Fointer to a function which returned an array ofchar pointers
ans: char ((x ?@
A". alue of particular %aria$les in R(8#
8/11/2019 1000 Ques
34/349
i!;printf(0d d dBn0 +i+ i*i+ i*i
*i*i*i*i);}
ans: %1H % 1,7 3, 32H % 112,
A=. main(){
int d ;int i!";d siCeof(i);printf(0d0+d);}
ans: 2
AE. char *f();
main(){char*a+*f();a(char*)malloc("*siCeof(char));af();printf(0s0+a);}char *f(){static char n?2,@+
strcpy(n+0Mello Sorld0);return(n);}
ans: 5ello Rorl
A. char *f();
8/11/2019 1000 Ques
35/349
main(){char*a+*f();a(char*)malloc("*siCeof(char));
af();printf(0s0+a);}char *f(){char n?2,@+strcpy(n+0Mello Sorld0);return(n);}
ans: unpreictable output. auto variablearess shoul not be returne. &t will loseits scope when it comes out of the bloc.
AL. char *f()main()
{char *a+*f();af();
printf(0s0+a);}char *f(){return(0Mello Sorld0);}
ans: 5ello Rorl
A7. what is the errormain()
{int 9!";switch(9){case ":pritnf!Sess than 2,!+$rea;case =":printf(0ess than ="0);
8/11/2019 1000 Ques
36/349
$rea;default:printf(0hello0);}
ans: printf not pritnf an one brace > ismissing
A6. which is %alid :(i)char arr[!"];arr0hello0;(ii) char arr[]0hello0;
ans: secon is correct. &n first lvalue reuire.
AA. main(){char *str;str(char*)malloc("*siCeof(char));strcpy(str+0test0);strcat(str+1P1);printf(0s0+str);
}
ans: strcpy function arguments shoul beeither a character array variable or a stringconstant. &nstea of I* give TU
!"". Mow many times main is 'et calledmain()
{
printf(0\um$oree0);main();}
ans: till stac overflow
8/11/2019 1000 Ques
37/349
!"!. main(){int i;if(i")
printf(0 Mell 0);elseprintf(0Mea%en0);}
ans: 5eaven
!". main(){
int i+9;for(i"+9";i4+94;i+9);printf(0d d0+i+9);}
ans: 2% 2% A pair of expressions separateby a comma is evaluate left to right/ an thetype an value of the result are the type anvalue of the right operan. 5ere we*ve to
consier ;2% conition.
!"=. !)pointer to a function.)pointer to structure.=)static %aria$le and difference $&w(const char *p+charconst *p+const char* const p).E)pass $y %alue > reference.)strin' li$rary functions(syntax).L)Srite a pro'ram to compare two strin's without
usin' the strcmp() function.7)Srite a pro'ram to concatenate two strin's.6)Srite a pro'ram to interchan'e %aria$les withoutusin' the third one.A)Srite pro'rams for Utrin' Ge%ersal > Falindromechec .!")Srite a pro'ram to find the ,actorial of a num$er.
8/11/2019 1000 Ques
38/349
!!)Srite a pro'ram to 'enerate the ,i$inocci Ueries.!)searchin' and sortin' alo'orithms withcomplexities.
!"E. Iheory Kuestion a$out far pointers.
ans: ar pointers are $ bytes in si0e an localpointers are 2 bytes in si0e. important: i saw in aprevious uestion paper of accenture which is inthe chetana atabase/ some lay wrote that si0eof an integer in K is 2 bytes an for K66 it is $bytes. Ghis is absur.Ghe si0e of types is entirelyepenent on the compiler use.for 4NF Gurbo K
si0eof int is 2 an float is $ bytes for winowsborlan K/K66 si0e of int is $ bytes for linux gcc/si0e of int is 2 bytes. All these epens on theNperating system.Olease eep this in min.
!". main(){char str[]{0hell0};
int i;
for(i";i4;i) printf(0ccccBn0+str[i]+i[str]+*(stri)+*(istr));
}
ans: hhhheeeellllllll
!"L. inline function does type checin' and so it is $etterthan a macro
!"7. main(){int i !";
8/11/2019 1000 Ques
39/349
int 9 i 55 !";printf(0d0+9);}
ans: ,
!"6. char *str 0Mello0;char arr[] 0Mello0;arr; && /GGVG..its lie a pointer constant*(arr !) 1s1;cout44arr; && o&p: Msllo
!"A. struct Nate
{ int yr; int day; int month;} date!+date;
date!.yr ""E;date!.day E;date!.month !;
now how will you initialiCe date (withoutmem$er $y mem$er assi'nment)ans: ate2 ) ate1+
!!". main(){extern int a;printf(0d0+a);;}
int a";
ans: 2,
!!!. main(){int a[]{+=};
8/11/2019 1000 Ques
40/349
printf(0Bn d d d0+a[]+a[=]+a[E]);}
ans: , , , if there are fewer initiali0ers
uninitiali0e variables are 0ero
!!. main(){intiO=+9+"+m;mi>>9;printf(0Bn d d d d0+i+9++m);}
ans: "2 3 , 1
!!=. main(){int a+$;asumdi'(!=);$sumdi'(!=);printf(0d d0+a+$);}
sumdi'(int n){static int s";int d;if(nP"){dn!";n(nOd)&!";ssd;
sumdi'(n);}else return(s);}
ans: 12
8/11/2019 1000 Ques
41/349
!!E. 3define RW2/(x) (x*x*x)main()
{int a+$=;
aRW2/($);printf(0Bn d d0+a+$);}
ans: 27
!!. main(){const int x'et();
printf(0d0+x);}'et(){return(");}
ans: 2, for auto variables initiali0ers can befunction calls or some expressions. But for
static initiali0ers shoul constants orconstant expressions.
!!L. # function has this prototype %oid f!(int **x)+ Mow willyou call this function?
{a) int **a; ($) int a; (c) int *a; (d) inta;
f!(a); f!(>a); f!(>a); f!(>>a);
ans: int (a+ f1a+
!!7. main(){int l!;for(;;){
8/11/2019 1000 Ques
42/349
printf(0d0+l);if(l5!")$rea;}
}
ans: 123$%7LH1,
!!6. main(){char str[]0fast0;static char *ptrDtoDarray str;printf(0s0+ptrDtoDarray);
}
ans: error. for auto variables initiali0ers canbe function calls or some expressions. Butfor static initiali0ers shoul constants orconstant expressions.
!!A. main(){
char str[]0fast0;char *ptrDtoDarray str;printf(0s0+ptrDtoDarray);}
ans: fast. for auto variables initiali0ers canbe function calls or some expressions. Butfor static initiali0ers shoul constants orconstant expressions.
!". main(){int i!";fn(i);
8/11/2019 1000 Ques
43/349
printf(0d0+i);}fn(int i){
return i;}
ans: 1,
!!. main(){int i+9;i!";
9siCeof(i);printf(0d0+i);}
ans: 1,
!. main(){struct emp
{char name["];int a'e;float sal;};struct emp e {0ti'er0};printf(0Bn d f0+e.a'e+e.sal);}
ans: , ,.,,,,,, &f there are fewerinitiali0ers in the list than members of thestructure the trailing members are initiali0ewith 0ero. Ghere may not be more initiali0ersthan members.
!=. main()
8/11/2019 1000 Ques
44/349
{char i";for(;i5";i) ;printf(0dBn0+i);
}
ans: "12L
!E. typedef enum 'rade{QVVN+2#N+SVGUI+}2#N;main()
{2#N '!;'!!;
printf(0d0+'!);}
ans: errormultiple eclaration for BA4
!. 3define UIY/! charmain()
{typedef char UIY/;
UIY/! x;UIY/ y;x;y;printf(0d dBn0+x+y);}
ans: "1 "1
!L. 3ifdef IGW/int -";3endif
main(){int 9";
8/11/2019 1000 Ques
45/349
printf(0d dBn0+i+9);}
ans: error since i is not eclare
!7. main("{char *pNestn+*pUource0- o%e You Naddy0;pNestn(char *)malloc(strlen(pUource));strcpy(pNestn+pUource);printf(0s0+pNestn);free(pNestn);}
ans: & Sove Qou 4ay
!6. main(){char a[][]+fla';a["]["]1#1;fla'((a*a)>>(*aa["]));printf(0dBn0+fla');
}
ans: 1
!A. main(){int i+9+;i9;printf(0d0+);
}
ans: lvalue reuire 66i66
!=". main(){int $!";
8/11/2019 1000 Ques
46/349
int *p>$;*p;printf(0d0+*p);}
ans: unnown value value at memorylocation next to the memory location of b
!=!. main(){int i"+9"while (i49){
if(4some condtn5){4$ody of the loop5i}elseif(4some condtn5){ 4$ody of the loop59OO}
else(4some condtn5){4$ody of the loop59OO}}Mow many times the $ody of the loopis 'oin' to
$e executed?
Ans: %, times
!=. Mow can you include a li$rary code written in R in asource code written in R?(Vptions are there)
ans. Fome cross"line platformcompiler isreuire for this.
8/11/2019 1000 Ques
47/349
!==. main(){int a["]+i;
for(i";i4";i){a[i]i;}for(i";i4";i){a[i]a["Oi];}for(i";i4";i)
printf(0d0+a[i]);}
ans: unnown value 1H 1L 17 1 1% 1$13 12 11 1, 11 12 13 1$ 1% 1 17 1L 1H
!=E. main(){int a["]+i;
for(i";i4";i){a[i]i;}for(i";i4";i){a[i]a["Oi];}for(i";i4";i)
printf(0d0+a[i]);}
ans: 1H 1L 17 1 1% 1$ 13 12 11 1, 1,11 12 13 1$ 1% 1 17 1L 1H
!=. %oid a$c(int a[])
8/11/2019 1000 Ques
48/349
{int ";int 9";while(49){
if(a[i]5a[9]);else9OO;}Mow many times the loop will occur?
Ans: %, times
!=L. main(){int a[]{+E+=++!};int x+y;int *p>a[];*p;x*p;y*(p);printf(0d d0+x+y);
}
ans: 3 3
!=7. int a; scanf(0f0+>a); is there any error or warnin' ?
ans. no compile time error but run time error
!=6. main(){int *p+*K;p(int *)!""";K(int *)""";printf(0d0+(KOp));}
8/11/2019 1000 Ques
49/349
ans: %,,
!=A. Shen a 1R1 function call is made+ the order in which
parameters passed to the function are pushed into thestac is
ans: right to left
!E". main(){extern int a;a!";
printf(0d0+a);}int a";
ans: 1,
!E!. siCeof () operator is used for
ans: ata type veriable
!E. main()main(){int i ;printf(0d d d d 0+i+ i+iOO+i);}
ans: 3 2 3 2
!E=. main(){int i ;printf(0old old old old 0+i+ i+iOO+i);}
8/11/2019 1000 Ques
50/349
ans: 3l 2l 3l 2l
!EE. Ucope of a 'lo$al %aria$le which is declared as static?
ans: ile
!E. main(){printf(0 Mello Bo is the world 0);}
ans: 5ello o is the worl
!EL. Shat isint *p(char (*s)[])
ans: p is a function which is returning apointer to integerwhich taes arguments as pointer to array ofcharacters.
!E7. Mow will u print I#I# alone from I#I# FVS/G usin'strin' copy and concate commands in R?
ans: implement strstr function
!E6. main(){int n !;switch(n)case !:printf(0R#U/ P0);case():printf(0default0);$rea;}
ans: error case outsie of switch anmisplace brea
8/11/2019 1000 Ques
51/349
all eywors in c shoul start with smallletters
!EA. 3define min((a)+($)) ((a)4($))?(a):($)
main(){int i"+a["]+*ptr;ptra;while(min(ptr+>a[A])4>a[6])ii!;printf(0idBn0+i);}
ans: i)%
!". X(X"446)?ans: Sast L igits are 1's rest are ,'s.
!!. struct x{int -;char s;
};union{struct x y;dou$le 9;}C;main()
{printf(0d0+siCeof (C));
}
ans: L
!. main(){char a[]{1!1+11+1=1+"+1!1+11+1=1};
8/11/2019 1000 Ques
52/349
printf(0s0+a);}
ans: 123
!=. main(){int a[]{1!1+11+1=1+"+1!1+11+1=1};printf(0s0+a);}
ans: 1
!E. main(){3define x !"{printf(0d0+x);}}
ans: 1,
!. main(){3define x !"{printf(0d0+x);}}
ans: lvalue reuire
!L. main(){char a[]0#2RN/,QM0;printf(0d0+siCeof(a));}
8/11/2019 1000 Ques
53/349
ans: H
!7. main()
{int i(int*)"x!""";printf(0d0+i);}
ans: nonportable pointer conversion
!6. main(int -){
printf(0d0+-);}
ans: 1 comman line arguments
!A. main(){printf(0 d0+printf(0helloworld0));}
ans: helloworl 1,
!L". main(){int a[][][L]{{+=+E++L+7}{^^^^^.}}printf(uuuu@+a+*a+**a+***a);
assume $ase address is L76A
ans: %7LH%/ %7LH%/ %7LH%/2 a/ a?,@/a?,@?,@/ a?,@?,@?,@
!L!. main()
8/11/2019 1000 Ques
54/349
{int a[][]{{}+{=}};printf(0d 0+a["]["]);printf(0d 0+a["][!]);
printf(0d 0+a[!]["]);printf(0d 0+a[!][!]);}
ans: 2 , 3 ,
!L. char str$uf[]0hello 0;char *strptr0world 0;str$uf0world 0;
strptr0hello0;
ans: error use strcpy function
!L=. char str![]0hello0;char str[]0hello0;the conditional strin' test (str!str)returns ,#U/
ans: use strcmp function
!LE. main(){int i;char *strE0!=four0;iatoi(strE);printf(0d0+i);
}
ans: 123
!L. main(){char loop;
8/11/2019 1000 Ques
55/349
for(loop1#1;loop41C1;loop)printf(0c0+loop);}
ans: print characters of ascii value from % to112
!LL. main(){char s[]{1!1+11+1=1+"+1!1+11+1=1};printf(0s0+s);}
ans: 123
!L7. main() { char *p@Raritor@; *p; printf(s@+p); *p;
printf(s@+*p); }
ans: aritor ritor
!L6. Mow to print @ sym$ol in printf?
ans: printfT
8/11/2019 1000 Ques
56/349
!7!. main(){
char str![]0M/V0;char str[]0M/V0;if(str!str)printf(0/_W#0);elseprintf(0HVI /_W#0);}
ans: -NG EVWAS use strcmp function for
comparing strings
!7. main(){int s;printf(0d0+s+s44+s55);}
ans: %
!7=. main(){int s;printf(0d d d0+s+s44+s55);}
ans: % 2, 1
!7E. main(){int a[][]{+=};printf(0d d d d0+a["]["]+a["][!]+a[!]
["]+a[!][!]);}
8/11/2019 1000 Ques
57/349
ans: 2 3 , ,
!7. main(){
int iO=+9+"+m;m 9>>i>>;printf(0d d d d0+i+9++m);}
ans: "2 3 1 1
!7L. main(){
const int i7;printf(0d0+i);}
ans: cannot moify a constant obect
!77. 3define - Lmain()
{
printf(0d0+-);}
ans: lvalue reuire
!76. main(){int a[][=][E]{{!++=+E++L+7+6+A+!+!+}+
{+=+E+7+L+7+6+A+"+"+"+"}};
printf(0d d d d0+a+*a+**a+***a);}
ans: 1,,2 1,,2 1,,2 1 array begins ataress 1,,2
!7A. main()
8/11/2019 1000 Ques
58/349
{printf(0c0+7[0sundaram0]);}
ans: m a?i@/ i?a@/ a?2@/ 2?a@
!6". main(){printf(0c0+0sundaram0[7]);}
ans: m a?i@/ i?a@/ a?2@/ 2?a@
!6!. main(int ar'c + char * ar'%[]){int i+9";for(i";i4ar'c;i)99atoi(ar'%[i]);printf(0d0+9);}
ans: if comman line arguments are
myprog 1 2 3
!6. main(){printf(0d0+O!55E);}
ans: "1 "1 is store in 2*s complement formwhen it is shifte sign bit is extene
!6=. struct x{int i;char c;};
8/11/2019 1000 Ques
59/349
union y{struct x a;dou$le d;};
main(){printf(0d0+siCeof(union y));}
ans: L union y is a union variable type.Fi0eof operator taes input either a variableor a ata type
!6E. struct x{char c!;char c;int i;short int 9;};
struct y{short int 9;
char c!;char c;int i;};main()
{printf(0d d0+siCeof (struct x)+siCeof (struct y));}
ans: struct x an struct y are structurevariable types. Fi0eof operator taes inputeither a variable or a ata type
!6. main(){int +9=+p";
8/11/2019 1000 Ques
60/349
p(+9+p);printf(0dBn0+p);}
ans: , comma operator
!6L. main(){int iO!";for(;i;printf(0dBn0+i));}
ans: prints "1, to "1
!67. main(){unsi'ned int iO!;printf(0d uBn0+i+i);printf(0uBn0+i*O!);}
ans: "1 %%3%
1
!66. main(){int **i;int *9";i>9;if (HW P i>> HW P *i){
printf(0- am here0);}}
ans: oes not print anything
!6A. main()
8/11/2019 1000 Ques
61/349
{int *9(int *)"x!""";printf(0p0+9);}
ans: ,,,, : 1,,,
!A". main(){int *9"x!""";printf(0p0+9);}
ans: ,,,,:1,,,
!A!. main(){int *9(int *)"x!"""; (or) int *9"x!""";printf(0d0+9);}
ans: $,H
!A. main(int x){printf(0d0+x);}
ans: 1 comman line arguments
if the name of the executa$le file is a$c and the
command line is'i%en asa$c xyCwhat is the output
ans: 2
8/11/2019 1000 Ques
62/349
!A=. main(){char a[]{1!1+11+1=1+"+1!1+11+1=1};printf(a);
}
ans: 123
!AE. 3define const const%oid main(int ar'c)
{const int x";}
ans: runs fine
!A. main(){int a[]{+L};printf(0d0+a[!.L]);}
ans:
!AL. struct x{int i"; &*line #*&};main(){struct x y; &*line 2*&
}
ans: error i is initiali0e in struct boy
!A7. struct {int len;char *str
8/11/2019 1000 Ques
63/349
}*p;p O5 len
ans: increments len
!A6. main(){char a[]0a$cdef'hi9lmnopKrstu%wxyC0;printf(0d0+siCeof(a));}
ans: 27 si0eof operator inclues nullcharacter also/ whereas strlen function
exclues null character
!AA. main(){char a[]0a$cdef'hi9lmnopKrstu%wxyC0;char *pa;printf(0d 0+strlen(p));p!";printf(0d0+strlen(a));
}
ans: 2 2
"". main(){printf(0d0+printf(0 hello world 0));}
ans: hello worl 13 incluing two spaces
"!. what is the output of the followin' code+ assumin' thatthe array$e'ins at location =LE67?
main()
8/11/2019 1000 Ques
64/349
{int a[][=][E]{{+!+E+=+L++6+7+"+A++}+{!++=+E++L+7+6+A+"+!+}
};printf(0u u u u0+a+*a+**a+***a);}
ans: %3$L7%/%3$L7%/%3$L7%/2
". main(){char a "x## ;
int $ ;$ (int) a ;$ $ 55 E ;printf(0x0+$);}
ans: fffa
"=. Shat is the siCe of the array declared as dou$le *
8/11/2019 1000 Ques
65/349
printf(0d0+scanf(0d0+>a));}
ans: it will wait for a character from
eyboar. &f u enter any numberit will print 1.
". main(){printf(0as0);printf(0B$hi0);printf(0isBn0);}
ans: ahiis
8/11/2019 1000 Ques
66/349
if(iOmax%al){printf(0inside0);}
else{printf(0out0);}}
ans: insie
"A. 3define a ==
3define $ !!O=main(){printf(0d0+a*$);}
ans: 33
!". main()
{int *i;int s(int *)malloc(!"*siCeof(int));for (i";i4!";i){printf(0d0+i*i);}}
ans: error -onportable pointer conversionan illegal use pointer i(i
!!. arrayZs $ase address is !"""....array is a[][E]..thenwat is decorrect address of a[E][=].../ach element taes E $ytes
8/11/2019 1000 Ques
67/349
ans:1,7
!. int a[+L]
how much memory will $e allocated
ans: oubtif comma operator is consiere12 bytes will be allocate
!=. 3define d !"!"main()
{printf(0d0+d*d);
}
ans: 12,
!E. main(){int i+9!;for(i";i4!";i);{
99i;}Frintf (0d d0+i+9);}
ans: 1, 11
!. static char *i;imalloc(siCeof(char));
find the error;
ans: malloc returns voi type casting isreuire char (
!L. main(){
8/11/2019 1000 Ques
68/349
int i"xaa;char *p;p(char *)i;pp55E;
printf(0x0+p);}
ans: illegal use of pointer p)p##$
!7. main(){enum{sundayO!+monday+wednesday};printf(0d d0+siCeof(wednesday)+wednesday);
}
ans: 2 1
!6. O5Mow do you write a pro'ram which produces its ownsource code as its output?O5Mow can - find the day of the wee 'i%en the date?O5Shy doesn1t R ha%e nested functions?O5Shat is the most efficient way to count the num$er
of $its which are set in a %alue?O5Mow can - con%ert inte'ers to $inary orhexadecimal?O5Mow can - call a function+ 'i%en its name as astrin'?O5Mow do - access commandOline ar'uments?O5Mow can - return multiple %alues from a function?O5Mow can - in%oe another pro'ram from within a Rpro'ram?
O5Mow can - access memory located at a certainaddress?O5Mow can - allocate arrays or structures $i''er thanLET?O5Mow can - find out how much memory is a%aila$le?O5Mow can - read a directory in a R pro'ram?O5Mow can - increase the allowa$le num$er of
8/11/2019 1000 Ques
69/349
simultaneously open files?O5Shat1s wron' with the call0fopen(0c:BnewdirBfile.dat0+ 0r0)0?
!A. %oid main(){int d;printf(0f0+d);}
ans: unefine
". %oid main()
{int i;for(i!;i4E;i)switch(i){case !: printf(0d0+i);$rea;{case :printf(0d0+i);$rea;case =:printf(0d0+i);$rea;
}}switch(i) case E:printf(0d0+i);}
ans: 123$
!. %oid main(){
int i;for(i!;i4E;i)switch(i){case !: printf(0d0+i);$rea;{case :printf(0d0+i);$rea;
8/11/2019 1000 Ques
70/349
case =:printf(0d0+i);$rea;}switch(i) case E:printf(0d0+i);}
}
ans: 123
. %oid main(){char *s0B!=EsBn0;printf(0d0+siCeof(s));}
ans: $ pointer taes $ bytes here
=. %oid main(){unsi'ned i!; &* unsi'ned char O! 5 ;
*&si'ned 9O!; &* unsi'ned or si'ned int O!
5L= *&
if(i49)printf(0less0);elseif(i59)printf(0'reater0);elseif(i9)printf(0eKual0);}
ans: less
E. Mow do you declare an array of H pointers to functionsreturnin' pointers to functions returnin' pointers tocharacters?
8/11/2019 1000 Ques
71/349
ans: char(((a?-@+
typedef char *pc; &* pointer to char *&typedef pc fpc(); &* function returnin' pointer to
char *&typedef fpc *pfpc; &* pointer to a$o%e *&typedef pfpc fpfpc(); &* function returnin'... *&typedef fpfpc *pfpfpc; &* pointer to... *&pfpfpc a[H]; &* array of... *&
22.int f();
!i# $ain()
{
f(1);
f(1,2);
f(1,2,3);
}
f(int i,int ,int &)
{
printf("%# %# %# ",i,,&);
}
ans: 1 garbage garbage 1 2 garabage 1 2 3
L. %oid main()
{int count!"+*temp+sum";temp>count;*temp";temp>sum;*tempcount;printf(0d d d 0+count+*temp+sum);
}
ans: 2, 2, 2,
7. main(){
8/11/2019 1000 Ques
72/349
static i=;printf(0d0+iOO);return i5" ? main():";}
ans: 321
6. char *foo(){char result[!""];strcpy(result+0anythin' is 'ood0);return(result);}
%oid main(){char *9;9foo();printf(0s0+9);}
ans: anything is goo aress of autovariable shoul not be returne. Fometimes
it will give unnown results
A. %oid main(){char *s[]{ 0dharma0+0hewlettO
pacard0+0siemens0+0i$m0};char **p;ps;printf(0s 0+*p);
printf(0s 0+*p);printf(0s 0+*p);}
ans: harma harma ewlett"pacar
=". main()
8/11/2019 1000 Ques
73/349
{static int i ";int C;if(i4)
{printf(0d 0+i);}elseexit(");C=;printf(0d d 0+C+main());}
ans: 1 2 3 $ %
=!. main(){static int i ";int C;if(i5){printf(0d 0+i);
exit(");}C=;printf(0d d 0+C+main());}
ans: 7
=. main()
{int C=;printf(0d d 0+C+main());}
ans: infinite loop or till stac overflows
8/11/2019 1000 Ques
74/349
==. main(){int i=+9;while (iOO+9OO)
{printf(0d d Bn0+i+9);}}
ans:2 $1 3, 2"1 1
"2 ,% times loop will be execute
=E. main(){int i=+9;if(iOO+9OO)printf(0d d Bn0+i+9);}
ans: 2 $
=. main(){int i=;printf(0d d d 0+i+iOO+i);}
ans: L L L
=L. main(){int times ;int i=;int 9E;
8/11/2019 1000 Ques
75/349
int =E;i9;while(times OO){
itimes;9times;times;}printf(0d d d 0+i+9+);}
ans: , , ,
=7. main(){int num =7L;while (num);printf(d +num);}
ans: 1
=6. main(){float =.E!L;printf(0f f 0+floor()+ceil());}
ans: 3.,,,,,, $.,,,,,,
=A. main()
{int num$er ;char name 1#1;printf(0Ihe addition of the name and the num$er
is o 0+namenum$er);}
8/11/2019 1000 Ques
76/349
ans: Ghe aition of the name an thenumber is 132
E". Ihe followin' function 'i%es some error. Shat chan'es
ha%e to $e made%oid ( int a+int $)
{int t; ta; a$; $t;}
ans: change everywhere a to (a an b to (b
E!. int main()
{,-/ *fp;fpfopen(0test.dat0+0w0);fprintf(fp+1helloBn0);fclose(fp);fpfopen (0test.dat0+0w0);fprintf (fp+ 0world0);fclose(fp);return ";
}
-f text.dat file is already present after compilin' andexecution how many $ytes does the file occupy ?
ans: % bytes******E. main()
{int i;
for(i";i4";i){switch(i){case ":i;case !:i;case :i;
8/11/2019 1000 Ques
77/349
default: iE;$rea;}printf(0d+0+i);}
}
ans: 1/ 21/
E=. main(){char cOLE;int iO=;unsigne int u )"1+
if(c5i){printf(0pass!+0);if(c4u)printf(0pass0);elseprintf(0,ail0);}else
printf(0,ail!+0);if(i4u)printf(0pass0);elseprintf(0,ail0);}
ans: ail1/ pass2
******EE. main(){char cOLE;int iO=;unsigne int u )1+if(c5i){
8/11/2019 1000 Ques
78/349
printf(0pass!+0);if(c4u)printf(0pass0);else
printf(0,ail0);}elseprintf(0,ail!+0);if(i4u)printf(0pass0);elseprintf(0,ail0);}
ans: ail1/ ail2 chec with above program
*****E. %oid main(){int i;char a[]0Utrin'0;char *p0Hew Urin'0;char *Iemp;
Iempa;amalloc(strlen(p) !);strcpy(a+p); &&ine num$er:A&&p malloc(strlen(Iemp) !);strcpy(p+Iemp);printf(0(s+ s)0+a+p);free(p);free(a);} &*ine num$er !*&
ans: lvalue reuire at line no. L
EL. main(){unsi'ned int xO!;int y;
8/11/2019 1000 Ques
79/349
y X";if(x y)printf(0same0);else
printf(0not same0);}
ans: same
******E7. char *'xxx(){static char xxx?1,2$@+return xxx;
}
main(){char *'0strin'0;strcpy('xxx()+');' 'xxx();strcpy('+0oldstrin'0);printf(0Ihe strin' is : s0+'xxx());
}
ans: Ghe string is olstring
*******E6. %oid myalloc(char *x+ int n){x (char *)malloc(n*siCeof(char));memset(x+1B"1+n*siCeof(char));}
main(){char *'0Utrin'0;myalloc('+");strcpy('+0Vldstrin'0);printf(0Ihe strin' is s0+');
8/11/2019 1000 Ques
80/349
}
ans: Ghe string is Nlstring
******EA. main(){char p[]0Utrin'0;int x";ifp))!Ftring!{printf(0Fass !0);if(p[siCeof(p)O]1'1)printf(0Fass 0);else
printf(0,ail 0);}else{printf(0,ail !0);if(p[siCeof(p)O]1'1)printf(0Fass 0);elseprintf(0,ail 0);
}}
ans: ail 1Oass 2 aress of array anaress of string where it is store areifferent
***". main(){
char *p0Utrin'0;int x";ifp))!Ftring!{printf(0Fass !0);if(p[siCeof(p)O]1'1)printf(0Fass 0);else
8/11/2019 1000 Ques
81/349
printf(0,ail 0);}else{
printf(0,ail !0);ifp?si0eofp"2@))'g'printf(0Fass 0);elseprintf(0,ail 0);}}
ans: ail 1ail2 aress of array an
aress of string where it is store areifferent
!. main(){printf(0u0+main);}
ans: ,
. main(){printf(0p0+main);}
ans: starting aress of main function x:ysegment : offset. Each time u run startingaress will change. unction name always
gives starting aress of that function.main()
{printf(0u0+main());}
8/11/2019 1000 Ques
82/349
ans: infinite loop or till stac overflows. mainfunction is calle recursively infinite times ortill stac overflows
=. main(){int i!";printf(0d d d0+i+i+i);}
ans: 12 11 11 compiler epenent
E. main()
{int *p+*K;p(int *)!""";K(int *)""";printf(0d0+(KOp));}
ans: %,,
. find(int x+int y){return ((x4y)?":(xOy)):}find(a+find(a+$)) is used for?
ans: fin out minimum of a/ b
L. find(int x+int y);main()
{int x+a6+$L;xfind(a+find(a+$));printf(0d0+x);}
find(int x+int y)
8/11/2019 1000 Ques
83/349
{ return ((x4y)?":(xOy));}
ans:
7. main(){int a;if (a7)printf(0 a is 7 0);elseprintf(0a is not 70);}
ans: a is 7
6. main(){int aE+$=+c;if (a5$)if($5c)printf(0inner0);else printf(0outer0);
}
ans: outer else is attache to inner if
A. main(){int a+$=+c;if (a5$)if($5c)
printf(0inner0);else printf(0outer0);}
ans: no output else is attache to inner if
L". main()
8/11/2019 1000 Ques
84/349
{inc(); inc(); inc();}inc()
{static int x;printf(0d0+ x);}
ans: 123
L!. main(){
printf(0d0+ strlen(00));}
ans: , strlen exclues null character. &t is anull string
L. main(){printf(0d0+ siCeof(00));
}
ans: 1 si0eof inclue null character. &t is anull string
L=. main(){int a+$;printf(0d0+ a$);
}
ans: 7
LE. main(){int %=+ *p%>%;
8/11/2019 1000 Ques
85/349
printf(0 d d 0+ %+*p%);}
ans: 3 3
L. main(){enum
cities{$ethlehem+9ericho+naCareth!+9erusalem};printf(0d d0+9ericho+naCareth);}
ans: 1 1
LL. difference $etween scanf and sscanf function
ans: sscanfs/... is euivalent to scanf...except thatinput charecter are taen from string s.
L7. main(){
char line[6"];scanf(0[JBn]0+line);printf(0s0+line);}
ans: if you type this is manu;enter# outputwill be this is manuscanf normally taes a single string but if weuse ?M
8/11/2019 1000 Ques
86/349
8/11/2019 1000 Ques
87/349
7=. main(){int a+$;
int *p+*K;a!";$!A;p)a6b+)max+}
ans: error must tae aress of memorylocation
*****7E. main(){printf(0u0+ siCeof(func));}
func(){return ";}
ans: error si0eof operator operan shoulnot be function name
7. main(){printf(0u0+ siCeof(func()));}
func(){return ";}
8/11/2019 1000 Ques
88/349
ans: 2 si0eof operator operan shoul notbe function name but it can be a functioncall
7L. siCeof operator isruntime operator
77. #n array whose elements are fn pointers whichinturn returns a character
ans: char (x?@ +
76. main(){
int n+i!;switch(n){case !:printf(0!0);case :printf(00);default:i!";
}printf(0id0+i);}
ans: 1, since n is not initiali0e it containsgarbage value hence almost all the timesefault case is run
7A. 3define max !"
main(){int a+$;int *p+*K;a!";$!A;p)a6b+)max+
8/11/2019 1000 Ques
89/349
}
ans: error must tae aress of a memorylocation
*****6". main(){int i;printf(0d0+ >i)!;scanf(0d0+ i)O!;}
ans: aress of memory location i scanf
function reas value into a garbage locationif it fall in protecte memory it gives errorotherwise value will be rea into thatlocation
********6!. main(){int i;float *pf;
pf (float *)>i;*pf !""."";printf(0d0+ i);}
ans: runtime error
6. main(){
int i "xff;printf(0d0+ i44);}
ans: 1,2,
6=. 3define U_G(x) x * x
8/11/2019 1000 Ques
90/349
main(){printf(0d0+ &U_G(!));}
ans: 22%
6E. union u{struct st{int i : E;int 9 : E;
int : E;int l;}st;int i;}u;
main(){u.i !"";
printf(0d+ d+ d0+u.i+ u.st.i+ u.st.l);}
ans: 1,, $ ,
6. union x{union u{
int i;int 9;}a[!"];int $[!"];}u;
main()
8/11/2019 1000 Ques
91/349
{printf(0d 0+ siCeof(u));printf(0d 0+ siCeof(u.a));printf(0d0+ siCeof(u.a["].i));
}
ans: 2, 2, 2 -ote: when unions orstructures are neste inner an outertagnames shoul be ifferent
******6L. main(){
int (*functa$le[])(char *format+ ...) {printf+ scanf};
int i !"";(*functa$le["])(0d 0+ i);(functable?1@!= !/ i+(functable?1@!= !/ i+(*functa$le["])(0d0+ >i);}
ans: runtime error is missing
***67. main(){
int(*functa$le[])(char *format+ ...) {printf+ scanf};int i !"";(*functa$le["])(0d+ 0+ i);(functable?1@!=!/ i+(functable?1@!=!/ i+(*functa$le["])(0+ d0+ >i);}
ans: 1,,/ enter two values for scanf/ iaress value. &n function pointers all thefunctions will have the same return type.
66. main(){
8/11/2019 1000 Ques
92/349
int i+ 9+ *p;i ;9 !"";p >i; &* #ddress of i is assi'ned to pointer p *&
printf(0f0+ i&(*p)); &* i is di%ided $y pointer p *&}
ans: runtime error format specifier =f is notmatche
6A. main(){char *p 0hello world0;
p["] 1M1;printf(0s0+ p);}
ans: 5ello worl
A". main(){char * str#;
char * str2 0- am VT0;memcpy( str#+ str2+ L);}
ans: error pointer shoul be initiali0ebefore using
A!. Mow will you print character?
ans: printfT
8/11/2019 1000 Ques
93/349
printf(0BB 0);printf(0 0);printf(0B0);}
ans: =
8/11/2019 1000 Ques
94/349
8/11/2019 1000 Ques
95/349
ans: stract function shoul be efine orstrcat shoul be use
A6. main()
{char *a 0Mello 0;char *$ 0Sorld0;printf(0s0+ strcat(a+$));}
ans: 5elloRorl
AA. main()
{char *a 00;char *$ 0Sorld0;printf(0s0+ strcpy(a+$));}
ans: Rorl
="". %oid func!(int (*a)[!"])
{printf(0V it wors 0);}
%oid func(int a[][!"]){printf(0Sill this wor?0);}
main(){int a[!"][!"];func!(a);func(a);}
8/11/2019 1000 Ques
96/349
8/11/2019 1000 Ques
97/349
char c;int i EL;c i;printf(0d0+ c);
}
ans: "%
=". main (){int x !";printf (0x d+ y d0+ x+OOx);}
ans: lvalue reuire
="L. main(){int i !"+ 9 ";printf(0d+ d+ 0+ 9OO + OOi);printf(0d+ d0+ 9 + i);}
ans: 2,/ H/ 1H/ 1,
="7. main(){int x;for(;x";xOO){printf(0xdBn0+ xOO);
}}
ans: no output
="6. main(){
8/11/2019 1000 Ques
98/349
8/11/2019 1000 Ques
99/349
printf(0d0+ $it);}}
ans: 2% %12
=!. main(){int i;for(i";i4;i){printf(0d 0+ ! 44 i);}
}
ans: 1 2 $ L 1
=!=. main(){si'ned int $it!+ i;for(;i;iOO){
printf(0d 0+ $it ($it 55 (i O (i O!))));}}
ans: 2% 12L $ 32 1
=!E. main(){si'ned int $it!+ i;
for(;i;iOO){printf(0d 0+ $it 55 (i O (i O!)));}}
ans: 2% 2% 2% 2% 2%
8/11/2019 1000 Ques
100/349
8/11/2019 1000 Ques
101/349
ans: , "%13
=!6. Shat is the difference $etween the followin'a. ii!;
$. i;
ans: 66i is a single instruction while ini)i61/ first i61 is compute an thenassigne.
=!A. Shat is exception handlin' and how is it different fromerror handlin'...... Shy
is exception handlin' used instead of error handlin' in
some cases and %ice %ersa.
=". /xplanation of VVF principlesONata #$straction.ONata /ncapsulationO-nheritenceOFolymorphismONynamic 2indin'.OGeduction of /rrors.
=!. main(){int d+a+$=+c(a+$);d(a+$);printf(0d d0+c+d);}
ans: 3 3 from 321 to 32$ thin about comma
operator
=. main(){int a+$=+ca+d;d(a+$);printf(0d d0+c+d);
8/11/2019 1000 Ques
102/349
}
ans: % 3
==. main(){int a+$=+c(a+$)+d;d(a+$);printf(0d d0+c+d);}
ans: 3 3
=E. main(){int a+$=+c(a+$)+d;da+$;printf(0d d0+c+d);}
ans: 3 % from 321 to 32$ thin about commaoperator
=. Shich one is ha%in' pro$lem?int *f!()
{int n;return (n)}
int *f()
{int *p;*p=;return p;}
int *f=()
8/11/2019 1000 Ques
103/349
8/11/2019 1000 Ques
104/349
ans: unefine symbol i
=A. main()
{int 9E;for(int i";i4;i){9;9;}printf(0d0+9);}
ans: 1$
==". main(){char s!["]0hello world0;s1?%@)U
8/11/2019 1000 Ques
105/349
===. 3define m 1,f+main()
{
f(m);}
fint or f{printf(0=0+9);}
ans: 1,
==E. 3define m 1,.,ffloat+main()
{f(m);}
ffloat {printf(0=f0+9);
}
ans: 1,.,,,,,, careful about macro valuetype an procee
==. f+main()
{int x!+y+C=;
f(x+y+C);}
fint p/int /int r{printf(0d d d0+p+K+r);}
8/11/2019 1000 Ques
106/349
ans: 1 2 3 in prototype we have not givenargument types as they are ints
==L. f+
main(){float x!."+y."+C=.";f(x+y+C);}
ffloat p/float /float r{printf(0f f f0+p+K+r);}
ans: error no prototype
==7. ffloat/ float/ float+main()
{float x!."+y."+C=.";f(x+y+C);}
ffloat p/float /float r{printf(0f f f0+p+K+r);}
ans: 1.,,,,,, 2.,,,,,, 3.,,,,,,
==6. main(){
int x";for(;;x){if(xE) $rea;continue;}printf(0dBn0+x);}
8/11/2019 1000 Ques
107/349
8/11/2019 1000 Ques
108/349
8/11/2019 1000 Ques
109/349
printf(0structures are eKual0);}
ans: structures are eual in A-F& K but
error in some other compilers. 4irectassignment an comparisons can*t be one.
=E7. main( ){char a[];a["] 1#1;printf(0c0+ a["]);}
ans: si0e of a is unnown
=E6. main(){
printf(0d dd0+siCeof(1=1)+siCeof(0=0)+siCeof(=));}
ans: 2 2 2
=EA. main(){printf(0c0+0a$cdef'h0[E]);}
ans: e
=". main()
{int a[ ]{!"+"+="+E"+"};char *p;p(char *)a;printf(0d0+*((int *)pE));}
8/11/2019 1000 Ques
110/349
ans: %,
=!. main(){
int a[]{!"+"+="+E"+"};char *p;p(char *)a;
printf(0d d d d0+*p+*(p!)+*(p)+*(p=));}
ans: 1, , 2, ,
=. main()
{printf(0c0+7[0sundaram0]);}
ans: m
==. 3define str(x) 3x3define
8/11/2019 1000 Ques
111/349
printf(0d0+a);}
ans: 11
=. main(){int $;$f(");printf(0d0+$);}
f(int a){
a#2, X return 1,: return 2,+}
ans: error in function efinition
=L. main(){int $;$f(");
printf(0d0+$);}
f(int a){return a#2, X 1,: 2,+}
ans: 2,
=7. Shat error would the followin' function 'i%e oncompilation.
f(int a+int $){int a;a";return a;
8/11/2019 1000 Ques
112/349
}ans: reeclaration of a
=6. main()
{int i=;ii;printf(0d0+i);}
ans: $
=A. main()
{static char a[]02om$ay0;char *$02om$ay0;printf(0d d0+siCeof(a)+siCeof($));}
ans: 7 $ here pointer taes $ bytes
=L".
main(){int x ;printf(0d d0+ x+ x);return ";}
ans:
=L!. main(){int C E;printf(0d0+ printf(0 d d 0+ C+ C));}
8/11/2019 1000 Ques
113/349
ans: $ $ % three spaces are there total fivecharacters will be printe by printfstatement
=L. main(){int C E;printf(0d0+ printf(0 d d 0+ C+ C));}
ans: $% $% 7
=L=. main( )
{int a[ ] { !"+ "+ ="+ E"+ "};int 9;for (9 "; 9 4 ; 9){printf(0d0+ * a);a66+}}
ans: lvalue reuire
=LE. main(){int n"+ i ";while(nOO5");i in;printf(0d0+i);
}
ans: "1
=L. main(){int i "; char ch `#Z
8/11/2019 1000 Ques
114/349
do {printf(c@+ ch);} while (i 4 ch 4 Z,Z);}
ans: AAAAAABK4E
=LL. int count+ sum;main(){for(count E; sum OOcount;);printf(0d0+ sum);}
ans: ,
=L7. main( ){static float a[ ] { !=.E+ !.}float *9+ *;9 a; a ;
9 9 * ; &;printf(ff @+ *9+ *);}
ans: error pointer multiplication anivision is illegal
=L6. main( )
{static char s[ ] GendeC%ous@;printf(d@+ *(s strlen(s)));}
ans: ,
8/11/2019 1000 Ques
115/349
=LA. main(){char **p0Mello0;printf(0c0+*p);
}
ans: 5
=7". main(){char **p0Mello0;printf(0s0+p);}
ans: 5ello
=7!. main(){char **p0Mello0;printf!=s!/(p+ J( or printfT=sU/((p+(J}
ans: error
=7. main(){char **p0Mello0;printf(0c0+**p);}
ans: error
=7=. main(){char a[]0Mello0;printf(0cBn0+*a66);}
8/11/2019 1000 Ques
116/349
ans: lvalue reuire
=7E. main()
{int a=+$+c!;static int a4$4cO!;printf(0d0+);}
ans: illegal initiali0ation for static initiali0ershoul be constant expression or constant
=7. main(){int a=+$+c!;int a4$4cO!;printf(0d0+);}
ans: ,
=7L. main(){char cO=;int iOLE;unsi'ned uOL;if(c5i)printf(0F#UU! 0);if( i 4 c)printf(0F#UU 0);
elseprintf(0,#-! 0);if(i4u)printf(0F#UU 0);elseprintf(0,#- 0);}
8/11/2019 1000 Ques
117/349
ans: OAFF1 OAFF2 OAFF2
=77. main()
{int iE;switch(i){case !:printf(0M/llo0);case default: && 0case0 should not come with0default0printf(0****0);
}}
ans: error case shoul not be there withefault
=76. main(){static int i;
printf(0d 0+iOO);if(i)main();}
ans: % $ 3 2 1
=7A. main(){
int a+c;int ptr;ptr)a+c(ptr* a;printf(0d+d0+c+a);}
8/11/2019 1000 Ques
118/349
ans: error nonportable pointer conversionan invali inirection
=6". main()
{int x!"+y+p+K;px5A;Kx5=>>yP=;printf(0pd Kd0+p+K);}
ans: p)1 )1
=6!. main(){int x!!+yL+C;CxyPE;printf(0Cd0+C);}
ans: 0)1
=6. main(){int c"+d+e!"+a;ac5!?d5!e5!?!"":"":="";printf(0ad0+a);}
ans: a)3,,
=6=. main(){int iO+9O;9un(i+>9);printf(0id+9d0+i+9);}9un(i+9)
8/11/2019 1000 Ques
119/349
int i+*9;{ii*i;*9*9**9;
}
ans: i)"%/)$
=6E. 3define HV3define Y/Umain()
{int i+9;
if(i5)9Y/U;else9HV;printf(0d0+9);}
ans: error -N an QEF are not efine
=6. 3define HV "3define Y/U !main()
{int i+9;if(i5)9Y/U;else9HV;
printf(0d0+9);}
ans: ,
=6L. main(){
8/11/2019 1000 Ques
120/349
8/11/2019 1000 Ques
121/349
int $=+a;printf(0i*&i*&*&i0+a+$+a$);}
ans: 2(J3(J=(Ji
=A!. Shich one of the followin' statements allocates enou'hspace to hold an array of !" inte'ers that are initialiCedto " ?
ans:int (ptr ) int ( calloc1,/si0eofint+
=A. main(){int i+9;9 !";i 9 O 9;printf(0d d0+ i+9);}
ans: , 12
=A=. main(){int 9;for(9";94=;9)foo();}foo() {static int i !";
i!";printf(0d 0+i);}
ans: 2, 3, $,
=AE. Shat is wron' in the followin' code
8/11/2019 1000 Ques
122/349
main(){char *c;c 0Mello0;
printf(0sBn0+ c);}
ans: 5ello nothing wrong with the coe
=A. main(){union {int a;
int $;int c;} u+%;u.a !";u.$ ";printf(0d d Bn0+u.a+u.$);}
ans: 2, 2,
=AL. main(){char *str 0!=E0;printf(0c c cBn0+ *str+ *(str)+ *(str));}
ans: 3 2 1
=A7. 3define max(a+$) (a$)?a:$main()
{int a+$;a=;$E;printf(0d0+max(a+$));
8/11/2019 1000 Ques
123/349
}
ans: error unefine symbol ab when it isreplace in printf statement
=A6. main(){int lenE;char *st0!=EL760;st st Olen;printf(0cBn0+*st);}
ans: some un character is printe
=AA. func();main()
{func(!);}func(int i){
static char (str)9 !Nne!/!Gwo!/!Ghree!/!our!>+printf(0sBn0+str[i]);return;}
ans: error in eclaration an efinition.Oointer shoul be there
E"". main(){int i;for (i!;i4!""; i)printf(0d ,xBn0+i+i);}
8/11/2019 1000 Ques
124/349
ans: 1 to HH will be printe both in ecimalan hexaecimal form
E"!. struct {
int x;int y;union {int idDno;char *name;}$;}s+*st;main()
{
st >s;stOx!";stO$.idDno !"!;printf(0d dBn0+s.x+s.$.idDno);}
ans: error unefine symbol i an b. i an bshoul not be use as irect variables. Gheyshoul be associate with structure variable
E". main(){int 9+ans;9 E;ans count(E);printf(0dBn0+ans);}
int count(int i)
{if ( i 4 ") return(i);elsereturn( count(iO) count(iO!));}
ans: "1L
8/11/2019 1000 Ques
125/349
E"=. main(){int iE;
if(i")printf(0statement !0);elseprintf(0statement 0);}
ans: statement 2
E"E. main()
{char a[];*a["]7;*a[!];printf(0d0+>a[!]Oa);}
ans: invali inirection
E". main(){char a[]0hellow0;char *$0hellow0;char c?%@)!hellow!+printf(0s s s 0+a+$+c);printf(0d d d0+siCeof(a)+siCeof($)+siCeof(c));}
ans: too many initiali0ers c array si0e isless
E"L. main(){char a[]0hellow0;char *$0hellow0;
8/11/2019 1000 Ques
126/349
char c[7]0hellow0;printf(0s s s 0+a+$+c);printf(0d d d0+siCeof(a)+siCeof($)+siCeof(c));}
ans: hellow hellow hellow 7 $ 7 here pointertaes $ bytes
E"7. int num[]{!"+!+++A"};main()
{int *p+*K;int i;
pnum;Knum;i*p;printf(0d d0+i+pOK);}
ans: 1, "1
E"6. Vne pointer declaration is 'i%en lie this:
int *(*p[!"])(char *+ char*)/xplain the %aria$le assi'nment
ans: an array of 1, pointers to functions withtwo character pointers as arguments anreturning integer pointer.
E"A. main(){
char *a[E]{09aya0+0mahe0+0chandra0+0$uchi0};printf(0d d d0+siCeof(a)+siCeof(char*)+siCeof(a)&siCeof(char *));}
ans: 1 $ $ pointer taes $ bytes
8/11/2019 1000 Ques
127/349
E!". Ihe inte'ers from ! to n are stored in an array in arandom fashion. $ut one inte'er is
missin'. Srite a pro'ram to find the missin' inte'er.
ans: Ghe sum of n natural numbers is )nn61J2. if we subtract the above sum from thesum of all the numbers in the array / the result isnothing but the missing number.
E!!. Srite a R pro'ram to find whether a stac is
pro'ressin' in forward or re%erse direction.
E!. Srite a R pro'ram that re%erses the lined list.
E!=. 3define 8#
8/11/2019 1000 Ques
128/349
E!. static int i ;main()
{
int sum";do{sum (!&i);}while("4iOO);}
ans: error ivie by 0ero
E!L. enum mode {'reen+red+oran'e+$lue +white};main ()
{'reen 'reen !;printf(0d+d0+'reen+red );}
ans: error lvalue reuire since green is asymbolic constant an ) operator shoul not
be there in enum eclaration
E!7. int (*(*ptr)(int)) (%oid)
ans: ptr is pointer to function that taes anint value returns a pointerto a function with a no argument whichreturns a integer
E!6. char *c[] {0,-/0+0/N-I0+0U/#GRM0+0RV8F-/0
};
8/11/2019 1000 Ques
129/349
8/11/2019 1000 Ques
130/349
int i+9 ;for(i";i4!";i);for(9";94!";9);printf(0id+9dBn0+i+9);
}
ans: i)11/)11
E. 3define sKuare(a) (a*a)main()
{printf(0d0+sKuare(E));}
ans: 2H
E=. main(){int p "+ K !;p K;p K;p KOO;
p OOK;printf(0d d0+p+K);}
ans: 1 1
EE. main(){int a + count;
int func(int);for (count ! ;count 4;count){a func(count);printf(0d0+ a);}}
8/11/2019 1000 Ques
131/349
int func(int x){int y;yx*x;
return(y);}
ans: 1$H12%
E. supposin' that each inte'er occupies E $ytes and eachcharactrer ! $yte + what is the
output of the followin' pro'ramme?
main(){int a[] { !++=+E++L+7};char c[] {1a1+1x1+1h1+1o1+11};printf(0d d0+ (>a[=]O>a["])+(>c[=]O >c["]));}
ans: 3 3
EL. main(){struct s! {int i; };struct s {int i; };struct s! st!;struct s st;st!.i ;st st!;printf(0 d 0 + st.i);
}
ans: error ifferent struct variables shoulnot assigne using !)! operator.
E7. main(){
8/11/2019 1000 Ques
132/349
8/11/2019 1000 Ques
133/349
ans: errorarray si0e is not eclare if it iseclare ans is , ,.,,,,,,
E=". 3 define infiniteloop while(!)
main(){infiniteloop;printf(0NVH/0);}
ans: infiniteloop in main ens with !+! . soloop will not reach en+an the 4N-E alsowill not print.
E=!. main(){int a+ $=;printf(0 d 0+ a$);}
ans: %
E=. 3define prn(a) printf(0d 0+a)3define print(a+$+c) prn(a)+ prn($)+ prn(c)3define max(a+$) (a4$)? $:a
main(){int x!+ y;print(max(x+y)+x+y);print(max(x+y)+x+y);
}
ans: 2 2 2 3 $ 2
E==. 3define FG-HI(int) printf(0intd 0+int);main()
{
8/11/2019 1000 Ques
134/349
int x+y+C;x"=;yO!;C"!;FG-HI(xJx);C44=;FG-HI(C);
y55=;FG-HI(y);}
ans: int), int)L int)"1
E=E. main(){int i;i!;
ii*i;printf(0d0+i);}
ans: $
E=. main(){char ch1#1;
while(ch41,1){switch(ch){case1#1:case121:case1R1:case1N1:ch;continue;case1/1:case1,1:ch;}putchar(ch);}
}
ans: P
E=L. main(){int a!+ $+ c=+ *pointer;
8/11/2019 1000 Ques
135/349
pointer>c;a)cJ(pointer+$c;printf (0ad $d0+a+$);
}
ans: error there shoul be space between Jan ( otherwise it will be starting ofcomment
E=7. 3define 8#H(x+y) (x)5(y)?(x):(y)main()
{
int i!"+9+"; 8#H(i+9);printf(0d d d d0+i+9+);}
ans: 12 11 garbage value
E=6. main(){
int a!"+$+ c=+d=;if(a4$)>>(cd)printf(0d d d d0 +a+$+c+d);else printf(0d d d d0+ a+$+c+d);}
ans: error if conition shoul beparenthesis
E=A. main(int siCe of ar' +char *ar'[]){while(siCe of ar')printf(0s0+ar'[OOsiCe of ar']);}
ans: error no space between si0eofarg
8/11/2019 1000 Ques
136/349
EE". main(int siCeofar' +char *ar'[]){while(siCeofar')
printf(0s0+ar'[OOsiCeofar']);}
ans: f:
8/11/2019 1000 Ques
137/349
{int x!"+y!;xx;yy;
printf(0d dBn0+x+y);}
ans: 11 1
EEE. main(){int x"+y=;x y x;
y y x;printf(0d dBn0+x+y);}
ans: %7 H$
EE. main(){char *p!0Hame0;
char *p;p(char *)malloc(");while(*p*p!);printf(0sBn0+p);}
ans: unnown string will be printe pointerp2 points to next character to null character.
EEL. main(){int x;printf(0d d dBn0+x+x44+x55);}
ans: % 2, 1
8/11/2019 1000 Ques
138/349
EE7. 3define swap!(a+$) aa$;$aO$;aaO$;main()
{
int x+y!";swap!(x+y);printf(0d dBn0+x+y);swap(x+y);printf(0d dBn0+x+y);}
int swap(int a+int $){
int temp;tempa;$a;atemp;return;}
ans: 1, %1, % swap2 won*t swap x an y
EE6. main(){char *ptr 0Gamco Uystems0;(*ptr);printf(0sBn0+ptr);ptr;printf(0sBn0+ptr);}
ans: Famco Fystemsamco Fystems
EEA. main(){char s![]0Gamco0;
8/11/2019 1000 Ques
139/349
8/11/2019 1000 Ques
140/349
}
ans: error Goo many initiali0ers
E=. main(){char a[]0hellow0;char *$0hellow0;char c[7]0hellow0;printf(0s s s 0+a+$+c);printf(0d d d 0+siCeof(a)+siCeof($)+siCeof(c));}
ans: hellow hellow hellow 7 $ 7 pointertaes $ bytes
EE. int a[!"]{L"+7+!"++E+=++6+A};
main(){int %arx+%ary+i;for (i";i4!";i)
{if(%arx4a[i]){%ary%arx;%arxa[!];}else if (%ary4a[i]){%arx%ary;
%arya[i];}printf(0d d Bn0+%arx+%ary);}}
8/11/2019 1000 Ques
141/349
8/11/2019 1000 Ques
142/349
ans: $
E6. main()
{int -=;while(-OO){int -!"";-OO;printf(0d0+ -);}}
ans: HHHHHH
EA. main(){char ch;for(ch1"1;ch4;ch)printf(0c0+ ch);}
ans: infinite loop signe character variesfrom "12L to 127
EL". x=function(x)...%alue E is passed to the function
x=function(x)...%alue = is passed to the function
EL!. Shat is runtime locata$le code?
Shat is %olatile+ re'ister definition in R
Shat is compiler and what its output.
EL. which of the followin' is ille'al for the pro'ram?
8/11/2019 1000 Ques
143/349
main(){char const *p1p1;}
!)p ) *p =)(*p) E) all
ans: 3 (p66 cannot moify a constantobect
EL=.3define putchar(c) printf(0c0+c)main()
{
int c1d1;putchar(c);}
ans:
ELE. %oid main (%oid){printf(0d0+ printf(0#2RBB0));
}
ans: ABK
8/11/2019 1000 Ques
144/349
ELL. %oid main(%oid){int a[!"]+ i;
int *$;$( int*) malloc(!"* siCeof(int)) ;b )a?3@+for(i";i4!";i)a[i] i!";printf(0d0+$[O!]);}
ans: 12
EL7. main(){int a[!"]{!++=+E++L+7+6+A+!"};int *pa;int *K>a[A];printf(0d0+KOp!);}
ans: 1,
EL6. main(){int iL;int *p>i;free(p);printf(0d0+i);}
ans:
ELA. main(){int i;iPi5=;
8/11/2019 1000 Ques
145/349
printf(0d0+i);}
ans: ,
E7". main(){int a[!"];=[a]!";printf(0d0+*(a=));}
ans: 1,
E7!. int (*p[!"]) ();
ans: p is array of pointers that each pointstoa function that taes no arguments anreturnsan int.
E7. struct emp{int a)2%+char b?2,@)!tg!+};
main(){emp e+e.a;
strcpy(e.$+0tellapalli0);printf(0d s0+e.a+e.$);}
ans: error structure members shoul not beinitiali0e irectly an struct eywor shoulbe there before emp e+
8/11/2019 1000 Ques
146/349
8/11/2019 1000 Ques
147/349
Shich of the a$o%e codes executes Kuicly.
ans: a"coe taes %,%, comparisons an
%,%, increments an b"coe taes %1,,comparisons an %1,, increments. Fo a"coeexecutes uicly which is having outer loopcount less
E77. i) (*ptr);ii) *ptr!;iii) *ptr;
which of the folowin' is same.
ans: i an ii are same
E76. %oid main(){char *s0susan0;clrscr();printf(s);
'etch();}
ans: susan
E7A. %oid main(){int a["];clrscr();
*a(int*)malloc(siCeof(a));printf(0d0+siCeof(a));'etch();}
ans: error nonportable pointer conversion
8/11/2019 1000 Ques
148/349
8/11/2019 1000 Ques
149/349
main(){int cLA;putchar(c);
}
ans: E
E6=. main(){printf(0d0+printf(0#2R&&0));}
ans: ABKJJ%
E6E. main(){int iL;printf(0d0+func(i));}
int func(int r){
int static result;if(r4") result!;elseresultfunc(rO=)func(rO!);return result;}
ans: 13
E6. main(){int i=;while(iOO){int i!"";iOO;
8/11/2019 1000 Ques
150/349
printf(0d..0+i);}}
ans: HH..HH..HH..
E6L. 3define putchar(c) printf(0c0+c)%oid main()
{char s1c1;putchar (s);}
ans: c
E67. Zefine putchar c printf!=c!/c%oid main()
{char s1c1;putchar (s);}
ans: error gap shoul not be there betweenputchar an c
E66. %oid main(){int a[]{A+E+!+7+};int *p;p>a[=];printf(0d0+p[O!]);
}
ans: 1
E6A. %oid main(){int a[]{!"+"+="+E"+"};
8/11/2019 1000 Ques
151/349
int *p;p (int*)((char *)a siCeof(int));printf(0d0+*p);}
ans: 2,
EA". Shich code will run faster
for(i";i4!"";i)for(9";94!";9)a[i][9]";
VG
for(9";94!";9)for(i";i4!"";i)a[i][9]";
ans: first coe 11,, increments 11,,comparisons
secon coe 1,1, increments 1,1,
comparisonssecon coe will run faster which is having
outer loop count less
"". main(){%oid print(int);int i;print(i);
}%oid print(int n){if(n5"){print(nO!);printf(0d0+n);
8/11/2019 1000 Ques
152/349
print(nO!);}}
ans: 1213121$1213121%1213121$1213121
"!. int * f(int a){int i;ia;return(>i);}
ans: we can't return aress of auto variable as itis allocation is mae in stac which is eallocatewhen the function returns.
". (!)Io find strin' len'th $y usin' recursi%e function.()Io find fi$onaci series $y usin' recursi%efunction.(=)Io write code for malloc so that allocation may $emade fastly.
(E)Srite a fn prototype which return a pointer whichpoints to an array of !" ints.
ans: int (f?1,@
"=. %oid main (){int
a[]{!"!+"!+="!+E"!+"!+L"!+7"!+6"!+A"!+""!};
int *p; clrscr ();printf(0d 0+a);printf(0arthi 0);printf(0d 0+ ((char *)a siCeof(int)));p(int *) ((char *) a siCeof (int));printf(0d0+*p);}
8/11/2019 1000 Ques
153/349
ans: LL$ arthi LL 2,1 aress of a )LL$
"E. %oid main (){int
a[]{!"!+"!+="!+E"!+"!+L"!+7"!+6"!+A"!+""!};int *p; clrscr ();printf(0d 0+a);printf(0arthi 0);printf(0d 0+ ((char *)"a siCeof(int)));p(int *) ((char *) a siCeof (int));
printf(0d0+*p);}
ans: error illegal use of pointer
". main (){int a[!"]{!"+A+6+7+L++E+=++!};clrscr();
int (p)a+int ()a?7@+printf(0d d 0+K+p);}
ans: error eclaration is not allowe heresince clrscr function is there. 4eclarationshoul come before any executablestatement
"L. main(){printf(0d0+printf(0MelloUoft0));}
ans: 5elloFoftH
8/11/2019 1000 Ques
154/349
"7. main(){int i=;
printf(0d d d0+i+i+i);}
ans: $ $ $
"6. main(){int i!";int 9+;
int a[!"];for(9";94!";9)a[9](i)(i*);}VptimiCe the a$o%e code.
ans: main9int i)1,/)%//a?1,@+
for),+;1,+66a?@)%+>
"A. main(){int *p"x!"";int *K"x!"";int p*K;
printf(0xBn0+);}
ans: error pointer multiplication is not vali
!". Rhar* foo(Utr...)
8/11/2019 1000 Ques
155/349
{ char str[E]; strcpy(str+0MelloUoft0); return str;
}
ans: we can't return aress of auto variableas itis allocation is mae in stac which iseallocatewhen the function returns.
!!. int a[!"]["][="][E"];
int *pMow to access an element of a usin' p?
ans: a?i@?@?@?l@ (p6
!. main(){int i!";if(i5")
if(i!")printf(0Mi0);elseprintf(02ye0);}
ans: no output
!=. -f a row daminated two dimentional arry in the
followin' which one is ad%anta'eand why?
a) for(i";i4!""";i)for(9";94!""";9)temptempa[i][9];
8/11/2019 1000 Ques
156/349
$) for(9";94!""";9)for(i";i4!""";i)temptempa[i][9]
ans: a ust it is a guess. &n Ia* we areaccessing elements which are in aacentlocations. &n Ib* we are accessing elementswhich are 1,,, locations apart
!E. %oid main(){printf(0d0+(float)=&);
}
ans: ,
!. %oid main(){char *s0Mello Sorld0;printf(0c0+s);}
ans: garbage character
!L. %oid main(){char *s0Mello Sorld0;printf(0c0+*s);}
ans: 5
!7. fp+fs;fpfopen(0tc.dat0+0w0);fsfopen(0tc.dat0+0w0);putch(1#1+fp);putch(121+fs); Shat will happen?
8/11/2019 1000 Ques
157/349
ans: A is overwritten by B
!6. Shat is the eKui%alent of a[i]
ans: (a6i
!A. int (funcint/intis a pointer to a function with inte'ers as parameters and returnin' an inte'er %alue.
". int ((funcint (/int (is a pointer to a functionwith inte'er pointers as parameters and returnin' apointer to an inte'er
!. switch(float %alue)
ans: compiler error
. main(){int a[]{!++=+E+};int *pa!;int *Ka;
int difKOp;printf(0d0+ dif);}
ans: $
=. switch(HW)ans: case ,: will be execute.
E. 3define exp main()
{printf(0d0+exp);}
ans: lvalue reuire
8/11/2019 1000 Ques
158/349
. strcat(str+str);ans: compilation error estination stringlength shoul accommoate both the strings
L. int(ptr?1,@
ans: pointer to array of 1, integers.
7. int main(){char *str 0Mello+ world0 ;printf(0s0 + str);
}
ans: 5ello/ worl when the fiel with isless than the length of the string the entirestring is printe
6. int (ptr?1,@+
ans: eclaration of 1, pointers
A. int main(){extern int i;printf(0d0 + i);}
ans: liner error
=". %oid temp();%oid temp(%oid);int main()
{temp();}%oid temp()
8/11/2019 1000 Ques
159/349
{printf(0R is excitin'P0);}
ans: K is exciting
=!. %oid temp();%oid temp(%oid);int main()
{temp();}%oid temp(%oid)
{printf(0R is excitin'P0);}
ans: K is exciting
=. %oid temp();%oid temp(%oid);int main()
{tempvoi+}%oid temp(){printf(0R is excitin'P0);}
ans: compiler error syntax error
==. %oid temp(int i){if(i !") return;i ;temp(i);printf(0d 0 + i);
8/11/2019 1000 Ques
160/349
}int main()
{temp(!);
}
ans: 1, H L 7 % $ 3 2
=E. some Kuestion on 0strto0 function
=. int main(){char *str 0Mello+ world0;
int i ) si0eofstr+for( ; i 5 " ; iOO)printf(0c0 + str[i]);}
ans: olle5 si0eof pointer is $ bytes
=L. int main(){
int a 8#
8/11/2019 1000 Ques
161/349
int a[]{!+++L+A+!"};int *$>a[E];printf(0Bnd0+$[O=]);}
ans: 2
=A. main(){int x"+y!;if(xy)y 7;else
y;printf(0d0+ y);}
ans: 7
E". main(){int i=A+count";
while( i > !) &&some condition lie this{count;ii55!;}printf(0d0+count);}
ans: 3
E!. main(){int i=A+count";while( i > !) &&some condition lie this{count;
8/11/2019 1000 Ques
162/349
i##1+}printf(0d0+count);}
ans: infinite loop
E. main(){int x!6;printf(0Bnd0+!x);}
ans: 12H
E=. main(){,-/ *f!;,-/ *f;f!fopen(0myfile0+0w0);ffopen(0myfile0+0w0);fputc(1#1+f!);
fputc(121+f);fclose(f!);fclose(f);}
what does f! n f conatins?
ans: B
EE. if i&p is coe friay monay sunayin commad line
thenmain(int ar'c+char *ar'%[])
{printf(0Bnc0+**ar'%);}
8/11/2019 1000 Ques
163/349
ans:may be f
E. 3define max !"main()
{printf(0Bnd0+max);}
ans: error lvalue reuire
EL. main(){int a[]{!++A+6+L+=++7+6+A};
int *pa!;int *KaL;printf(0Bnd0+KOp);}
ans: %
E7. main(){
int i=;while(iOO){int i!"";iOO;printf(0d 0+i);}}
ans: HH HH HH
E6. what does (*a)[!"] means?
ans: a is pointer to an array of 1, integers
EA. Vpen a file 0input0 and print the odd num$er of linesfirst on the screen and then
8/11/2019 1000 Ques
164/349
e%en num$er of lines..somethin' lie that.....
". main(){
int x+ y;y x*x * x ;printf(0d d0+x+y);}
ans: 7 21
!. main(){
int a!"+$;while(OO$5" >> a){OO$;a;}printf(0d d0+a+$);}
ans: 1 "2
. main(){char i;for (i"; i4; i){printf(0c0+ i);}
}
ans: infinite loop signe char range is "12Lto 127
=. main(){
8/11/2019 1000 Ques
165/349
int i";switch(i){case !: printf(0hi0);
case ": printf(0Cero0);case : printf(0world0);}}
ans: 0eroworl
E. struct
8/11/2019 1000 Ques
166/349
L. struct
8/11/2019 1000 Ques
167/349
int (i)1,,J (p+printf(0d0+i);}
ans: error nonportable pointer conversion
L". main(){int n;printf(0Bnn*d0+n+n);}
ans: n) % with specifier =% right
ustifie
L!. Mow lon' the followin' pro'ram will run?main()
{printf(0BnUonata Uoftware0);main();}
ans: until the stac overflows
L. main(){const int x;int *ptrx;ptrx>x;*ptrx!";&*x!";*&
printf(0d0+x);}
ans: 1, you can change a constant obect byusing a pointer
L=. main()
8/11/2019 1000 Ques
168/349
{const int x;int *ptrx;ptrx>x;
*ptrx!";x!;printf(0d0+x);}
ans: error cannot moify a constant obect
LE. main(){
const char *fun();(fun)!A!+}
const char *fun(){return 0Mello0;}
ans: error cannot moify a constant obect
fun returns to a !const char! pointer whichcannot be moifie
L. Shat error would the followin' function 'i%e oncompilation?
f(int a+ int $){int a;a";
return a;}
ans: error reeclaration of a
LL. Sould the followin' pro'ram compile?main()
8/11/2019 1000 Ques
169/349
{int a!"+*9;%oid *; 9>a;9;
66+printf(0Bnuu0+9+);}
ans: -o/ the arithmetic operation is notpermitte on voi pointers. Fi0e of the typeis unnown.
L7. -n the followin' pro'ram how would you print " usin'
p?main()
{int a[]{!"+ "+ ="+ E"+ "};char *p;p (char*) a;}
ans: printf!=!/(int(p6$+ or
printf!=!/(p6L+
L6. Foint out the error in the followin' pro'rammain()
{int a!";%oid f();a)f+printf(0Bnd0+a);
}%oid f()
{printf(0BnMi0);}
8/11/2019 1000 Ques
170/349
ans: error not an allowe type. Gheprogram is trying to collect the value of a!voi! function into an integer variable.
LA. -f the followin' pro'ram (mypro') is run from thecommand line as myprog friay tuesay sunay+Shat would $e the output?main(int ar'c+ char *ar'%[])
{while(siCeof(ar'%))printf(0s0+ar'%[OOsiCeof(ar'%)]);}
ans:
7". -f the followin' pro'ram (mypro') is run from thecommand line as myprog friay tuesay sunay+Shat would $e the output?main(int ar'c+ char *ar'%[])
{printf(0c0+*ar'%[!]);}
ans: r chec it out
7!. -f the followin' pro'ram (mypro') is run from thecommand line as mypro' friday tuesday sunday+ Shatwould $e the output?main(int ar'c+ char*ar'%[])
{printf(0c0+**ar'%);
}
ans: f chec it out
7. main(){char near * near *ptr!;
8/11/2019 1000 Ques
171/349
8/11/2019 1000 Ques
172/349
ans: 12L when not initiali0e const variablewill have garbage value
77. main()
{const int x;x!6;printf(0d0+x);}
ans: error cannot moify a constant obect.x shoul have been initiali0e where it iseclare
76. -n the followin' code+ is p an inte'er or an inte'erpointer?
typeef int( ptrptr p1/p2+
ans. &nteger pointer
7A. -f the followin' pro'ram (mypro') is run from the
command line as myprog monay tuesaywenesay thursay+ Shat would $e the output?main(int ar'c+ char *ar'%[])
{while(OOar'c 5")printf(0s0+*ar'%);}
ans: monay tuesay wenesay Ghursay
6". -f the followin' pro'ram (mypro') is run from thecommand line as mypro' ! =+ Shat would $e theoutput?main(int ar'c+ char *ar'%[])
{int i+9";
8/11/2019 1000 Ques
173/349
8/11/2019 1000 Ques
174/349
{,V#IFIG a+$;$!".";}
ans: b is a float variable no error
6. typeef float( SNAGOGD+main()
{,V#IFIG a+$;b)1,.,+}
ans: error illegal use of floating point. 5ereb is a floating pointer variable. Nbserve theifference between marco an typeef in %L$an %L% problems
6L. 3define U_G(x) (x*x)main()
{
int a+$=;a U_G($);printf(0d0+a);}
ans: 11
67. main(){
int iE;switch(i){default:printf(0Bn # mouse is an elephant $uilt $y the
\apanese0);case !:
8/11/2019 1000 Ques
175/349
printf(0 2reedin' ra$$its is a hair raisin'experience0);
$rea;case :
printf(0Bn ,riction is a dra'0);$rea;case =:printf(0Bn -f practice mae perfect+ then no$ody1s
perfect0);}}
ans: A mouse is an elephant built by the
]apanese Breeing rabbits is a hair raisingexperience
66. -n the followin' code+ in which order the functionswould $e called?
a f!(=+!E)*f(!&E)f=();
ans: f1/ f2/ f3
6A. f=(){printf(0three 0);return !;}
f!(int x+ int y){printf(0one 0);
return(xy);}
f(int x){printf(0two 0);return x;}
8/11/2019 1000 Ques
176/349
8/11/2019 1000 Ques
177/349
A=. main(){int i!;
switch(i){case !:printf(0BnGadioacti%e cats ha%e !6 halfOli%es0);$rea;case !*E:printf(0Bn2ottle for rent OinKuire within0);$rea;}
}
ans: Daioactive cats have 1L half"lives noerror
AE. main(){int i;printf(0-d id0+i+i);
}
ans: &)$ i)3
A. main(){unsi'ned char i"x6";printf(0id0+i44!);}
ans: i)2%
AL. main(){unsi'ned char i"x6";ii44!;
8/11/2019 1000 Ques
178/349
printf(0id0+i);}
ans: i),
A7. main(){int 2"x,,,,;^B + J( note: not assigne
to B (Jprintf(0d0+2);}
ans: "1
A6. main(){unsi'ned int 2"x,,,,;X2 ;printf!=!/B+}
ans: "1
AA. main(){unsi'ned int 2"x,,,,;X2 ;printf!=u!/B+}
ans: %%3%
L"". ,unc(int a+ int$){int a;a!";return a;
8/11/2019 1000 Ques
179/349
8/11/2019 1000 Ques
180/349
char c1a1;printf(0d d0+ siCeof(c)+siCeof(1a1));}
ans: 1 2
L". main(){char c1a1;Orintf(0d d0+ siCeof(c)+siCeof(1a1));}
ans: liner error unefine symbol_Orintf
L"L. main(){Khar c)'a'+printf(0d d0+ siCeof(c)+siCeof(1a1));}
ans: error unefine symbol IKhar* /unefine symbol Ic* / statement missing +
L"7. %oid main(%oid){struct s{int x;float y;}s!{+E.""};union u
{int x;float y;}u!;u1)union us1+printf(0d and f0+u!.x+u!.y);}
8/11/2019 1000 Ques
181/349
ans: error incompatible type conversion
L"6. int fn(%oid);
%oid print(int+int(*)());int i!";
%oid main(%oid){int i";print(i+fn);}
%oid print(int i+int (*fn!)()){printf(0dBn0+(*fn!)());}
int fn(%oid){return(iO);}
ans: %
L"A. %oid main(%oid){char num$ers[]
[L]{0ero0+0Vne0+0Iwo0+0Ihree0+0,our0};printf(0s is c0+>num$ers[E]["]+num$ers["]
["]);
}
ans: our is `
L!". %oid main(%oid){int y+C;
8/11/2019 1000 Ques
182/349
int x)y)0)1,+int fx;float ans".";f *x*y;
ansx&=."y&=;printf(0d .f0+f+ans);}
ans: 1,,, .33
L!!. dou$le d$l".E="+dE.7!"+d$l%ar=;%oid main(%oid)
{
dou$le d$ln(%oid);d$l%ar=d$ln();printf(0.fBt.fBt.fBn0+d$l+d+d$l%ar=);}
dou$le d$ln(%oid){dou$le d$l%ar=;d$ld$l%ar=E.;return(d$ldd$l%ar=);
}
ans: $.%, $.%7 13.%7
L!. %oid main(%oid){int old%ar+new%arO;int swap(int+int);swap(old%ar+new%ar);
printf(0Hum$ers are dBtd0+new%ar+old%ar);}
int swap(int old%al+int new%al){int temp%alold%al;old%alnew%al;new%altemp%al;
8/11/2019 1000 Ques
183/349
}
ans: -umbers are "2% 2%
L!=. %oid main(%oid){int i!""+9";i 9;i*9;printf(0dBtdBn0+i+9);}
ans: error lvalue reuire
L!E. int new%al(int);%oid main(%oid)
{int ia[]{!+E+E+"};int i;int sum";for(i";ia[i];i){
sumnew%al(ia[i]);}printf(0Uum d0+sum);}
int new%al(int x){static int di%!;return(x&di%);}
ans: Fum) 3H
L!. %oid main(%oid){int %ar!+%ar+%ar=+minmax;%ar!;
8/11/2019 1000 Ques
184/349
%ar;%ar=L;minmax)var1#var2Xvar1#var3X
var1:var3:var2#var3Xvar2:var3+
printf(0dBn0+minmax);}
ans: maximum of three numbers
L!L. static int i";int print(int i);%oid main(%oid)
{
static int i!"";while(print(i)){printf(0d 0+i);iOO;}}
int print(int x){
static int i;return(iOO);}
ans: 1,, HH
L!7. %oid main(%oid);typedef struct HIype
{
int i;char c;lon' x;}HewIype;
%oid main(%oid){
8/11/2019 1000 Ques
185/349
8/11/2019 1000 Ques
186/349
L!. 3define swap!(a+$) aa$;$aO$;aaO$;main()
{
int x+y!";swap1x/y+printf(0d dBn0+x+y);swap(x+y);printf(0d dBn0+x+y);}
int swap(int a+int $){int temp;
tempa;$a;atemp;return;}
ans: 1, %1, %
L. 3define swap!(a+$) aa$;$aO$;aaO$;main()
{int x+y!";swap1x/yprintf(0d dBn0+x+y);swap(x+y);printf(0d dBn0+x+y);}
int swap(int a+int $){int temp;tempa;$a;atemp;return;
8/11/2019 1000 Ques
187/349
}
ans: 1, %1, %
L=. 3define swap!(a+$) aa$;$aO$;aaO$main()
{int x+y!";swap1x/yprintf(0d dBn0+x+y);swap(x+y);printf(0d dBn0+x+y);
}int swap(int a+int $)
{int temp;tempa;$a;atemp;return;}
ans: error statement missing +
LE. main(){char *ptr 0Gamco Uystems0;(*ptr);printf(0sBn0+ptr);ptr;
printf(0sBn0+ptr);}
ans: Famco Fystemsamco Fystems
L. main()
8/11/2019 1000 Ques
188/349
{char s![]0Gamco0;char s[]0Uystems0;s!s;
printf(0s0+s!);}
ans: error lvalue reuire
LL. main(){char *p!;char *p;
p!(char *) malloc();p(char *) malloc();strcpy(p!+0Gamco0);strcpy(p+0Uystems0);strcat(p!+p);printf(0s0+p!);}
ans: DamcoFystems
L7. main(){int x!"+y!;xx;yy;printf(0d dBn0+x+y);}
ans: 11 1
L6. main(){int a";if(a") printf(0Gamco UystemsBn0);printf(0Gamco UystemsBn0);
8/11/2019 1000 Ques
189/349
}
ans: Damco Fystems
LA. main(){int a";if(a") printf(0Gamco UystemsBn0);printf(0Gamco UystemsBn0);}
ans: Damco FystemsDamco Fystems
L=". int Uum/lement(int *+int);%oid main(%oid)
{int x[!"];int i!";for(;i;){iOO;
*(xi)i;}printf(0d0+Uum/lement(x+!"));}
int Uum/lement(int array[]+int siCe){int i";float sum";for(;i4siCe;i)
sumarray[i];return sum;}
ans: $%
L=!. int printf(const char*+...);
8/11/2019 1000 Ques
190/349
8/11/2019 1000 Ques
191/349
ans: % 2, %
L=E. static int i;%oid main(%oid)
{int sum";do{sum(!&i);}while("4iOO);}
ans: error ivie by 0ero exception
L=. %oid main(%oid){%oid pa(int *a+int n);int arr[]{+E+=++!};pa(arr+);}
%oid pa(int *a+int n){
int i;for(i";i4n;i)printf(0d 0+*(a)i);}
ans: % % % % %
L=L. const int !"";%oid main(%oid)
{int a[!""];int sum";for(";4!"";)*(a);suma[OO];printf(0d0+sum);
8/11/2019 1000 Ques
192/349
}
ans: error cannot moify a constant obect
L=7. int !"";%oid main(%oid)
{int a[!""];int sum";for(";4!"";)*(a);suma[OO];printf(0d0+sum);
}
ans: HH
L=6. main(){printf(0Mello d0+printf(0_W#GT test? 0));}
ans: VWADC testX 5ello 12
L=A. main(){int i+9+#;for (# O!;#4!; #)printf(0d 0+PP#);}
ans: 1 , 1
LE". main(){int i;printf!=
8/11/2019 1000 Ques
193/349
ans: error lvalue reuire
LE!. main()
{char i 1a1;printf(0c c0+i+(i));}
ans: b b
LE. main(){
int i+9;printf(0_W#GT sBn0+main());}
ans: Ghere is nothing on the screen an progwaits till the memory lasts an then out ofmemory run time error.
LE=. 3define f(x) x*x*x
main(){printf(0Bnd0+f());}
ans: 12
LEE. main(){
%oid fun!(%oid *);char a[] 0Kuar0;%oid *temp;temp a;fun!(temp);}
%oid fun!(%oid *temp! ){
8/11/2019 1000 Ques
194/349
int t! ";while(*((char*)temp! t! )P1B"1) {printf(0c0+*((char*)temp! t!));}
}
ans: uar
LE. %oid main(){int x=;printf(0d d0+x55!+ x44=);}
ans: 1 2$
LEL. %oid main(){int *x;x (int *) !;}
ans: Socation 1% in the program space isassigne to pointer x
LE7. Shich of the followin' functions cannot $e called fromanother file?
a. const %oid func(){ ^^..}$. extern %oid func(){^^^}c. %oid func(){^^^}
d. static %oid func(){^^^.}
ans. static
LE6. int *func(){static int x";
8/11/2019 1000 Ques
195/349
x; return >x;}
int main(){
int * y func();printf(0d 0+(*y));func();printf(0d0+*y);return ";}
ans: 1 3
LEA. %oid main(){unsigne in
Recommended