Saturday, February 13, 2021

New C Programming 38 Solved MCQ Question Answer 2021

 Question: 1. The output of the following code is:

void main()
{
int z, a = 5, b = 3; z = a * 2 + 26 % 3;
printf("%d", z); }
Option A. 10
Option B. 0
Option C. 12
Option D. None of the above

Question: 2. Which options shows the correct hierarchy of arithmetic operators
Option A. **, * or /, + or -
Option B. **, *, /, +, -
Option C. **< /< *< +<-
Option D. / or *, - or +

Question: 3. The output of the following code is:
void main() 
{
float a;
int x = 10, y = 3; a = x / y;
printf("%f", a); }
Option A. 3.999999
Option B. Error
Option C. 3
Option D. 3.000000

Question: 4. The output of the following code is:
void main() 
{
char a = 'B';
switch (a)
{
case 'A' : printf("a");
case 'B' : printf("b");
default : printf("c");
}
Option A. B
Option B. b
Option C. bca
Option D. bc

Question: 5. The output of the following code is:
void main()
{
int a = 20;
printf("%d\t%d
", ++a, a);
}
Option A. 21 21
Option B. 20 21
Option C. 21 20
Option D. 20 20

Question: 6. How many times the following loop will execute?
for (a = 0; a < 4; a++)
printf("hello
");
Option A. 3
Option B. 4
Option C. 5
Option D. infinite

Question: 7. The output of the following code is:
void main() 
{
int a;
int &b = a;
a=100;
printf("b=%d\ta=%d
", b,a);
}
Option A. b=100 a=100
Option B. b=100 a=0
Option C. b=0 a=100
Option D. Error

Question: 8. The output of the following code is:
void main() 
{
int a = 0;
while (a<=50) for(;;) if(++a % 50==0) break;
printf("a = %d", a);
}
Option A. a = 100
Option B. a = 50
Option C. compilation error
Option D. runtime error

Question: 9. The output of the following code is:
int f(int a, int b); 
void main()
{
int a = 12, b=154;
printf("%d", f(a, b));
}
int f(int a, int b)
{
if (a<b) return(f(b, a));
if(b==0) return(a);
return (f(b, a % b));
}
Option A. 2
Option B. 1
Option C. Compilation error
Option D. Runtime error

Question: 10. The output of the following code is:
void main() 
{
int a = 1, b=2;
int *ip;
ip=&a;
b=*ip;
printf("%d", b);
}
Option A. 2
Option B. 1
Option C. 100
Option D. 0

Question: 11. The output of the following code is:
void main() 
{
static int a = 1, b, c;
if (a>=2) b=2; c=3;
printf("%d\t%d", b,c);
}
Option A. 2 3
Option B. 0 3
Option C. 0 0
Option D. 2 0

Question: 12. The output of the following code is:
#define sqr(x= x*x) 
main()
{
int a = 10, b = 5;
printf("%d, %d", sqr(a+b),sqr(++a));
}
Option A. 77, 121
Option B. 225, 121
Option C. 77< 144
Option D. Compilation error

Question: 13. struct stud
{
int roll;
char name[20];
float marks;
} *p;
What will be the byte size of p?
Option A. 24
Option B. 2
Option C. 26
Option D. None

Question: 14. The output of the following code is:
main() 
{
unsigned int a = 10;
while (a>=10)
{
int a; a-- ;
}
printf("%i", a);
}
Option A. Infinite loop
Option B. 9
Option C. 0
Option D. None

Question: 15. The output of the following code is:
main() 
{
xyz: goto abc;
printf("Hello");
abc: printf("World");
goto xyz;
}
Option A. Infinite loop
Option B. Hello World
Option C. World Hello
Option D. Compilation error

Question: 16. The output of the following code is:
main() 
{
int a = 0;
for (; i = 0; i++)
printf("%d", a);
}
Option A. 0
Option B. Nothing will be displayed
Option C. Infinite loop
Option D. None of the above

Question: 17. The output of the following code is:
void change (char *k) 
{
k="Hello";
return;
}
main()
{
char *ch = "World";;
change(ch);
printf("%s", ch);
}
Option A. Hello
Option B. World
Option C. Compilation error
Option D. Hello World

Question: 18. Which of the following is not an infinite loop
Option A. int i =1;
while (1)
{i++;}
Option B. for( ; ; );
Option C. int true=0< false;
while (true)
{false = 1;}
Option D. int y, x = 0;
do
{y = x;}
while (x==0);

Question: 19. do-while loop is useful when we want the statements within the loop must be executed
Option A. Only once
Option B. At least once
Option C. More than Once
Option D. Any one of the above

Question: 20. Which of the following is not a preprocessor directive
Option A. #if
Option B. #elseif
Option C. #undef
Option D. #pragma

Question: 21. The output of the following code is:
main() 
{
int a = 5, b = 6;
(a == b? printf("%d", a));
}
Option A. 0
Option B. 5
Option C. Error
Option D. None of the above

Question: 22. The output of the following code is:
main() 
{
int k, num = 30;
k = (num > 5 ? (num <= 10 ? 100 : 200) : 500);
printf("
%d", num);
}
Option A. 200
Option B. 500
Option C. 30
Option D. Unpredictable

Question: 23. The output of the following code is:
main() 
{
void msg()
{
printf("HELLO WORLD");
}
}
Option A. HELLO WORLD
Option B. Error
Option C. None of the above
Option D. Null

Question: 24. The output of the following code is:
main() 
{
int sub[50];
for(i=0; i<=48;i++)
{
sub[i]=i;
printf("
%d", sub[i]);
}
}
Option A. 0 to 48 will be displayed
Option B. 48
Option C. 49
Option D. Compilation Error

Question: 25. The output of the following code is:
main() 
{
int a[10], i;
for (i = 1; I <= 0; i++)
{
scanf("%d", a[i]);
printf("%d", a[i]);
}
}
Option A. 10
Option B. Logical error
Option C. Runtime error
Option D. 1 to 10 will be displayed

Question: 26. Which of the following expressions is wrong
Option A. float a =123.56;
Option B. char ch ='T' * 'A';
Option C. char ch ='T' *20;
Option D. 3 +a = b;

Question: 27. strcat() function ----------------------- two strings.
Option A. delete
Option B. concatenate
Option C. compare
Option D. none of the above

Question: 28. A function to be called must be ended with a----------------
Option A. .
Option B. ?
Option C. ;
Option D. none of the above

Question: 29. The function fopen() on failure returns---------------------.
Option A. 0
Option B. NULL
Option C. 1
Option D. none of the above

Question: 30. The-------------------- statement helps immediate exit from any part of the loop
Option A. break
Option B. continue
Option C. exit
Option D. All of the above

Question: 31. The -------------------------- loop executes at least once.
Option A. for
Option B. while
Option C. do-while
Option D. while & do-while

Question: 32. char *s[10] defines an array of ------------------------
Option A. pointers to strings
Option B. string to pointer
Option C. both

Question: 33. A multidimensional array A[10][9] can store-------- number of elements
Option A. 91
Option B. 88
Option C. 90
Option D. 89

Question: 34. The size of signed integer is ------ bytes.
Option A. 4
Option B. 2
Option C. 8
Option D. 10

Question: 35. There are total ------ numbers of operators in 'C'.
Option A. 35
Option B. 45
Option C. 55
Option D. 40

Question: 36. ------ is the ternary operator
Option A. ?,-
Option B. ?,:
Option C. ++<--
Option D. none of the above

Question: 37. unsigned char has a range from 0 to ------------
Option A. 253
Option B. 254
Option C. 255
Option D. 256

Question: 38. If 'str' is a string of 7 characters, the statement printf("%4s", str); will display ------characters.
Option A. 4
Option B. 7
Option C. 6
Option D. 0

Answer Sheet

1C
2D
3D
4D
5C
6B
7D
8A
9A
10B
11B
12D
13B
14A
15A
16D
17B
18C
19B
20B
21C
22C
23B
24D
25B
26D
27B
28C
29B
30A
31C
32A
33C
34B
35B
36B
37C
38A

0 comments:

Post a Comment