Introduction to C++ Programming: Basics, Syntax,
and Object-Oriented Concepts
1. What is the purpose of comments in C++?: To document programs and help others under-
stand them; ignored by the compiler.
2. What is the role of the #include directive?: It includes the contents of the input/output stream
header <iostream> before the program is compiled.
3. What happens if you forget to include the <iostream> header?: The compiler will
issue an error message.
4. What is the significance of the main() function in C++?: It is the entry point of every C++
program where execution begins.
5. What does the 'int' keyword indicate in the main() function?: It indicates that the
main function returns an integer value.
6. What is an output statement in C++?: It instructs the program to print characters contained
between double quotes.
7. What is a common programming error related to statement termination?: -
Omitting the semicolon (;) at the end of a statement is a syntax error.
8. What is the purpose of good programming practice regarding indentation?-
: To make the program's functional structure stand out and easier to read.
9. What does std::cout represent?: It specifies that we are using the cout name from the std
namespace.
10. What is the function of the stream insertion operator (<<)?: It inserts the value to
its right into the output stream.
11. What is an escape sequence in C++?: A combination of a backslash and another character that
represents a special character.
12. What does the escape sequence \n do?: It causes the cursor to move to the beginning of the
next line on the screen.
13. What does the return statement do in the main function?: It indicates that the
program has terminated successfully.
14. What is a variable in C++?: A location in memory where a value can be stored for use by a program.
15. What are fundamental types in C++?: Data types such as int, double, and char.
1/8
, 16. What does the type double specify?: It specifies real numbers, which can have decimal points.
17. What is an identifier in C++?: A series of characters consisting of letters, digits, and underscores
that does not begin with a digit.
2/8
and Object-Oriented Concepts
1. What is the purpose of comments in C++?: To document programs and help others under-
stand them; ignored by the compiler.
2. What is the role of the #include directive?: It includes the contents of the input/output stream
header <iostream> before the program is compiled.
3. What happens if you forget to include the <iostream> header?: The compiler will
issue an error message.
4. What is the significance of the main() function in C++?: It is the entry point of every C++
program where execution begins.
5. What does the 'int' keyword indicate in the main() function?: It indicates that the
main function returns an integer value.
6. What is an output statement in C++?: It instructs the program to print characters contained
between double quotes.
7. What is a common programming error related to statement termination?: -
Omitting the semicolon (;) at the end of a statement is a syntax error.
8. What is the purpose of good programming practice regarding indentation?-
: To make the program's functional structure stand out and easier to read.
9. What does std::cout represent?: It specifies that we are using the cout name from the std
namespace.
10. What is the function of the stream insertion operator (<<)?: It inserts the value to
its right into the output stream.
11. What is an escape sequence in C++?: A combination of a backslash and another character that
represents a special character.
12. What does the escape sequence \n do?: It causes the cursor to move to the beginning of the
next line on the screen.
13. What does the return statement do in the main function?: It indicates that the
program has terminated successfully.
14. What is a variable in C++?: A location in memory where a value can be stored for use by a program.
15. What are fundamental types in C++?: Data types such as int, double, and char.
1/8
, 16. What does the type double specify?: It specifies real numbers, which can have decimal points.
17. What is an identifier in C++?: A series of characters consisting of letters, digits, and underscores
that does not begin with a digit.
2/8