com
C,C++ Questions
1. Base class has some virtual method and derived class has a method with the same name. If we initialize the base class pointer with derived object,. calling of that virtual method will result in which method being called a. Base method b. !erived method.. "ns. b #. $or the following C program %define "&'"()*(+.1,-)-)* main(* .float r1/0.#1,r#/#.1,a2 a/"&'"(r1*2 printf(34n "rea of the circle is 5f3, a*2 a/"&'"(r#*2 printf(34n "rea of the circle is 5f3, a*2 6 7hat is the output "ns. "rea of the circle is 1##.010#18 "rea of the circle is 19.0#1888 +. 7hat do the following statements indicate. ')plain. int(-p*:18; int-f(* int(-pf*(* int-p:18;
<- function returning pointer to integer <- pointer to a function returning to integer
&efer to= >> ?ernighan @ &itchie page no. 1## >> Achaum series page no. +#+ ,. void main(* . int d/12 printf(35f3,d*2 6 "ns= Bndefined
1. void main(* . int i2 for(i/12iC,,i++* switch(i*. case 1= printf(35d3,i*2breaD2 case #=printf(35d3,i*2breaD2 case +=printf(35d3,i*2breaD2 case ,=printf(35d3,i*2 6 "ns= 1,#,+,, 6
E. void main(* . unsigned i/12 <- unsigned char D/ >1 /F D/#112 -< signed j/>12 <- char D/ >1 /F D/011+1 -< <- unsigned or signed int D/ >1 /FD/011+1 -< if(iCj* printf(3less3*2 else if(iFj* printf(3greater3*2 else if(i//j* printf(3eGual3*2 6 "ns= less
9. Kow do Lou declare an arraL of J pointers to functions returning pointers to functions returning pointers to characters "ns= Mhe first part of this Guestion can be answered in at least three waLs= 1. char -(-(-a:J;*(**(*2 #. Build the declaration up incrementallL, using tLpedefs= tLpedef char -pc2 <- pointer to char -< tLpedef pc fpc(*2 <- function returning pointer to char -< tLpedef fpc -pfpc2 <- pointer to above -< tLpedef pfpc fpfpc(*2 <- function returning... -< tLpedef fpfpc -pfpfpc2 <- pointer to... -< pfpfpc a:J;2 <- arraL of... -< +. Bse the cdecl program, which turns 'nglish into C and vice versa= cdeclF declare a as arraL of pointer to function returning pointer to function returning pointer to char char -(-(-a:;*(**(* cdecl can also e)plain complicated declarations, help with casts, and indicate which set of parentheses the arguments go in (for complicated function definitions, liDe the one above*. "nL good booD on C should e)plain how to read these complicated C declarations 3inside out3 to understand them (3declaration
Freshersworld.com Resource Center
11. In the above Guestion an arraL of pointers is declared. 7rite the statement to initialize the +rd element of the # element to 182
1#. int f(*2 void main(* . f(1*2 f(1,#*2 f(1,#,+*2 6 f(int i,int j,int D* . printf(35d 5d 5d3,i,j,D*2 6 7hat are the number of sLnta) errors in the above "ns= Jone.
1,. %define one 8 %ifdef one printf(3one is defined 3*2 %ifndef one printf(3one is not defined 3*2
11. void main(* . int count/18,-temp,sum/82 temp/@count2 -temp/#82 temp/@sum2 -temp/count2 printf(35d 5d 5d 3,count,-temp,sum*2 6 "ns= #8 #8 #8 10. Mhere was Guestion in c worDing onlL on uni) machine with pattern matching. 1,. what is alloca(* "ns = It allocates and frees memorL after use<after getting out of scope
1E. main(* . static i/+2 printf(35d3,i>>*2 return iF8 main(*=82 6 "ns= +#1
1H. char -foo(* . char result:188;*2 strcpL(result,3anLthing is good3*2 return(result*2 6 void main(* . char -j2 j/foo(* printf(35s3,j*2
Freshersworld.com Resource Center
19. void main(* . char -s:;/. 3dharma3,3hewlett>pacDard3,3siemens3,3ibm362 char --p2 p/s2 printf(35s3,++-p*2 printf(35s3,-p++*2 printf(35s3,++-p*2 6 "ns= 3harma3 (p>Fadd(dharma* @@ (-p*>Fharma* 3harma3 (after printing, p>Fadd(hewlett>pacDard* @@(-p*>Fharma* 3ewlett>pacDard3 #8. Iutput of the following program is main(* .int i/82 for(i/82iC#82i++* .switch(i*. case 8=i+/12 case 1=i+/#2 case 1=i+/12 default i+/,2 breaD26 printf(35d,3,i*2 6 6 a* 8,1,9,1+,1E b* 1,9,1+,1E c* 1#,1E,## d* 10,#1 e* ALnta) error "ns. (d* #1. 7hat is the ouptut in the following program main(* .char c/>0,2 int i/>+# unsigned int u />102 if(cFi*
Freshersworld.com Resource Center
#9 $ind the output for the following C program main(* . char -ptr / 3&amco ALstems32 (-ptr*++2
Freshersworld.com Resource Center
+8 $ind the output for the following C program %includeCstdio.hF main(* . char s1:;/3&amco32 char s#:;/3ALstems32 s1/s#2 printf(35s3,s1*2 6 "ns. Compilation error giving it cannot be an modifiable TlvalueT
+1 $ind the output for the following C program %includeCstdio.hF main(* . char -p12 char -p#2 p1/(char -* malloc(#1*2 p#/(char -* malloc(#1*2 strcpL(p1,3&amco3*2 strcpL(p#,3ALstems3*2 strcat(p1,p#*2 printf(35s3,p1*2 6 "ns. &amcoALstems
+#. $ind the output for the following C program given that :1;. Mhe following variable is available in file1.c static int averageUfloat2 "ns. "ll the functions in the file1.c can access the variable
++. $ind the output for the following C program % define M&B' 8 some code
Freshersworld.com Resource Center
10
11
+9. %define N"J(),L* ()*F(L* ()*=(L* .int i/182 j/12 D/82 D/N"S(i++,++j*2 printf(5d 5d 5d 5d,i,j,D*2 6 "ns. 18 1 8 ,8. void main(* . int i/E2 printf(35d3,i++-i++*2 6 "ns= 10
12