Home

1000+ C Programming MCQ for DRDO [Solved]

Thursday 9th of March 2023

Sharing is caring

1. Which one of the following is not a fundamental data type in C++
A. float
B. string
C. int
D. wchar_t
Answer : A
2. All macro substitutions in a program are done before compilation of the program.
A. True
B. False
C.
D.
Answer : A
3. Identify the wrong statement
A. putchar(65)
B. putchar('x')
C. putchar("x")
D. putchar('
')
Answer : C
4. Which of the following is not an infinite loop
A. int i =1;
while (1)
{i++;}
B. for( ; ; );
C. int true=0< false;
while (true)
{false = 1;}
D. int y, x = 0;
do
{y = x;}
while (x==0);
Answer : C
5. The -------------------------- loop executes at least once.
A. for
B. while
C. do-while
D. while & do-while
Answer : C
6. What is C Tokens?
A. The smallest individual units of c program
B. The basic element recognized by the compiler
C. The largest individual units of program
D. A & B Both
Answer : D
7. The output of the following code is:
main() 
{
int a = 5, b = 6;
(a == b? printf("%d", a));
}

A. 0
B. 5
C. Error
D. None of the above
Answer : C
8. char *s[10] defines an array of ------------------------
A. pointers to strings
B. string to pointer
C. both
D.
Answer : A
9. When a user defined function is defined in program, then it has to be called at least once from the main().
A. True
B. False
C.
D.
Answer : B
10. What is right way to Initialization array?
A. int num[6] = { 2, 4, 12, 5, 45, 5 } ;
B. int n{} = { 2, 4, 12, 5, 45, 5 } ;
C. int n{6} = { 2< 4< 12 } ;
D. int n(6) = { 2, 4, 12, 5, 45, 5 } ;
Answer : A
11. /* The C language.
/* is a procedural language .*/*/
The above statement is valid.

A. True
B. False
C.
D.
Answer : B
12. The same variable names of automatic type can be used in different functions without any conflict.
A. True
B. False
C.
D.
Answer : A
13. No commas or blanks are allowed within an integer or a real constant.
A. True
B. False
C.
D.
Answer : A
14. A multidimensional array A[10][9] can store-------- number of elements
A. 91
B. 88
C. 90
D. 89
Answer : C
15. Which header file is essential for using strcmp() function?
A. string.h
B. strings.h
C. text.h
D. strcmp.h
Answer : A
16. A recursive function calls itself again and again.
A. True
B. False
C.
D.
Answer : A
17. An array elements are always stored in _________ memory locations.
A. Sequential
B. Random
C. Sequential and Random
D. None of the above
Answer : A
18. Which of the STL containers store the elements contiguously (in adjecent memory locations)?
A. std::vector
B. std::list
C. std::map
D. std::set
Answer : C
19. p++ executes faster than p + 1.
A. True
B. False
C.
D.
Answer : A
20. The default initial value of automatic storage class is 0.
A. True
B. False
C.
D.
Answer : B
21. The output of the following code is:
main() 
{
int sub[50];
for(i=0; i<=48;i++)
{
sub[i]=i;
printf("
%d", sub[i]);
}
}

A. 0 to 48 will be displayed
B. 48
C. 49
D. Compilation Error
Answer : D
22. Which of the following is allowed in a C Arithmetic instruction
A. []
B. {}
C. ()
D. None of the above
Answer : C
23. The main() function can call itself recursively.
A. True
B. False
C.
D.
Answer : A
24. The main() function can be called from any other function.
A. True
B. False
C.
D.
Answer : A
25. Which of the following language is predecessor to C Programming Language?
A. A
B. B
C. BCPL
D. C++
Answer : B
26. Which of the following is not a standard exception built in C++.
A. std::bad_creat
B. std::bad_alloc
C. std::bad_cast
D. std::bad_typeid
Answer : A
27. What will be output if you will compile and execute the following c code?
#include 
int main()
{
float a=5.2;
if(a==5.2)
printf("Equal");
else if(a<5.2)
printf("Less than");
else
printf("Greater than");
return 0;
}

A. Less than
B. Equal
C.

Greater than


D. None of above
Answer : A
28. Each pass through a loop is called a/an
A. enumeration
B. iteration
C. culmination
D. pass through
Answer : C
29. 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");
}

A. B
B. b
C. bca
D. bc
Answer : D
30. strcat() function ----------------------- two strings.
A. delete
B. concatenate
C. compare
D. none of the above
Answer : B
31. When is std::bad_alloc exception thrown?
A. When new operator cannot allocate memory
B. When alloc function fails
C. When type requested for new operation is considered bad<  thisexception is thrown
D. When delete operator cannot delete teh allocated (corrupted) object
Answer : D
32. A function to be called must be ended with a----------------
A. .
B. ?
C. ;
D. none of the above
Answer : C
33. unsigned char has a range from 0 to ------------
A. 253
B. 254
C. 255
D. 256
Answer : C
34. Left shift operator rotates the bits on the left and places them to the right.
A. True
B. False
C.
D.
Answer : B
35. C programming language was developed by
A. Dennis Ritchie
B. Ken Thompson
C. Bill Gates
D. Peter Norton
Answer : A
36. printf() is not a library function.
A. True
B. False
C.
D.
Answer : B
37. The value of an enumerated datatype can be read using scanf() function.
A. True
B. False
C.
D.
Answer : B
38. Right shifting an operand 1bit is equivalent to multiplying it by 2.
A. True
B. False
C.
D.
Answer : B
39. Which of the following expressions is wrong
A. float a =123.56;
B. char ch ='T' * 'A';
C. char ch ='T' *20;
D. 3 +a = b;
Answer : D
40. A C variable cannot start with
A. An alphabet
B. A number
C. A special symbol other than underscore
D. both (b) and (c)
Answer : D
41. The statement "for (i = 0, j = 2; j <= 10; j++)" is a valid statement in 'C'.
A. True
B. False
C.
D.
Answer : A
42. The output of the following code is:
main() 
{
void msg()
{
printf("HELLO WORLD");
}
}

A. HELLO WORLD
B. Error
C. None of the above
D. Null
Answer : B
43. The printf() function retunes which value when an error occurs?
A. Positive value
B. Zero
C. Negative value
D. None of these
Answer : C
44. The expression 'int j = 6 + 3 % -9;' evaluates to -1.
A. True
B. False
C.
D.
Answer : B
45. The size of signed integer is ------ bytes.
A. 4
B. 2
C. 8
D. 10
Answer : B
46. A continue statement causes execution to skip to
A. the return 0; statement
B. the first statement after the loop
C. the statement following the continue statement
D. the next iteration of the loop
Answer : C
47. Which of the following is a valid destructor of the class name "Country"
A. int ~Country()
B. void Country()
C. int ~Country(Country obj)
D. void ~Country()
Answer : B
48. How many times the following loop will execute?
for (a = 0; a < 4; a++)
printf("hello
");

A. 3
B. 4
C. 5
D. infinite
Answer : B
49. 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));
}

A. 2
B. 1
C. Compilation error
D. Runtime error
Answer : A
50. The output of the following code is:
void main() 
{
float a;
int x = 10, y = 3; a = x / y;
printf("%f", a); }

A. 3.999999
B. Error
C. 3
D. 3.000000
Answer : D

Sharing is caring