0% found this document useful (0 votes)
4 views

Practice Questions Computer Programing II

The document contains 50 comprehensive practice questions on computer programming and C++, including multiple-choice, true/false, fill-in-the-blank, and short-answer formats. Key topics covered include C++ syntax, data types, operators, functions, and the use of header files. It serves as a resource for reinforcing knowledge and understanding of C++ programming concepts.

Uploaded by

akliluasebot
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Practice Questions Computer Programing II

The document contains 50 comprehensive practice questions on computer programming and C++, including multiple-choice, true/false, fill-in-the-blank, and short-answer formats. Key topics covered include C++ syntax, data types, operators, functions, and the use of header files. It serves as a resource for reinforcing knowledge and understanding of C++ programming concepts.

Uploaded by

akliluasebot
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

Practice Questions Computer programing II

Here are 50 comprehensive practice questions based on the concepts from the uploaded file
about computer programming and C++.
Multiple-Choice Questions (30)
1. What does the term "computer" refer to?
• a) A device that processes data
• b) An acronym for "Common Operating Machine Particularly Used for Technical
Education and Research"
• c) An electronic device for fast calculation
• d) A system for storing and retrieving data
• Answer: c) An electronic device for fast calculation
2. Which of the following is NOT a feature of a computer program?
• a) Executes instructions provided by the user
• b) Written using a programming language
• c) Can be run on multiple platforms without modification
• d) Provides instructions to a CPU
• Answer: c) Can be run on multiple platforms without modification
3. What does "syntax" in a programming language describe?
• a) The meaning of combinations of symbols
• b) The rules for the combination of symbols
• c) The function of each command in a program
• d) The logical structure of a program
• Answer: b) The rules for the combination of symbols
4. Which of the following is true about C++?
• a) C++ is a purely object-oriented language
• b) C++ is case-insensitive
• c) C++ supports both procedural and object-oriented programming
• d) C++ is a scripting language
• Answer: c) C++ supports both procedural and object-oriented programming
5. Which statement is true about C++?
• a) C++ is not case-sensitive
• b) C++ supports object-oriented programming
• c) C++ programs do not require a compiler
• d) C++ does not support multiple header files
• Answer: b) C++ supports object-oriented programming
6. Which operator is used for output in C++?
• a) cin
• b) cout
• c) scanf
• d) printf
• Answer: b) cout
7. Which of the following is the correct syntax to include the iostream header file in
C++?
• a) # include "iostream.h"
• b) #include
• c) # include
• d) #include "iostream"
• Answer: b) #include
8. What does the 'return 0;' statement do in the main function?
• a) Terminates the program with an error code
• b) Ends the main function and returns control to the operating system
• c) Starts the program
• d) Exits the program without any effect
• Answer: b) Ends the main function and returns control to the operating system
9. Which of the following is a valid identifier in C++?
• a) 2salary
• b) _salary
• c) first-name
• d) char
• Answer: b) _salary
10. Which data type has the highest precision in C++?
• a) int
• b) float
• c) double
• d) long
• Answer: c) double
11. What is the purpose of a header file in C++?
• a) To define the main function
• b) To include library functions and declarations
• c) To store global variables
• d) To compile the program
• Answer: b) To include library functions and declarations
12. Which of the following data types can be modified with the 'unsigned' modifier in
C++?
• a) int
• b) char
• c) double
• d) All of the above
• Answer: a) int
13. Which operator in C++ is used to increment the value of a variable by 1?
• a) --
• b) +=
• c) ++
• d) **
• Answer: c) ++
14. What is the result of the expression 5 + 3 * 2 in C++?
• a) 16
• b) 11
• c) 13
• d) 10
• Answer: b) 11
15. Which keyword is used to define a constant in C++?
• a) constant
• b) const
• c) define
• d) static
• Answer: b) const
16. What is the size of a 'double' data type in C++?
• a) 2 bytes
• b) 4 bytes
• c) 8 bytes
• d) 16 bytes
• Answer: c) 8 bytes
17. What is the function of the 'cin' object in C++?
• a) To output data
• b) To read input from the user
• c) To define variables
• d) To compile the program
• Answer: b) To read input from the user
18. Which of the following is NOT a valid keyword in C++?
• a) break
• b) continue
• c) switch
• d) assign
• Answer: d) assign
19. Which of the following is a correct declaration of a variable in C++?
• a) int age = 25;
• b) int 25age;
• c) age int = 25;
• d) 25 int age;
• Answer: a) int age = 25;
20. Which function starts the execution of a C++ program?
• a) main()
• b) start()
• c) execute()
• d) init()
• Answer: a) main()
21. Which statement is true about the 'void main()' function in C++?
• a) It must always return an integer value
• b) It is used for programs that do not require a return value
• c) It is deprecated in modern C++
• d) It is only used for recursive programs
• Answer: b) It is used for programs that do not require a return value
22. Which of the following symbols represents a comment in C++?
• a) //
• b) /* */
• c) #
• d) All of the above
• Answer: d) All of the above
23. Which operator is used to check if two values are equal in C++?
• a) =
• b) ==
• c) !=
• d) >
• Answer: b) ==
24. What is the correct syntax for defining an integer variable in C++?
• a) int var;
• b) var int;
• c) integer var;
• d) var = int;
• Answer: a) int var;
25. Which of the following is an example of a relational operator in C++?
• a) +
• b) >
• c) &&
• d) ++
• Answer: b) >
26. Which of the following C++ keywords is used to define a function?
• a) function
• b) def
• c) void
• d) return
• Answer: c) void
27. Which of the following is an example of implicit type casting in C++?
• a) (int)3.14
• b) double(3)
• c) i = i + d;
• d) (float) 12
• Answer: c) i = i + d;
28. Which header file is needed to use the 'cin' and 'cout' objects in C++?
• a) <stdio.h>
• b)
• c) <iostream.h>
• d) <math.h>
• Answer: b)
29. What is the default return type of the 'main' function in C++?
• a) void
• b) int
• c) char
• d) float
• Answer: b) int
30. Which operator is used for modulus operation in C++?
• a) %
• b) /
• c) ^
• d) *
• Answer: a) %
True/False Questions (10)
31. C++ supports both object-oriented and procedural programming.
Answer: True
32. In C++, a variable must be declared before it is used.
Answer: True
33. The return type of the 'main' function in C++ is always void.
Answer: False
34. C++ requires that every program includes a header file.
Answer: True
35. In C++, a 'double' type variable can hold decimal values.
Answer: True
36. C++ keywords are case-insensitive.
Answer: False
37. Comments in C++ are executed by the compiler.
Answer: False
38. The size of a 'char' variable in C++ is typically 1 byte.
Answer: True
39. In C++, the assignment operator '=' is used for comparison.
Answer: False
40. The 'cin' object is used for output in C++.
Answer: False
Fill-in-the-Blank Questions (5)
41. The __________ operator in C++ is used for checking equality between two values.
Answer: ==
42. A __________ in C++ is a block of code that can be executed by calling its name.
Answer: function
43. In C++, a __________ is used to store a value that cannot be changed after
initialization.
Answer: constant
44. C++ programs require a __________ to compile and run the code.
Answer: compiler
45. The __________ symbol is used to denote the beginning of a comment in C++.
Answer: //
Short-Answer Questions (5)
46. Explain the difference between 'int main()' and 'void main()' in C++.
Answer: 'int main()' returns an integer value to the operating system, usually 0 to indicate
successful execution, while 'void main()' does not return any value.
47. What is a 'header file' in C++?
Answer: A header file in C++ is used to declare functions, variables, and constants that are used
across multiple files, often including standard library functions.
48. Describe the purpose of the 'return 0;' statement in the 'main' function.
Answer: The 'return 0;' statement indicates that the program has executed successfully and
returns control to the operating system.
49. What is the difference between 'cin' and 'cout' in C++?
Answer: 'cin' is used to take input from the user, while 'cout' is used to output data to the screen.
50. What is a constant in C++ and how is it declared?
Answer: A constant in C++ is a variable whose value cannot be changed after initialization. It is
declared using the 'const' keyword.

You might also like