Monday, January 5, 2009

SATYAM PLACEMENT QUESTION on c and c++ prgramming language

(1)Which of following operator can't be overloaded.
a)==

b) ++

c) ?!

d) <=

Q2. For the following C program
#include

void main()

{

printf("Hello World");

}
3. For the following C program:
swap(int x,y)

{

int temp;

temp=x;

x=y;

y=temp;

}
main()

{

intx=2;

y=3;

swap(x,y);

}
After calling swap, what are the values x & y?
4. For the following C program
struct base

{

int a,b;

base();

int virtual function1();

}
struct derv1:base

{

int b,c,d;

derv1();

int virtual function1();

}
struct derv2 : base

{

int a,e;

}

base::base()

{

a=2;

b=3;

}

derv1::derv1()

{

b=5;

c=10;

d=11;

}

base::function1()

{

return(100);

}

derv1::function1()

{

return(200);

}
void main()

{

base ba;

derv1 d1,d2;

printf("%d %d",d1.a,d1.b);

}
Output of the program is:
a)a=2;b=3;

b) a=3; b=2;

c) a=5; b=10;

d) none
5. For the above program answer the following q's
voidmain()

{

base da;

derv1 d1;

derv2 d2;

printf("%d %d %d",da.function1(),d1.function1(),d2.function1());

}
Output is:
a)100,200,200;

b) 200,100,200;

c) 200,200,100;

d) None of the above
6. For the following C program
struct

{

int x;

int y;

}abc;
x cannot be accessed by the following
1)abc-->x;

2)abc[0]-->x;

3)abc.x;

4)(abc)-->x;
a )1, 2, 3

b) 2 & 3

c) 1 & 2

d) 1, 3, 4

No comments:

Blog List