TCS Placement C, C++ Questions 2010 Part 4


35.Consider the following program
main()
{
int a[5]={1,3,6,7,0};
int *b;
b=&a[2];
}
The value of b[-1] is
(a) 1                 (b) 3                 (c) -6                 (d) none

36. # define prod(a,b)=a*b
main()
{
int x=2;
int y=3;
printf("%d",prod(x+2,y-10));
}
the output of the program is
(a) 8                 (b) 6                 (c) 7                 (d) None

37.Consider the following program segment
int n,sum=1;
switch(n)
{
case 2:sum=sum+2;
case 3:sum*=2;
break;
default:sum=0;
}
If n=2, what is the value of sum
(a) 0                 (b) 6                 (c) 3                 (d) None of these

38. Identify the incorrect one
1.if(c=1)
2.if(c!=3)
3.if(a<b)then
4.if(c==1)
(a) 1 only                 (b) 1&3                 (c) 3 only                 (d) All of the above

39. The format specified for hexa decimal is
(a) %d                 (b) %o                 (c) %x                 (d) %u

40. Find the output of the following program
main()
{
int x=5, *p;
p=&x
printf("%d",++*p);
}
(a) 5                 (b) 6                 (c) 0                 (d) none of these

41.Consider the following C code
main()
{
int i=3,x;
while(i>0)
{
x=func(i);
i--;
}
int func(int n)
{
static sum=0;
sum=sum+n;
return(sum);
}
}
The final value of x is
(a) 6                 (b) 8                 (c) 1                 (d) 3

42. Int *a[5] refers to
(a) array of pointers             (b) pointer to an array             (c) pointer to a pointer                 (d) none of these

43.Which of the following statements is incorrect
(a) typedef struct new
{
int n1;
char n2;
} DATA;

(b) typedef struct
{
int n3;
char *n4;
}ICE;

(c) typedef union
{
int n5;
float n6;
} UDT;

(d) #typedef union
{
int n7;
float n8;
} TUDAT;

No comments:

Post a Comment

Popular Posts