1)
Point out the error, if any, in
the following program.
#include<stdio.h>
main()
{
int i=1,j=2;
switch(i)
{
case 1:
printf(“Good”);
break;
case j:
printf(“Bad”);
break;
}
}
(a) Error (b)Good (c)Bad (d)GoodBad
ANS :(a)Error
2)
Find the output for the given
program.
#include<stdio.h>
main()
{
int i=4z=12;
if(i=5&&z>5)
printf(“\nLet us
C”);
else
printf(“\nwish C
was free”);
}
(a)Let us C (b)wish C was
free (c)Error (d)No output
ANS :(a)Let us C
3)
What would be the output of the
given program?
#include<stdio.h>
main()
{
int big,a,b,c;
a=2,b=3,c=4;
big=(a>b?(a>c?3:4):(b<c?6:8));
printf(“%d”,big);
}
(a)Error (b)3 (c)6 (d)8
ANS :(d)8
4)
Find the output for the given
program.
#include<stdio.h>
main()
{
extern int i;
i=20;
printf(“%d”,i);
}
(a)20 (b)Compile Error (c)0 (d)Linker
Error
ANS :(d)Linker Error
5)
What would be the output for
the given program?
#include<stdio.h>
main()
{
int a=10,*j;
void *k;
j=k=&a;
j++;
k++;
printf(“\n%u%u”,j,k);
}
(a)10,11 (b)0 (c)Linker Error (d)Compiler Error
ANS :(d)Compiler Error
6)
Check out the answer for the given
program.
#include<iostream.h>
main()
{
int x=77;
float y=5.1252;
char z=’A’;
char city[15];
cout<<”x=”<<(char)x<<endl;
cout<<”y=”<<(int)y<<endl;
cout<<”z=”<<(int)z;
}
(a)65,5,M (b)M,5,65 (c)Compiler Error (d)Linker Error
ANS :(b)M,5,65
7)
What would be the output of the
following program?
#include<stdio.h>
#define PRODUCT(X) (X*X)
void main()
{
int i=3,j,k;
j=PRODUCT(i++);
k=PRODUCT(++i);
printf(“\n%d%d”,j,k);
}
(a)3,4 (b)9,9 (c)49,5 (d)9,49
ANS :(d)9,49
8)
Find the output for the given
program.
#include<stdio.h>
main()
{
int i=10;
i=!i>14;
printf(“i=%d”,i);
}
(a)i=13 (b)i=10 (c)i=0 (d)No output
ANS :(c)i=0
9)
Find the output for the given
program.
#include<stdio.h>
main()
{
int k=35,*z,*y;
z=&k;
y=z;
*z++=*y++;
k++;
printf(“k=%d z=%d y=%d”,k,z,y);
}
If suppose address of k is 1000. what is the value of k,z,y?
(a)k=36 z=-10 y=-10 (b)k=1010
z=1012 y=35
(c)k=1012 z=1010 y=1008 (d)None
ANS :(a)k=36 z=-10 y=-10
10)
Find the answer for the
following program.
#include<iostream.h>
void main()
{
char c;
cout<<”Enter
text(press F6 to end)”;
while(cin.get())
{
if(c==’s’)
cin.putback(‘s’);
cout.put(c);
}
return 0;
}
If input is “cplusplus”
(a)cpluss (b)Error (c)No output (d)cplusspluss
ANS :(d)cplusspluss
11)
Find out the output for the
given program.
#include<stdio.h>
main()
{
int a=2,*f1,*f2;
f1=f2=&a;
*f2+=*f2+=a+=2.5;
printf(“\n%d%d%d”,a,*f1,*f2);
}
(a)2.5,2.5,2.5 (b)16.5,16.5,16.5 (c)15.5,15.5,15.5 (d)16,16,16
ANS :(d)16,16,16
12)
What would be the output for
the following program?
#include<stdio.h>
main()
{
int i=300;
char *ptr=&i;
*++ptr=2;
printf(“%d”,i);
}
(a)302 (b)119 (c)556 (d)298
ANS :(c)556
13)
Find the output for the
following program.
#include<iostream.h>
main()
{
char text[20];
int len;
cout<<”Enter
text:”;
cin.getline(text,20);
len=cin.getcount();
cout<<len;
}
If text is virtual, what is ouput of len?
(a)6 (b)7 (c)8 (d)Error
ANS :(c)8
14)
Find the output of the
following program.
#include<stdio.h>
main()
{
enum
colors{BLACK,BLUE,GREEN};
printf(“%d..%d..%d”,BLACK,BLUE,GREEN);
}
(a)0..1..2 (b)2..5..6 (c)Undeclared variables (d)None
ANS:(a)0..1..2
15)
What would be the output for
the following program?
#inlcude<stdio.h>
main()
{
int i;
printf(“%d”,scanf(“%d”,&i));//value
10 is given as input
}
(a)1 (b)10 (c)Linker Error (d)Compiler Error
ANS :(a)1
16)
What would be the output for
the following program?
#include<iostream.h>
main()
{
unsigned int=65536;
cout<<”x=”<<x;
}
(a)0 (b)Garbagevalue (c)Error (d)65536
ANS :(a)0
17)
What is the output for the
given program?
#include<stdio.h>
main()
{
int i=10;
i=i>14;
printf(“\n%d”,i);
}
(a)1 (b)10 (c)0 (d)14
ANS :(c)0
18)
Find the output of the
following program.
#include<stdio.h>
main()
{
char not;
not=!2;
printf(“%d”,not);
}
(a)1 (b)0 (c)Error (d)No output
ANS :(b)0
19)
What would be the output for
the given program?
#include<iostream.h>
void main()
{
int a=2,*pa,*ra;
pa=&a;
ra=a;
cout<<”a=”<<a<<”*pa=”<<*pa<<”ra=”<<ra;
}
(a)Compiler Error (b)Linker
Error (c)No output
(d)None of this
ANS :(a)Compiler Error
20)
What is the output of the
following program?
#include<stdio.h>
main()
{
int i;
i=1;
i=i+2 * i++;
printf(“%d”,i);
}
(a)5 (b)2 (c)4 (d)3
ANS :(c)4
21)
What would be the output of the
following program?
#include<stdio.h>
main(0
{
char *str1=”abcd”;
char *str2=”abcd”;
printf(“%d%d%d”,sizeof(str1),sizeof(str2),sizeof(“abcd”));
}
(a)144 (b)244 (c)255 (d)155
ANS :(c)255
22)
Find the output for the given
program.
#include<stdio.h>
main()
{
int c=--2;
printf(“c=%d”,c);
}
(a)c==-2 (b)c=2 (c)Error (d)Garbage value
ANS :(c)Error
23)
What would be the output of the
given program?
#include<stdio.h>
main()
{
int i,j
for(i=0;i<=10;i++)
{
j+=5;
assert(i<5);
}
}
(a)Linking Error (b)Compiler
Error (c)No output (d)Runtime Error
ANS :(a)Linking Error
24)
Find the output for the given
program.
#include<stdio.h>
main()
{
char *p=”hai
friends”,*p1;
p1=p;
while(*p!=’/0’)++*p++;
printf(“%s%s”,p,p1);
}
(a)Error (b)ibj!gsjfoet (c)No
output (d)None of these
ANS :(c)No output
25)
What would be the output for
the given program?
#include<stdio.h>
#include<conio.h>
main()
{
clrscr();
printf(“%d\n”,clrscr());
}
(a)Error (b)100 (c)Compiler Error (d)Infinite Loop
ANS :(b)100
26)
Check out the answer for the
given program.
#include<stdio.h>
main()
{
printf(“\nab”);
printf(“\bsi”);
printf(“\nrna”);
}
(a)hai (b)absina (c)ab sina (d)sp
abha
ANS :(a)hai
27)
What would be the output of the
following program?
#include<stdio.h>
void main()
{
while(1)
{
if(printf(“%d”,printf(“%d”)))
break;
else
continue;
}
(a)0 (b)2 (c)1 (d)Garbagevalue
ANS :(d)Garbagevalue
28)
Find the output for the given
program.
#include<stdio.h>
void main()
{
void *v;
int integer=2;
int
*i=&integer;
v=i;
printf(“%d”,(int*)*v);
}
(a)2 (b)0 (c)Compiler Error (d)Linker Error
ANS :(c)Compiler Error
29)
Find the output for the given
program.
#include<stdio.h>
main()
{
int i=257;
int *iPtr=&i;
printf(“%d%d”,*((char*)iPtr),*((char*)iPtr+1));
}
(a)10,11 (b)257,257 (c)257,752 (d)1,1
ANS :(d)1,1
30)
Find the answer for the
following program.
#include<stdio.h>
main()
{
int
y[4]={6,7,8,9};
int *ptr=y+2;
printf(“%d\n”,ptr[1]);
}
(a)6 (b)7 (c)8 (d)9
ANS :(d)9
*******Thank you for reading and All the best**************
Your comments will help me a lot...please give your comments which will encourage me to post more.....
No comments:
Post a Comment
Thanks for your valuable comments