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...
-----------------------------------------------------------------------------------------------
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?
-----------------------------------------------------------------------------------------------
3.
void main()
{
int d=5;
printf("%f",d);
}
-----------------------------------------------------------------------------------------------
4.
void main()
{
int i;
for(i=1;i<4,i++) s="\12345s\n" i="1;" k=" -1"> k=255; */
signed j=-1; /* char k= -1 => k=65535 */
/* unsigned or signed int k= -1 =>k=65535 */
if(i
printf("greater");
else
if(i==j)
printf("equal");
}
void main()
{
char *s="\12345s\n";
printf("%d",sizeof(s));
}
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
printf("greater");
else
if(i==j)
printf("equal");
}
void main()
{
float j;
j=1000*1000;
printf("%f",j);
}
1. 1000000
2. Overflow
3. Error
4. None
pointers to functions returning pointers to characters?
int f()
void main()
{
f(1);
f(1,2);
f(1,2,3);
}
f(int i,int j,int k)
{
printf("%d %d %d",i,j,k);
}
What are the number of syntax errors in the above?
void main()
{
int i=7;
printf("%d",i++*i++);
}
#define one 0
#ifdef one
printf("one is defined ");
#ifndef one
printf("one is not defined ");
void main()
{
int count=10,*temp,sum=0;
temp=&count;
*temp=20;
temp=∑
*temp=count;
printf("%d %d %d ",count,*temp,sum);
}
main()
{
static i=3;
printf("%d",i--);
return i>0 ? main():0;
}
char *foo()
{
char result[100]);
strcpy(result,"anything is good");
return(result);
}
void main()
{
char *j;
j=foo()
printf("%s",j);
}
void main()
{
char *s[]={ "dharma","hewlett-packard","siemens","ibm"};
char **p;
p=s;
printf("%s",++*p);
printf("%s",*p++);
printf("%s",++*p);
}
main()
{int i=0;
for(i=0;i<20;i++) c="-64;" i="-32" u ="-16;">i)
{printf("pass1,");
if(c<<2,x>>2);
}
main()
{char c=-64;
int i=-32
unsigned int u =-16;
if(c>i)
{printf("pass1,");
if(c<<2,x>>2);
}
#define swap1(a,b) a=a+b;b=a-b;a=a-b;
main()
{
int x=5,y=10;
swap1(x,y);
printf("%d %d\n",x,y);
swap2(x,y);
printf("%d %d\n",x,y);
}
int swap2(int a,int b)
{
int temp;
temp=a;
b=a;
a=temp;
return;
}
main()
{
char *ptr = "Ramco Systems";
(*ptr)++;
printf("%s\n",ptr);
ptr++;
printf("%s\n",ptr);
}
#include
main()
{
char *p1;
char *p2;
p1=(char *) malloc(25);
p2=(char *) malloc(25);
strcpy(p1,"Ramco");
strcpy(p2,"Systems");
strcat(p1,p2);
printf("%s",p1);
}
# define TRUE 0
some code
while(TRUE)
{
some code
}
int x;
struct list *next;
}*head;
the struct head.x =100
Is the above assignment to pointer is correct or wrong ?
int i;
i=1;
i=i+2*i++;
printf(%d,i);
fp1=fopen("one","w")
fp2=fopen("one","w")
fputc('A',fp1)
fputc('B',fp2)
fclose(fp1)
fclose(fp2)
}
Find the Error, If Any?
{int i=10;
j=5;
k=0;
k=MAX(i++,++j);
printf(%d %d %d %d,i,j,k);
}
{
int i=7;
printf("%d",i++*i++);
}
a.a+=1;
b.a*=2;
c.a**=1;
d.a>>=1;
a.malloc
b.calloc
c.new
{
char **p=="Hello";
printf("%s",**p);
}
{
printf("%d%c\n");
printf("%d%c\n");
}
{
int x==5;
printf("%d%d",x++,++x);
}
{
int x==4;
printf("%d",printf(" %d %d ",x,x) );
}
{
union
{
int i;
char p;
struct
{
int t;
char e;
char o;
};
};
printf("%d\n",sizeof(l) );
}
{
int i==0,n==6;
while(n--0);
i+==n;
printf("%d\n",i);
}
What's the value of k?
k= a< a="=" a=" 1;" i="=" i="=" a="e" s="'R';" i="=" a1="=" a2="=" t="¡;" a1="¢;" a2=" t;" s1="=" s2="s1;" temp=" s1;" a1= "new" a2= "dictionary" t="¡;" a1="¢;" a2="t;" s1=" s2;" s2=" s1;" temp=" s1;" p="=">add(dharma) && (*p)->harma)
"harma" (after printing, p->add(hewlett-packard) &&(*p)->harma)
"ewlett-packard"
18. (c)
19. (b)
20. (a)
21. (b)
22. An empty string
23. 57 94
24. 5 20 1
25. 10 5
26. Samco Systems
27. RamcoSystems
28. This won't go into the loop as TRUE is defined as 0
29. Wrong
30. 4
31. no error. But It will over writes on same file.
32. 10 5 0
33. 56
34. ;
35. C
36. C
37. Garbage or nothing
38. Garbage Value
39. 6 6
40. 4 4 5
41. 4
42. -1
43. 0
44. 3
45. 16 21
46. UPPER CASE
47. 5 4 3 2 1
48. (newdictionary)-(dictionarynew)
49. (newdictionary)-(dictionarynew)
50. 50
Categories
- C++ (10)
- Interview (9)
- Questions (9)
- Answers (6)
- C (5)
- constructor (5)
- VC++ (4)
- class (4)
- destructor (4)
- copy constructor (3)
- placement new (3)
- C FAQs (2)
- MFC (2)
- C++ FAQs (1)
- Memory Alignment (1)
- Mutable (1)
- Named Constructor Idiom (1)
- assignment (1)
- bit field (1)
- dangling (1)
- initialization lists (1)
- name mangling (1)
- stack unwinding (1)
- stray pointer (1)
Blog Archive
-
▼
2009
(17)
-
▼
February
(14)
- Part - 2 MFC Interview Questions & Answers
- MFC Interview Questions & Answers
- C Inteview Question
- Interview FAQs : C++ (Answers End of Post)
- Interview FAQs : C (Answers at end of post)
- C++ Interview Questions: Part 9
- C++ Interview Questions: Part 8
- C++ Interview Questions: Part 7
- C Interview Questions : Part 6
- Constructors And Destructors
- C++ Interview Questions: Part 4
- C++ Interview Questions: Part 3
- C++ Interview Questions: Part 2
- C++ Interview Questions: Part 1
-
▼
February
(14)
Most Popular Links
About Me
Wednesday, February 11, 2009
Interview FAQs : C (Answers at end of post)
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment