(Paper) C Programming Placement Questions Paper - Aptitude

C Programming Placement Questions Paper


C Questions
-
1.Consider the following declaration:-

char const *p = 'd';

Which of the following is not a permissible operation
(a) *p++
(b) ++p
(c) (*p)++
(d) All

2.What is the output of the following code:-

void print_arr(float **p)
{
printf(" 0 %f 1 %f 2 %f\n",p[0][0],p[0][1],p[0][2]);
}

void main()
{
float arr[2][3] = {{0,1,2},{3,4,5}};
float **fl_arr;
fl_arr = (float *)arr;
print_arr(fl_arr);
fl_arr++;
print_arr(fl_arr);
}

(a)
(d)segmentation fault


3.What is the output of the following code:-

#define putchar (c) printf("%c",c)
void main()
{
char s='c';
putchar (s);
}

(a) c
(b) 99
(c) Compilation error
(d) Execution error

4.What is the output of the following code:-

void main()
{
printf("%d",printf("ABC\\"));
}

(a) ABC\\
(b) 1
(c) ABC\4
(d) ABC\3

5.What is the output of the following code:-

int compute(int n)
{
if(n>0)
{
n=compute(n-3)+compute(n-1);
return(n);
}
return(1);
}

void main()
{
printf("%d",compute(5));
}

(a) 6
(b) 9
(c) 12
(d) 13

6.What is the output of the following code:-

void main()
{
int i;
for(i=0;i<3;i++)
{
int i=100;
i--;
printf("%d..",i);
}
}

(a0..1..2..
(b)99..98..97..
(c)100..100..100..
(d)99..99..99..

7.What is the output of the following code:-

void main()
{
int a[]={9,4,1,7,5};
int *p;
p=&a[3];
printf("%d",p[-1]);
}

(a)6
(b)1
(c)7
(d)Error

8.What is the output of the following code:-

void main()
{
int a[]={10,20,30,40,50};
int *p;
p= (int*)((char *)a + sizeof(int));
printf("%d",*p);
}

(a)10
(b)20
(c)30
(d)40

9.Which code will run faster

for(i=0;i<100;i++)
for(j=0;j<10;j++)
a[i][j]=0;

OR

for(j=0;j<10;j++)
for(i=0;i<100;i++)
a[i][j]=0;

(a)First code
(b)Second code
(c)Same
(d)Compiler and hardware dependent

Answers(Only those which are sure)

1.(c)
3.(c)
4.(c)
5.(b)
6.(d)
7.(b)
8.(b)


Aptitude

1.How many 2 digit numbers are there which have 8 as the unit number in it's square.
(a)3
(b)None
(c)2
(d)1

2. B is 8km East of A. C is 6km North of B. D is 12km East of C. E is 16km North of D.
What is the distance b/w A and E.
(a)20km
(b)22km
(c)18km
(d)30km

3. x+y = z
Then
(a)...
(b)y
(c)...

4. 2 <3 , 7 <8
Then which is the greatest
(a) (x^2)y
(b) 5xy
(c) x(y^2)
(d) 5(x^2)y/12

5. A is taller than B, D is taller than D, D is shorter than E.Then which of the following is correct.
(a) C is taller than E
(b) A is taller than C
(c) D is shorter than A
(d) B is shorter than C

6.A small passage was given and 4 options which summarizes it was given.The best was to be chosen.

7.Another passage was given and 4 inference was given and correct was to be chosen.This one is very easy.

8.Which of the following is a parellogram:-
(a)130,50,130,50(angle in deg)
(b)120,30,130,20
(c)90,90,90,90
(d)a & c

9. In the following series (an - 1)^2, 1 is the first term.Which are the next three
(a)1,3,4
(b)0,3,6
(c)0,1,2
(d)0,1,0

Answers
1.(b)
2.(d)
3.(b)
4.(c)
5.(c)
8.(d)
9.(d)

comments powered by Disqus