Professional Documents
Culture Documents
{
int a=3, b = 5;
printf(&a["Ya!Hello! how is this? %s\n"], &b["junk/super"]);
printf(&a["WHAT%c%c%c %c%c %c !\n"], 1["this"],
2["beauty"],0["tool"],0["is"],3["sensitive"],4["CCCCCC"]);
}
2) #include<stdio.h>
int main()
{
int i=0;
printf("%d ",sizeof(++i));
printf("%d ",sizeof(++i));
printf("i=%d\n",i);
return 1;
}
3)#include<stdio.h>
int main()
{
unsigned int x=-1;
int y;
y = ~0;
if(x == y)
printf("same");
else
printf("not same");
return 1;
}
a) same
b) not same
c) warning & same
d) warning & notsame
4) int main()
{
short volatile i=0;
scanf("%ol",&i);
printf("\n%ld\n",i);
return 0;
}
what is the output if input is 258?
a) 258 b) 25 c) 21 d) none
of these
main()
{
error g1;
g1=1;
printf("%d",g1);
}
a) 1
b) Error in g1=1;
7) main()
{
char p[]="String";
int x=0;
if(p=="String")
{
printf("pass 1");
if(p[sizeof(p)-2]=='g')
printf("pass 2");
else
printf("fail 2");
}
else
{
printf("fail 1");
if(p[sizeof(p)-2]=='g')
printf("pass 2");
else
printf("fail 2");
}
}
8) #include<string.h>
main()
{
char strp[] = "Never ever say no";
char *chp, c='e';
int i,j;
chp = strrchr(strp, c);
i = chp-strp;
for(j=0;j<=i;j++)
printf("%c",strp[j]);
}
a) Never eve
b) Never say
d) error
9) #include<stdio.h>
int main()
{
int a[0]={0,1,2,3};
a[-1]=2;
printf("%d %d %d %d%d�,
sizeof(a),a[1]d",sizeof(a),a[1],sizeof(a[2]),a[3],a[1]);
return 0;
}
a) 0 garbage 4 3 0
b) 16 2 4 3 0
c) 0 2 4 garbage garbage
d) error
10) #include<stdio.h>
static struct s{
unsigned a:5;
unsigned b:5;
unsigned c:5;
unsigned d:5;
}v={1,2,3,4};
main()
{
printf("size of v = %d",sizeof(v));
}
a)size of v = 2 b)size of v = 4
c)size of v = 8 d)size of v = 6
11) main()
{
int p;
for(p = 1; p<=10 , --p; p=p+2)
puts("Hello");
}
12) main()
{
char arr[50];
scanf("%[^\n]",arr);
printf("%10.5s",arr);
printf("\n%-10.5s",arr);
printf("%10.-5s",arr);
}
a)This b) This
ThisThis This %10.-5s
c) This d) This
This %10.05a This This10.-5s
13) main()
{
int i;
scanf("%*s%n",&i);
printf("%d",i);
}
14) main()
{
printf("MCA");
printf("\a\b\c\\0CD");
printf("\n\0NITT");
printf("WEL\rCOME");
}
a) MCA\a\b\c\0CD b)MCc\0CD
NITTWEL WEL
COME
15) main()
{
int a[5]={1,3,6};
int *b;
b=&a[4];
printf("%d %d",a[4],b[-2]);
}
16) struct a{
float a;
char b;
struct a *anext;
};
struct b{
int c;
double d;
struct a *e;
struct b *bnext;
}*head;
main()
{
head=(struct b*)malloc(sizeof(struct b));
printf("%d",sizeof(*head));
head->e=(struct a*)malloc(sizeof(struct a));
printf("\n%d",sizeof(*head));
head->bnext=(struct b*)malloc(sizeof(struct b));
printf("\n%d",sizeof(*head));
head->bnext->e=(struct a*)malloc(sizeof(struct a));
printf("\n%d",sizeof(*head));
}
a) G.P
b) A.P
c) constant
d) error
main()
{
enum tag{abc=1,bcd=4,efg,xyz=-7};
printf("%d %d %d",efg,sizeof(bcd),sizeof(enum tag));
}
a) 5 4 16 b) 5 4 4 c) 5 2 8 d) 5 4 2
a)11
b)12
c)21
d)22
int main()
{
u.s.x=12;
printf("%d%d",u.s.x,u.s.y);
}
a)12 12
b)12 garbage
c)12 0
d)none of these
21) #include<stdio.h>
int main()
{
char str[0]="wow";
wow(4,4.5,'e',str);
return 0;
}
wow()
{
printf("Wow!!! What a Function");
}
22)main(void)
{
int i=8;
printf("Well done.\n%n",&i);
printf("%s %d","All the best",i);
}
a)Well done.
All the best
b)Well done.
All the best 8
c)Well done.
All the best 11
d)Well done.
-1073752156All the best 8
23)#include <iostream>
using namespace std;
class moo
{
public:
moo()
{
cout<<\"moo::moo()\\n\";
}
moo(int i)
{
cout<<\"moo::moo(int)\\n\";
}
~moo()
{
cout<<\"moo::~moo()\\n\";
}
};
void main()
{
moo m;
m = 10;
}
a) moo::moo()
moo::moo(int)
moo::~moo()
moo::~moo()
b) moo::moo()
moo::~moo()
moo::~moo()
c) moo::moo()
moo::moo(int)
moo::~moo()
d) moo::moo()
moo::~moo()
24)#include <iostream>
using namespace std;
class integer
{
int i;
}
main()
{
cout<<"Version ";
cout<<"2003";
}
a)Version 2003
c)Version
d)Error
class integer
{
int i;
public:
integer(int a)
{
i=a;
}
void get_int()
{
cout<<"Enter an integer : ";
cin>>i;
}
void put_int()
{
cout<<i;
}
void operator ++()
{
i++;
}
};
int main()
{
integer i;
i.get_int();
i++;
i.put_int();
return 0;
}
a)100
b)101
d)error
26)#include <iostream>
using namespace std;
class integer
{
int i;
public:
integer()
{
i=0;
}
int &add(int a)
{
int &sum=i;
i+=a;
return ∑
}
};
int main()
{
integer a1;
int &result=a1.add(10);
cout<<result;
return 0;
}
a)10
b)20
c)garbage
d)error
class base1
{
public :
void fun()
{
cout<<"base1";
}
};
class base2
{
public:
void fun()
{
cout<<"base2";
}
};
int main()
{
derieved d;
d.fun();
}
a)base1
b)base2
c)base1base2
d) Error
class index
{
private:
int count;
public:
index()
{
count = 0;
}
int main()
{
class index b;
cout<<b++;
cout<<++b;
}
a)0 1
b)0 2
c)1 2
d)error
29)
#include<iostream>
using namespace std;
int main()
{
char *ch1="Hello";
const char *ch2="Bye";
display(ch1);
display(ch2);
return 0;
a)1Hello1Bye
b)1Hello2Bye
c)2Hello2Bye
d)Error
class integer
{
public:
int i;
int &fun()
{
i=2;
return i;
}
};
int main()
{
integer a;
a.fun()=2003;
cout<<a.i;
}
a)2003
b)2
c)error
d)none of these