Home

1000+ C Programming Multiple Choice Question Answer [Solved]

Thursday 9th of March 2023

Sharing is caring

1. gets() and puts() are unformatted I/O functions.
A. True
B. False
C.
D.
Answer : A
2. C programs are converted into machine language with the help of
A. An Editor
B. A compiler
C. An operating system
D. None of the above
Answer : B
3. A recursive function calls itself again and again.
A. True
B. False
C.
D.
Answer : A
4. Which among the following is a unconditional control structure
A. do-while
B. if-else
C. goto
D. for
Answer : C
5. The statement "for (i = 0, j = 2; j <= 10; j++)" is a valid statement in 'C'.
A. True
B. False
C.
D.
Answer : A
6. Which one of the following is not a fundamental data type in C++
A. float
B. string
C. int
D. wchar_t
Answer : A
7. Which of the following is an example of compounded assignment statement?
A. a = 5
B. a += 5
C. a = b = c
D. a = b
Answer : C
8. A function to be called must be ended with a----------------
A. .
B. ?
C. ;
D. none of the above
Answer : C
9. The output of the following code is:
void main() 
{
int a;
int &b = a;
a=100;
printf("b=%d\ta=%d
", b,a);
}

A. b=100 a=100
B. b=100 a=0
C. b=0 a=100
D. Error
Answer : D
10. What will be output if you will compile and execute the following c code?
#include 
int main(){
int i=320;
char *ptr=(char *)&i;
printf("%d",*ptr);
return 0;
}

A. 1
B. 64
C. 320
D. Compiler Error
Answer : B
11. 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
12. If 'str' is a string of 7 characters, the statement printf("%4s", str); will display ------characters.
A. 4
B. 7
C. 6
D. 0
Answer : A
13. && and & operators have the same meaning.
A. True
B. False
C.
D.
Answer : B
14. C programming language was developed by
A. Dennis Ritchie
B. Ken Thompson
C. Bill Gates
D. Peter Norton
Answer : A
15. It is necessary to initialize the array at the time of declaration.
A. True
B. False
C.
D.
Answer : B
16. printf("%d", sizeof('2')); will print 2.
A. True
B. False
C.
D.
Answer : B
17. The array 'char name[10] can consist of a maximum of 9 characters.
A. True
B. False
C.
D.
Answer : A
18. 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
19. the value *(&i) is same as printing the value of address of i.
A. True
B. False
C.
D.
Answer : B
20. Expression 4**3 evaluates to 64.
A. True
B. False
C.
D.
Answer : B
21. What's wrong? for (int k = 2, k <=12, k++)
A. the increment should always be ++k
B. the variable must always be the letter i when using a for loop
C. there should be a semicolon at the end of the statement
D. the commas should be semicolons
Answer : B
22. An array declared as A[100][100] can hold a maximum of 100 elements.
A. True
B. False
C.
D.
Answer : B
23. Which classes allow primitive types to be accessed as objects?
A. Storage
B. Virtual
C. Friend
D. Wrapper
Answer : B
24. The output of the following code is:
main() 
{
int a = 0;
for (; i = 0; i++)
printf("%d", a);
}

A. 0
B. Nothing will be displayed
C. Infinite loop
D. None of the above
Answer : D
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]);
}
}

A. 10
B. Logical error
C. Runtime error
D. 1 to 10 will be displayed
Answer : B
26. The identifier argv[] is a pointer to an array of strings.
A. True
B. False
C.
D.
Answer : B
27. unsigned' is a valid variable name.
A. True
B. False
C.
D.
Answer : B
28. 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
29. Left shift operator rotates the bits on the left and places them to the right.
A. True
B. False
C.
D.
Answer : B
30. Which of the following is invalid?
A. ''
B. " "
C. 'a'
D. abc'
Answer : D
31. The main() function can be called from any other function.
A. True
B. False
C.
D.
Answer : A
32. Which of the following is allowed in a C Arithmetic instruction
A. []
B. {}
C. ()
D. None of the above
Answer : C
33. 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
34. The-------------------- statement helps immediate exit from any part of the loop
A. break
B. continue
C. exit
D. All of the above
Answer : A
35. enum helps to create user defined datatype.
A. True
B. False
C.
D.
Answer : A
36. Operation between an integer and float always yields a float result.
A. True
B. False
C.
D.
Answer : A
37. What does STL stand for?
A. Simple Template Library
B. Standard Template Library
C. Static Type Library
D. Single Type-based Library
Answer : A
38. There are total ------ numbers of operators in 'C'.
A. 35
B. 45
C. 55
D. 40
Answer : B
39. static variable will not always have assigned value.
A. True
B. False
C.
D.
Answer : A
40. A declaration float a, b; occupies ___ of memory
A. 1 byte
B. 4 bytes
C. 8 bytes
D. 16 bytes
Answer : C
41. Variables declared as register storage type gets stored in CPU registers.
A. True
B. False
C.
D.
Answer : A
42. 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
43. What is the difference between overloaded functions and overridden functions?
A. Overloading is a dynamic or run-time binding and Overriding is static or compile-time binding
B. Redefining a function in a friend class is called function overriding while Redefining a function in a derived class is called a overloaded fucntion.
C. Overloading is a static or compile-time binding and Overriding is dynamic or run-time binding
D. Redefining a function in a friend class is called function overloading while Redefining a function in a derived class is called as overridden fucnion.
Answer : B
44. The expression "int i = j = k = 0;" is invalid.
A. True
B. False
C.
D.
Answer : A
45. The output of the following code is:
main() 
{
xyz: goto abc;
printf("Hello");
abc: printf("World");
goto xyz;
}

A. Infinite loop
B. Hello World
C. World Hello
D. Compilation error
Answer : A
46. The expression "b = 3 ^ 2;" will evaluate b = 9.
A. True
B. False
C.
D.
Answer : B
47. Right shifting an operand 1bit is equivalent to multiplying it by 2.
A. True
B. False
C.
D.
Answer : B
48. The output of the following code is:
void main()
{
int a = 20;
printf("%d\t%d
", ++a, a);
}

A. 21 21
B. 20 21
C. 21 20
D. 20 20
Answer : C
49. Only one break can be used in one loop.
A. True
B. False
C.
D.
Answer : B
50. The main() function can call itself recursively.
A. True
B. False
C.
D.
Answer : A

Sharing is caring