hii

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:-
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:-
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:-
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:-
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:-
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:-
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:-
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

Last edited by shabbir; 23Aug2007 at 17:17.. Reason: Code block + Post Format