1) main()
{
extern int i;
i=20;
printf("%d",i);
}
a)20 b)no output c)compilation error d) none of these
2) main()
{
char *p;
printf("%d %d ",sizeof(*p),sizeof(p));
}
a) 1 2 b) 2 1 c) 1 1 d) 2 2
3) what is the output of following code
void e(int);
main()
{
int a;
a=3;
e(a);
}
void e(int n)
{
if(n>0)
{
e(n--);
printf("%d",n);
e(--n);
}
}
a) 0 1 2 1 b) 0 1 2 0 c) 12 0 1 d) 0 2 1 1
4) output for this program is....
main()
{
char *p;
char buff[10]= {1,2,3,4,5,6,9,8};
p= (buff+1)[5];
printf("%d",p);
a)5 b) 9 c) 6 d)none of these
5) main()
{
int i;
printf("%d",scanf("%d",&i)); // value 10 is given as input here
}
a) 1 b) 10 c) &i d) null
6) #include
void main()
{
union a
{
int i;
char ch[2];
};
union a u;
u.ch[0]= 3;
u.ch[1]= 2;
printf("%d %d %d",u.ch[0],u.ch[1],u.i);
}
a) 3 2 515 b)515 2 3 c) 3 2 5 d) none of these
7) int aaa() {printf(“Hi”);}
int bbb(){printf(“hello”);}
int ccc(){printf(“bye”);}
main()
{
int ( * ptr[3]) ();
ptr[0] = aaa;
ptr[1] = bbb;
ptr[2] =ccc;
ptr[2]();
}
a) Hi b) hello c) bye d)Type mismatch in redeclaration
8) void main()
{
int const * p=5;
printf("%d",++(*p));
}
a) 5 b) 6 c) &p d) compiler error
9) main()
{
struct student
{
char name[30];
struct date dob;
}stud;
struct date
{
int day,month,year;
};
scanf("%s%d%d%d", stud.rollno, &student.dob.day, &student.dob.month, &student.dob.year);
}
a) It scans perfectly with error b) scanf format is incorrect c) No Error d) compilation Error
10) main()
{
int i=4,j=7;
j = j || i++ && printf("YOU CAN");
printf("%d %d", i, j);
}
a) 4 1 b) Incorrect compound condition c) 4 7 d) No output
11) main()
{
int a=2,*f1,*f2;
f1=f2=&a;
*f2+=*f2+=a+=2.5;
printf("\n%d %d %d",a,*f1,*f2);
}
a) 16 16 16 b) 16 16 c) 2 16 16 d) 2.5 16 16
12) main()
{
float f=5,g=10;
printf("%f\n",f<<2);
printf("%lf\n",g%f);
}
a) 20 0 b) left shift cannot be applied to float c) mod operation cannot be applied to float d) both b and c
13) main()
{
enum{i=10,j=20,k=50};
printf("%d\n",++k);
}
a) 50 b) 51 c) No Error d) Error: constant value cannot
be incremented.
14) main()
{
int *j;
{
int i=10;
j=&i;
}
printf("%d",*j);
}
a)10 b) syntax error c) garbage value d) No Error & No output
15)#define int char
main()
{
int i=65;
printf("sizeof(i)=%d",sizeof(i));
}
a) sizeof(i)=1 b)sizeof(i)=2 c)sizeof(i)=65 d)Error
16) #include‹stdio.h›
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) 98 b)11 c) 22 d) 77
17) #include‹stdio.h›
main()
{
int a[2][2][2] = { {10,2,3,4}, {5,6,7,8} };
int *p,*q;
p=&a[2][2][2];
*q=***a;
printf("%d----%d",*p,*q);
}
a) 6 b) 10 c) some garbage value d) No output
18) main()
{
static char names[5][20]={"pascal","ada","cobol","fortran","perl"};
int i;
char *t;
t=names[3];
names[3]=names[4];
names[4]=t;
printf("%s",names[3]);
}
a) perl b) fortran c) compilation Error d) Linker Error
19) which of the below three functions are likely cause the problem with pointer
int *f1(void)
{
int x=10;
return &x;
}
int *f2(void)
{
int *ptr;
*ptr=10;
return ptr;
}
int *f3(void)
{
int *ptr;
ptr= (int*)malloc(sizeof(int));
return ptr;
}
a) only f3 b) only f1 and f2 c) only f1 and f3 d) f1,f2.f3
20) main()
{
char *p;
p="Hello";
printf("%c\n",*&*p);
}
a) H b) address of p c) compilation Error d) None
21) How many bytes are occupied by the near pointer?
a) 16 b) 2 c) 32 d) 1
22) p-- executes faster than p-1 because
a) p uses registers b) p-- is a single instruction c) -- is faster than - d) None
23) The associativity of ! operator is
a) Right to Left b) Left to Right c) (a) for arithmetic d) (a) for relational
(b) for relational (b) for arithmetic
24) main()
{
double me=1.1;
long double you=1.1;
if(me==you)
printf(“I Love U”);
else
printf(“I Hate U”);
}
a) I Love U b) I Hate U c) Compilation Error d) Run-time Error
25) main()
{
show();
}
void show()
{
printf(“I am greatest”);
}
a) I am greatest b) I Am Greatest c) Compiler Error d) Linker Error
26) main()
{
char not;
not =!2;
printf(“%d”,not);
}
a) 0 b) syntax Error c) Linker Error d) Run-time Error
27) main()
{
int k=ret(sizeof(float));
printf(“%d”,++k);
}
int ret(int ret)
{
ret+=2.5;
return ret;
}
a) Typecasting required b) 7 c) 6 d) 6.5
28) #define sqr(int) (int * int)
main()
{
float a;
a=sqr(3.0+2.0);
printf(“%f”,a);
}
a) 25.0 b) 11.0 c) 9.0 d) 4.0
29) main()
{
unsigned int i=10;
while(i-- >=0)
printf(“%u”,i);
}
a) 10 9 8 0 b) 10 8 7 6 5 4 3 2 1 0 c) While loop never ends
d) cannot decrement unsigned value
30) main()
{
char *str=”hello”;
char *ptr=str;
char least=127;
while(*ptr++)
least=(*ptr
printf(“%d”,least);
}
a) 127 b) 1 c) 0 d) Incompatible type conversion
31) main()
{
char *ptr=”%%s”;
printf(++ptr,ptr);
}
a) ptr b) %s c) Incorrect pointer addition d) %%s
32) main()
{
int z,x=5,y=-10,a=4,b=2;
z = x++ - --y * b / a;
printf(“%d”,z);
}
a) 5 b) 6 c) 10 d) 11
33) int *fun()
{
static int k=5;
printf(“%d”,k);
return &k;
}
void main()
{
fun();
*(fun())=7;
fun();
}
a) 5 7 b) 5 6 7 c) 5 5 7 d) 5 5 5
34) struct node *nptr, *sptr; /* pointers to linked list */
for(nptr=sptr; nptr ;nptr=nptr->next)
{
free(nptr);
}
a) It will not work correctly since the for loop covers the entire list.
b) It may fail since each node nptr is freed before its next address can be accessed
c) In the for loop, the assignment nptr=nptr->next must be replaced with nptr=nptr.next
d) No memory location is released.
35) Pick up the possible statements which can multiply the value in i by 4 form the following list
I) i*4 II) i<<2>>4 IV) i<<4
a) I only b) both I and II c) III only d) both III and IV
36) main()
{
int testarray[3][2][2]={1,2,3,4,5,6,7,8,9,10,11,12};
printf(“%d”,testarray[2][1][0]);
}
a) 5 b) 10 c) 11 d) 3
37) printf(“%d”, 11 ^ 5); What will be printed?
a) 6 b) 5 c) 10 d)14
38) main()
{
int i=0x1234;
char *p;
p=&i;
printf(“%c”,*p);
}
a) 4 b) Incompatible data type c) No output d) null
39) main()
{
void *p, *q;
p=(void *)1008;
q=(void *)1000;
printf(“%d”,p-q);
}
a) 4 b) 8 c) Compilation Error d) Linker Error
40) Pick out the equivalent postfix expression for this infix expression :
((A + B) * C – (D – E) ^ (F + G))
a) AB+C*DE - - FG + ^
b) ABC*DE - - FG ^ G +
c) AB+CDE - - * FG+^
d) AB+C*DE - -FG^+
41) A binary tree with 40 nodes has ________ branches?
a) 40 b) 41 c) 39 d) 20
42) How many different trees are possible with 10 nodes?
a) 1020 b) 1000 c) 1014 d) 1019
43) Consider an tree implemented using array holds ABCDEFG-H- - - - IJ, where - denotes no value. Pick out the correct post order traversal result.
a) HDEBFIJGCA
b) DHBEAFCIGJ
c) ABDHECFGIJ
d) ABCDEFGHIJ
44) If the records that it’s sorting are in main memory then the sort is called as
a) Internal b) external c) stable d) None
45) Consider an array holding tree information 11 12 13 8 6 5 17 20. If you heapify it what will be the contents of the array?
a) 12 11 8 6 5 17 20 13
b) 20 12 17 11 6 5 13 8
c) 20 12 11 17 13 6 5 8
d) 17 12 11 20 6 8 5 13
46) To implement a node holding another node in a linked list which of the following you will use?
a) Single structure
b) self-referential structures
c) structures within structures
d) both b and c
47) In dealing with a hash clash, a technique is used that builds a linked list of all items whose keys hash to the same values is called
a) chaining b) rehashing c) hash collision d) open addressing
48) A useful tool for specifying the logical properties of a data type is a
a) Abstract data type
b) ADT
c) both a and b
d) None of these
49) In queue the insert operation could be implemented by the statements as
a) q.items[++q.rear]=x
b) ++q.items[q.rear]=x
c) q.items[q.rear++]=x
d) Any of the above
50) A finite set of elements that is empty or is partitioned into three disjoined subsets is called
a) tree b) binary tree c) list d) queue
No comments:
Post a Comment