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()
{
Ans:
3.void main() {
int d=5;
printf("%f",d);
}
Ans: Undefined
4.void main()
{
int i;
for(i=1;i<4,i++)
switch(i)
case 1: printf("%d",i);break;
{
case 2:printf("%d",i);break;
case 3:printf("%d",i);break;
}
switch(i)
Ans: 1,2,3,4
5.void main() {
char *s="\12345s\n";
printf("%d",sizeof(s));
}
Ans: 6
6.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
7.void main() {
float j;
j=1000*1000;
printf("%f",j);
}
1. 1000000
2. Overflow
3. Error
4. None
Ans: 4
8.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?
Ans: None.
9.void main()
10.#define one 0
11.void main()
12.what is alloca()
13.main()
14.char *foo()
a. Base method
b. Derived method..
Ans: b
#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?
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
int d=5;
printf("%f",d);
}
Ans: Undefined
{
int i;
for(i=1;i<4,i++)
switch(i)
case 1: printf("%d",i);break;
{
case 2:printf("%d",i);break;
case 3:printf("%d",i);break;
}
switch(i)
case 4:printf("%d",i);
}
}
Ans: 1,2,3,4
5.void main() {
char *s="\12345s\n";
printf("%d",sizeof(s));
}
Ans: 6
6.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
float j;
j=1000*1000;
printf("%f",j);
}
1. 1000000
2. Overflow
3. Error
4. None
Ans: 4
{
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?
Ans: None.
9.void main()
{
int i=7;
printf("%d",i++*i++);
}
Ans: 56
int i=7;
printf("%d",i++*i++);
}
Ans: 56
#ifdef one
printf("one is defined ");
#ifndef one
printf("one is not defined ");
printf("one is defined ");
#ifndef one
printf("one is not defined ");
Ans: "one is defined"
{
int count=10,*temp,sum=0;
temp=&count;
*temp=20;
temp=∑
*temp=count;
printf("%d %d %d ",count,*temp,sum);
}
Ans: 20 20 20
int count=10,*temp,sum=0;
temp=&count;
*temp=20;
temp=∑
*temp=count;
printf("%d %d %d ",count,*temp,sum);
}
Ans: 20 20 20
Ans : It allocates and frees memory after use/after getting out of scope
{
static i=3;
printf("%d",i--);
return i>0 ? main():0;
}
Ans: 321
static i=3;
printf("%d",i--);
return i>0 ? main():0;
}
Ans: 321
{
char result[100]);
strcpy(result,"anything is good");
return(result);
}
void main()
{
char *j;
j=foo()
printf("%s",j);
}
Ans: anything is good.
char result[100]);
strcpy(result,"anything is good");
return(result);
}
void main()
{
char *j;
j=foo()
printf("%s",j);
}
Ans: anything is good.
No comments:
Post a Comment