TCS MCQ C Question – 5

1. How many times loop will executed ?
#include<stdio.h>
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

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

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

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

5. How many times loop will executed ?
#include<stdio.h>
int main()
{
int i;
for(i=0;i<5;i++)
{
printf(“Hello\n”);
}
}

a) 0
b) 1
c) 3
d) 5

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

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

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

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

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

11. How many times hello will print ?
#include<stdio.h>
int main(void)
{
int i;
for(i=0;i<5;i++);
printf(“hello”);
}

a) Compilation error
b) Runtime error
c) 4
d) 1

If a function is defined as static, it means

A) The value returned by the function does not change

B) all the variable declared inside the function automatically will be assigned initial value of zero

C) It should be called only within the same source code / program file.

D) None of the other choices as it is wrong to add static prefix to a function