TCS Techincal Questions with Solutions Set -2

1. How many times loop will executed ?
#include
int main()
{
int x,y;
for(x=5;x>=1;x–)
{
for(y=1;y<=x;y++)
printf(“%d\n”,y);
}
}
a) 11
b) 13
c) 15
d) 10
Answer:c

2. Which of the following indicate the end of file ?
a) feof()
b) EOF
c) Both feof() and EOF
d) None of the mentioned
Answer:c

3. If a functions return type is not explicitly defined then it is default to ……….(in C).
a) int
b) float
c) void
d) error
Answer:a

4. Where the local variable is stored ?
a) Disk
b) Stack
c) Heap
d) Register
Answer:b

5. How many times loop will executed ?
#include
int main()
{
int i;
for(i=0;i<5;i++)
{
printf(“Hello\n”);
}
}
a) 0
b) 1
c) 3
d) 5
Answer:d

6. What is dangling pointer?
a) points to garbage value
b) points to function
c) Both A and B
d) None of these
Answer:a

7. what is the purpose of ftell ?
a)to get the current file position
b)to get the current file attribute
c)to get the current file status
d)to get the current file name
Answer:a

8. What is recursion ?
a) looping
b) a function calls another function repeatedly
c) a fnction calls repeatedly
d) function calls itself repeatedly
Answer:d

9. What is the similarity between enum and struct ?
a) can assign new values
b) can create new data types
c) nothing in common
d) they are same
Answer:b

10. which of the following is not a fundamental datatype?
a) Enum
b) unsigned long int
c) Long int
d) double
Answer:

11. How many times hello will print ?
#include
int main(void)
{
int i;
for(i=0;i<5;i++);
printf(“hello”);
}
a) Compilation error
b) Runtime error
c) 4
d) 1
Answer:b