You are on page 1of 4

COIMBATORE INSTITUTE OF TECHNOLOGY ,COIMBATORE

M.Sc ( SOFTWARE ENGINEERING ) 3

rd

YEAR

C APTITUDE -- TEST 1
1>

main()
{

int i=3,j;
j=i+++i++;
printf("%d",j);
A)

B) 4

C)

D)

2>

main()
{
char s[ ]="man";
for(i=0;s[ i ];i++)

int i;
printf("%c%c%c%c",s[ i ],*(s+i),*(i+s),i[s]);

A) Invalid indirection
mmmmaaaa

B) mmmmaaaannnn

C) some garbage values

D)

3>

main()
{
int i=32,j=0x20,k,l,m;
k=i|j;
l=i&j;
m=k^l;
printf("%d %d %d %d %d",i,j,k,l,m);
4>

A) 32 32 32 32 0

main()
{
int i=10;
Printf ("i=%d",i);
5>

main()
{

6>

A) 1

B) 14

B) 20 20 20 20 20

C) 1 1 1 1 0

i=!i>14;
}
C) 10

D) 0

// &a=65502
int a[3][4];
int *p;
p=(int *)a;
q=a;
p++;
q++;
printf("\n%u %u",p,q);
}
A) 65504 65504

int (*q)[4];

B) error

C) 65504 65510

main()
{
int i=5;
printf("%d%d%d%d%d",i++, i--,++i,--i,i);
7>

A) 45545

B) 65655

void main(void)
{
struct a
{
char ch[7];
} s={"look","moon"};
printf("%c",*++s.kl);
}
8>

A ) Error

D) 20 32 32 20 0

B) o

C) n

C) 56655

D) 65504 65508

D) 45455

char *kl;

D) p

void main()
{
char far *farther,*farthest;
printf("%d..%d..%d..%d",sizeof(farther),sizeof(farthest) ,
sizeof(*farthest) ,sizeof(*farther) ) ;
}
A)

4..4..2..1

B)

4..4..1..1

C)

9>

static struct top l={"waste",123};


1

1..1..1..1

D)

4..2..1..1

void main()
{
struct hj
{
char h[10];
int j;
}*p;
p=&l;
printf("\n%s %d",p->h,p->j);

A) waste 123
B) Compiler Error: top undefined structure
cannot be assigned to any other structure
D)garbages

C) structure pointer

10>

main()
{
int i;
printf("%d",scanf("%d",&i)); // value 10 is given as input here
A) 1

11>

B) 10

C) compiler error

#define f(g,g2) g##g2


main()
{
int var12=100;
printf("%d",f(var,12));

D) 0

E) garbage values

A) undefined symbol 'var'

B) garbage value

C) 100

D) '##' does have no

12>

effect

main()
{

int i=3,j=2;
j++;
switch(i)
{
case 1:
printf("CIT");
case j:
printf("cIt");
default:
printf("hi");
} }
A) CIT

13>

break;
break;
break;

B) Compiler Error

C) cIt

D) hi

main()
{
char *p;
p="%d\n";
p++;
p++;
printf(p-2,300);
}
A) Garbage value
14>

B) %, 300

C>Arguments to printf not plausible one

D) 300

main()
{
char *str1="abcd";
char str2[]="abcd";
printf("%d %d %d",sizeof(str1),sizeof(str2),sizeof("abcd"));
15>

A) 4 4 4

B) 2 5 5

C) 5 5 5

void main()
{
int i=0;
for(;if(i<=32);++i);
}
16>

A) 0 1.................. 32

void main ( )
{
unsigned int c =- +-+-+1;
printf("%d",(unsigned)c);
17>

A) -1

D) 2 4 4

printf("%d",i);
B) error

C) 0

D) 33

B) Lvalue required

C) Expression Syntax

void main()
{
2

D) 1

E ) 65535

unsigned int i= -5;


printf("%u++--..\b ",i);
i=- +-+--+i;
printf("%u ",(unsigned)i);
printf("%d",i);

A) 65531++--.. 65530 -5
B) -5++--. -6 -6
D) -5++--..b -6 -6
E) expression syntax

C)65531++--.

65530 -6

18>

main()
{
char s[]={'a','b','c','\n','c','\0'};
char *p,*str,*str1;
p=&s[3];
str=p;
str1=s;
printf("%d",++*p+++*str1-32);
}
A) 79

B) 65

C) garbage value

D) 77

19>

void main()
{
struct num_name{int no;
char name[25];
};struct num_name n1[]={{12,"find"},{15,"matrix"},{8,"pick"} };
printf("%d %d",n1[2].no,(*(n1+2)).no+1);
}
A) 8

78

B) 8

C) 8

D) 8

79

20>

void main()
{
unsigned int i = 10;
while (i>=0)
{
printf("C APTITUDE IS A DAMN
}
}

& BUGS!! ");

A) 11 times the string gets printed


B) none of these
on & on
D) 10 times the string gets printed properly

i --;

C) infinitely goes

21>

main()
{
char c = -64;
int i = -32;
if (c > i)
printf ("pass1");
else
printf ("fail");
if (i < u) printf ("pass2");
else
printf ("fail2");
}

unsigned int u = -16;

A) Error gets flashed stating a character constant cannot be assigned a -ve value
pass1fail2
C) pass1pass2 D) failpass2
22 >

main()
{
unsigned char i=-0x80;
printf("%d",i<<1<<1<<1);
}
A) -1024

B) 1024

C) 1

D) 2048

23>

main()
{
static int var = 5;
3

B)>

printf("%d ",var--);
if(var) { main(); }
}
A)

54321

B) main function cannot be recursive

C) 4 3 2 1 0

D) 5

24>

main()
{

struct xx
{
int x;
struct yy
{
char s;
struct xx *p;
};
struct yy *q;
};

Your Answer:

Explain whether the nested-structure declaration is correct or not .Give Reason.

25>

char * f()
{
char *s = malloc(8);
strcpy(s,"goodbye");
}
main()
{
char *f();
printf("\n %d",*f()=10);
}
A) address value of 'f()' gets printed
D) Syntax error

B) Error in initializing a function C) 10