1. Which of the following extension is used for user-defined header file in c++?
a) hg
b) cpp
c) h
d) hf
2. Which of the following is a correct identifier in C++?
a) VAR_1234
b) $var_name
c) 7VARNAME
d) 7var_named
3. Which keyword is used to define the macros in c++?
a) #macro
b) #define
c) macro
d) define
4. Which of the following symbol is used to declare the preprocessor directives in C++?
a) $
b) ^
c) #
d) *
5. What are the actual parameters in C++?
a) Parameters with which functions are called
b) Parameters which are used in the definition of a function
c) Variables other than passed parameters in a function
d) Variables that are never used in the function
6. What are the formal parameters in C++?
a) Parameters with which functions are called
b) Parameters which are used in the definition of the function
c) Variables other than passed parameters in a function
d) Variables that are never used in the function
7. Which function is used to read a single character from the console in C++?
a) cin.get(ch)
b) getline(ch)
c) read(ch)
d) scanf(ch)
8. Which of the following escape sequence represents carriage return?
a) \r
b) \n
c) \n\r
d) \c
9. Which of the following is called insertion/put to operator?
a) <<
b) >>
c) >
d) <
10. Which of the following is the scope resolution operator?
a) .
b) *
c) ::
d) ~
11. Which of the following correctly declares an array?
a) int array[10];
b) int array;
c) array{10};
d) array array[10];
12. What is the index number of the last element of an array with 9 elements?
a) 9
b) 8
c) 0
d) Programmer-defined
13. How many characters are specified in the ASCII scheme?
a) 64
b) 128
c) 256
d) 24
14. Which data type is used to represent the absence of parameters?
a) int
b) short
c) void
d) float
15. Which statement is used to exit a loop prematurely in C++?
a) break
b) continue
c) return
d) exit
16. What does cin do in C++?
a) Outputs data
b) Takes input
c) Performs calculations
d) Defines variables
17. The switch statement is an alternative for:
a) if
b) if-else
c) if-else-if
d) all of the above
18. Which header file is required for using cout and cin?
a) stdlib.h
b) iostream
c) conio.h
d) math.h
19. Which keyword is used to define a constant variable in C++?
a) constant
b) const
c) define
d) static
20. What is the correct syntax to declare a pointer?
a) int ptr;
b) int *ptr;
c) int &ptr;
d) pointer int ptr;
21. Which of the following is not a valid variable name in C++?
a) _num
b) num_1
c) 1num
d) myNum
22. The process of translating high-level language into machine code is called:
a) Compilation
b) Execution
c) Debugging
d) Linking
23. Which operator is used for address retrieval in C++?
a) *
b) &
c) #
d) @
24. What will be the output of cout << 7 % 3;?
a) 1
b) 2
c) 3
d) 4
25. The execution of a function begins from:
a) void main()
b) start()
c) int main()
d) execute()
26. Which loop is guaranteed to execute at least once?
a) for loop
b) while loop
c) do-while loop
d) none of the above
27. Which of the following is an entry-controlled loop?
a) for
b) while
c) both a and b
d) do-while
28. What will be the value of x after execution of the statement: x = (5 > 2) ? 10 : 20;?
a) 5
b) 2
c) 10
d) 20
29. What is the size of an integer variable in C++ (typically)?
a) 2 bytes
b) 4 bytes
c) 8 bytes
d) Depends on the system
30. Which of the following is a valid C++ function definition?
a) int sum(int a, int b) { return a + b; }
b) sum(int a, int b) { return a + b; }
c) int sum(a, b) { return a + b; }
d) sum(a, b) { return a + b; }
31. What is the default value of an uninitialized integer variable in C++?
a) 0
b) Garbage value
c) Null
d) Compiler error
32. Which of the following is used to dynamically allocate memory in C++?
a) malloc
b) calloc
c) new
d) free
33. What will be the output of cout << (4 > 3 && 2 < 5);?
a) true
b) false
c) 1
d) 0
34. Which of the following is a valid loop construct in C++?
a) for
b) while
c) do-while
d) all of the above
35. Which statement is used to exit a loop prematurely in C++?
a) break
b) continue
c) return
d) exit
36. What does cin do in C++?
a) Outputs data
b) Takes input
c) Performs calculations
d) Defines variables
37. The switch statement is an alternative for:
a) if
b) if-else
c) if-else-if
d) all of the above
38. Which header file is required for using cout and cin?
a) stdlib.h
b) iostream
c) conio.h
d) math.h
39. Which keyword is used to define a constant variable in C++?
a) constant
b) const
c) define
d) static
40. What is the correct syntax to declare a pointer?
a) int ptr;
b) int *ptr;
c) int &ptr;
d) pointer int ptr;