Home Company Questions TCS Interview Questions TCS Interview Questions - 4

Login Form




TCS Interview Questions - 4 Print E-mail

1. What is the output of the following program

main ()

{

unsigned int i;

for (i = 10; i >= 0; i--)

printf ("%d", i);

}

a) prints numbers 10 - 0                       b) prints nos 10 - 1                   c) goes into infinite loop


2. How many x's are printed?

for (i = 0, j = 10; i < j; i++, j--)

printf ("x");

a) 10          b) 5             c) 4            d) none


3. union {

int no;

char ch;

} u;

What is the output?

u.ch = '2';

u.no = 0;

printf ("%d", u.ch);

a) 2               b) 0               c) null character             d) none


4. Which are valid?

i) pointers can be added

ii) pointers can be subtracted

iii) integers can be added to pointers

a) all correct                 b) only i and ii


5. char name[] = {'n', 'a', 'm', 'e'}

printf ("name = \n%s", name);

a) name =

name

b) name =

followed by funk characters

c) name = \nname

d) none


6. struct adr {

char *name;

char *city;

int zip;

};

struct adr *adradr;

which are valid references?

i) adr->name X

ii) adradr->name

iii) adr.zip X

iv) adradr.zip


7. main ()

{

}

int a;

f1(){}

f2(){}

Which of the functions is int a available for?

a. all of them

b. only f2

c. only f1

d. f1 and f2 only


8. What is the value of the following expression?

i = 1;

i = (i <<= 1 % 2)

a) 2                b) 0                c) erroneous syntax


9. What is the result?

*A + 1 - *A + 3

a) -              b) -2           c) 4             d) none of the above


 

10. int *i;

float *f;

char *c;

which are the valid castings?

i) (int *) &c

ii) (float *) &c

iii) (char *) &i