Home

1000+ C Programming Multiple Choice Question Answer [Solved]

Thursday 9th of March 2023

Sharing is caring

1. Single operations involving entire arrays are permitted in C.
A. True
B. False
C.
D.
Answer : A
2. The statement "for (i = 0, j = 2; j <= 10; j++)" is a valid statement in 'C'.
A. True
B. False
C.
D.
Answer : A
3. printf() is not a library function.
A. True
B. False
C.
D.
Answer : B
4. ------ is the ternary operator
A. ?,-
B. ?,:
C. ++<--
D. none of the above
Answer : B
5. The contents of a file opened in 'r+' mode cannot be changed.
A. True
B. False
C.
D.
Answer : B
6. 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
7. Left shift operator rotates the bits on the left and places them to the right.
A. True
B. False
C.
D.
Answer : B
8. Bitwise operators can operate upon?
A. double and chars
B. floats and doubles
C. ints and floats
D. ints and chars
Answer : D
9. The expression 'int j = 6 + 3 % -9;' evaluates to -1.
A. True
B. False
C.
D.
Answer : B
10. unsigned char has a range from 0 to ------------
A. 253
B. 254
C. 255
D. 256
Answer : C
11. static variable will not always have assigned value.
A. True
B. False
C.
D.
Answer : A
12. struct stud
{
int roll;
char name[20];
float marks;
} *p;
What will be the byte size of p?

A. 24
B. 2
C. 26
D. None
Answer : B
13. A pointer is an indication of the variable to be accessed next.
A. True
B. False
C.
D.
Answer : B
14. A multidimensional array A[10][9] can store-------- number of elements
A. 91
B. 88
C. 90
D. 89
Answer : C
15. The expression "int i = j = k = 0;" is invalid.
A. True
B. False
C.
D.
Answer : A
16. Which of the following is allowed in a C Arithmetic instruction
A. []
B. {}
C. ()
D. None of the above
Answer : C
17. Which of the following is not true about preprocessor directives
A. They begin with a hash symbol
B. They are processed by a preprocessor
C. They form an integral part of the code
D. They have to end with a semi colon
Answer : A
18. An array declared as A[100][100] can hold a maximum of 100 elements.
A. True
B. False
C.
D.
Answer : B
19. What does STL stand for?
A. Simple Template Library
B. Standard Template Library
C. Static Type Library
D. Single Type-based Library
Answer : A
20. Which of the following is invalid?
A. ''
B. " "
C. 'a'
D. abc'
Answer : D
21. The identifier argv[] is a pointer to an array of strings.
A. True
B. False
C.
D.
Answer : B
22. The output of the following code is:
main() 
{
unsigned int a = 10;
while (a>=10)
{
int a; a-- ;
}
printf("%i", a);
}

A. Infinite loop
B. 9
C. 0
D. None
Answer : A
23. continue statement is used
A. to go to the next iteration in a loop
B. come out of a loop
C. exit and return to the main function
D. restarts iterations from beginning of loop
Answer : D
24. char *s[10] defines an array of ------------------------
A. pointers to strings
B. string to pointer
C. both
D.
Answer : A
25. 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
26. What's wrong? while( (i < 10) && (i > 24))
A. the logical operator && cannot be used in a test condition
B. the while loop is an exit-condition loop
C. the test condition is always true
D. the test condition is always false
Answer : D
27. Structures within structures cannot be created.
A. True
B. False
C.
D.
Answer : B
28. void' is a datatype.
A. True
B. False
C.
D.
Answer : A
29. 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);
}

A. 2 3
B. 0 3
C. 0 0
D. 2 0
Answer : B
30. = and = = have the same operation.
A. True
B. False
C.
D.
Answer : B
31. The output of the following code is:
void main()
{
int z, a = 5, b = 3; z = a * 2 + 26 % 3;
printf("%d", z); }

A. 10
B. 0
C. 12
D. None of the above
Answer : C
32. Nested macros are allowed.
A. True
B. False
C.
D.
Answer : B
33. 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
34. The main() function can call itself recursively.
A. True
B. False
C.
D.
Answer : A
35. 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
36. Character data types cannot be declared as unsigned.
A. True
B. False
C.
D.
Answer : B
37. What would be the output of the following program?
int x=40;
main(){
int x=20;
printf("
%d",x);
}

A. 40
B. 20
C. Compilation Error
D. Garbeg Value
Answer : B
38. Which classes allow primitive types to be accessed as objects?
A. Storage
B. Virtual
C. Friend
D. Wrapper
Answer : B
39. 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
40. enum helps to create user defined datatype.
A. True
B. False
C.
D.
Answer : A
41. What's wrong? (x = 4 && y = 5) ? (a = 5) ; (b = 6);
A. the question mark should be an equal sign
B. the first semicolon should be a colon
C. there are too many variables in the statement
D. the conditional operator is only used with apstrings
Answer : D
42. If the class name is X, what is the type of its “this” pointer (in a nonstatic, non-const member function)?
A. const X* const
B. X* const
C. X*
D. X&
Answer : D
43. Which of the following correctly describes C++ language?
A. Statically typed language
B. Dynamically typed language
C. Both Statically and dynamically typed language
D. Type-less language
Answer : D
44. There are total ------ numbers of operators in 'C'.
A. 35
B. 45
C. 55
D. 40
Answer : B
45. Which among the following is a unconditional control structure
A. do-while
B. if-else
C. goto
D. for
Answer : C
46. Which of the following keyword supports dynamic method resolution?
A. abstract
B. Virtual
C. Dynamic
D. Typeid
Answer : A
47. Which of the following is not a preprocessor directive
A. #if
B. #elseif
C. #undef
D. #pragma
Answer : B
48. All elements of a structure are allocated contiguous memory locations.
A. True
B. False
C.
D.
Answer : A
49. What is the right way to access value of structure variable book{ price, page }?
A. printf("%d%d", book.price, book.page);
B. printf("%d%d", price.book, page.book);
C. printf("%d%d"< price::book< page::book);
D. printf("%d%d", price?>book, page?>book);
Answer : A
50. 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

Sharing is caring