MCQs

Practice: Paper 1   Paper 2  Paper 3    Paper 4

1)Memory allocation using malloc() is done in?
a. static area
b. Heap area
c. stack area 
d. disc

Answer: b
2)What will be the output of the below program?
int main()
{
int i= 10;
i = ! i > 14;
printf( "%d", i );
return 0;
}
a. 1 
b. Runtime error
c. compilation error 
d. 0

Answer: d
Q3. What will be the output of the below program?
#include<stdio.h>
int main()
{
printf("%.0f", 5.89);
return 0;
}
a. 0 
b. 5 
c. 6 
d. 5.89

Answer: c
4)What is the use of void pointer?
a. Pointer that will not return any value
b. Address of any variable of any data type can be assigned
c. Address of void method can be stored
d. Address of another pointer can be stored


Answer: B
5. If malloc() fails to allocate the requested memory, it returns
a. Null
b. Garbage Value
c. Zero
d. None of the Mentioned

Ans: a


6. What will be the output of the below program?
#include<stdio.h>
int x = 5;
void main()
{
int x = 3;
m();
printf("%d" , x);
}
void m()
{
x = 8;
n();
}
void n()
{
printf("%d", x);
}
a. 3 8 
b. 8 3 
c. 8 5 
d. 8

Answer: b
7)What will be the output of the below program?
#include<stdio.h>
long int fact(int n);
int main()
{
// missing statment
}
long int fact(int n)
{
if(n>=1)
{
return n * fact( n-1 );
}
else
{
return 1;
}
}
a. printf("%ll\n",fact(5)) b. printf("%u\n", fact(5))
c. printf("%d\n", fact(5)) d. printf("%ld\n", fact(5))

Answer Option : d
Q8. How many times the below loop will be 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. 15 b. 11 c. 10 d. 13

Answer: a
Q9. Which is true?
a. Local variable is always static
b. Global variables are equal to auto variable
c. Both are true
d. None of the mentioned

Answer: d

Q10. What will happen if in a C program you assign a value to an array element whose subscript exceeds the size of array?
a. The element will be set to 0.
b. The compiler would report an error.
c. The program may crash if some important data gets overwritten.
d. The array size would appropriately grow.

Answer: c

Q11. What is the difference between declaration and definition of a variable?
a. Declaration specifies the properties and definition specifies the block of executable statements
b. Declaration declares a variable& variable definition defines its type
c. declaration specifies the properties and definition causes the storage to be allocated.
d. None of the mentioned

Answer: c
Q12. What is the format of conditional operator?
a. Condition? true_value: false_value
b. Condition! true_value: false_value
c. Condition? false_value: true_value
d. Condition? true_value: false_value
Answer: a
Q13. Accessibility of local and global is _____ and _____.
a. Within the function, Within the block
b. Within the function, to all functions
c. Within the block, Within the function
d. None of the mentioned

Answer: b
Q14. Print a string without using printf() or putchar() function. Which of the following will be used? String: “hello world”
a. write(1,"hello world",11)
b. puts("hello world");
c. system(“echo 'hello world'”)
d. All of the mentioned

Answer: d

Q15. What will be the output/error?
int main()
{
Int i=5;
char c='c';
int sum=i+c;
printf("%d",sum);
return 0;
}
a. 104 b. 103 c. Error d. -121

Answer: a

Q16. What is the use of ‘&’ operator in C?

a. used as pointer b. gives the size of the variable
c. give address d. All of the mentioned

Answer: c

Q17. Which one of the following is true?
a. Local variable is always static
b. Global variables are equal to auto variable
c. Both are true
d. None of the mentioned

Answer: d

Q18. Where are the local variables stored?

a. Stack b. Queue c. Heap d. Hard disk

Answer: a

Q19. What will be the output/error?
int main()
{
printf("%.0f", 5.89);
return 0;
}

a. 0 b. 5 c. 6 d. 5.890000

Answer: c

Q20. What is the use of void pointer?
a. Pointer that will not return any value
b. Address of any variable of any data type can be assigned
c. Address of void method can be stored
d. Address of another pointer can be stored

Answer: b

No comments:

Post a Comment

CTS Written test results of Vijayawada, Guntur, Ongole, Godarvari Districts were out.  Tentative dates of TR and HR are 24th and 25th Nov...