TCS Placement C, C++ Questions 2010 Part 2


For questions 14,15,16,17 use the following alternatives:
a. int     b. char     c. string     d. float

14.     '9'

15.     "1 e 02"

16.     10e05

17.     15

18. Read the following code
# define MAX 100
# define MIN 100
....
....
if(x>MAX)
x=1;
else if(x<MIN)
x=-1;
x=50;
if the initial value of x=200,what is the value after executing this code?
(a) 200             (b) 1             (c) -1             (d) 50

19. A memory of 20 bytes is allocated to a string declared as char *s then the following two statements are executed:
s="Entrance"
l=strlen(s);
what is the value of l ?
(a)20             (b)8             (c)9             (d)21

20. Given the piece of code
int a[50];
int *pa;
pa=a;
To access the 6th element of the array which of the following is incorrect?
(a) *(a+5) (b) a[5] (c) pa[5] (d) *(*pa + 5}

21. Consider the following structure:
struct num nam
{
int no;
char name[25];
}
struct num nam n1[]={{12,"Fred"},{15,"Martin"},{8,"Peter"},{11,Nicholas"}};
.....
.....
printf("%d%d",n1[2],no,(*(n1 + 2),no) + 1);
What does the above statement print?
(a) 8,9             (b) 9,9             (c) 8,8             (d) 8, unpredictable value

22. Identify the in correct expression
(a)a=b=3=4; (b)a=b=c=d=0; (c)float a=int b= 3.5; (d)int a; floatb;a=b=3.5;

No comments:

Post a Comment

Popular Posts