c&cpp - C / C+ Questions 1. Base class has some...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
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. Derived method. . Ans. b 2. For the following C program #define AREA(x)(3.14*x*x) main() {float r1=6.25,r2=2.5,a; a=AREA(r1); printf("\n Area of the circle is %f", a); a=AREA(r2); printf("\n Area of the circle is %f", a); } What is the output? Ans. Area of the circle is 122.656250 Area of the circle is 19.625000 3. What do the following statements indicate. Explain. int(*p)[10] int*f() int(*pf)() int*p[10] Refer to: -- Kernighan & Ritchie page no. 122 -- Schaum series page no. 323 4. void main() { int d=5; printf("%f",d); } Ans: Undefined 5. void main() { int i; for(i=1;i<4,i++) switch(i) case 1: printf("%d",i);break; { case 2:printf("%d",i);break;
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
case 3:printf("%d",i);break; } switch(i) case 4:printf("%d",i); } Ans: 1,2,3,4 6. void main() { char *s="\12345s\n"; printf("%d",sizeof(s)); } Ans: 6 7. void main() { unsigned i=1; /* unsigned char k= -1 => k=255; */ signed j=-1; /* char k= -1 => k=65535 */ /* unsigned or signed int k= -1 =>k=65535 */ if(i<j) printf("less"); else if(i>j) printf("greater"); else if(i==j) printf("equal"); } Ans: less 8. void main() { float j; j=1000*1000; printf("%f",j); } 1. 1000000 2. Overflow 3. Error 4. None Ans: 4 9. How do you declare an array of N pointers to functions returning pointers to functions returning pointers to characters?
Background image of page 2
Ans: The first part of this question can be answered in at least three ways: 1. char *(*(*a[N])())(); 2. Build the declaration up incrementally, using typedefs: typedef char *pc; /* pointer to char */ typedef pc fpc(); /* function returning pointer to char */ typedef fpc *pfpc; /* pointer to above */ typedef pfpc fpfpc(); /* function returning. .. */ typedef fpfpc *pfpfpc; /* pointer to. .. */ pfpfpc a[N]; /* array of. .. */ 3. Use the cdecl program, which turns English into C and vice
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 06/08/2010 for the course IIM CAT taught by Professor Cat during the Spring '06 term at Indian Institute Of Management, Ahmedabad.

Page1 / 11

c&amp;amp;cpp - C / C+ Questions 1. Base class has some...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online