Podcast
Questions and Answers
What is the only function that all C++ programs must contain?
What is the only function that all C++ programs must contain?
What is the purpose of comments in a C++ program?
What is the purpose of comments in a C++ program?
What is a location in the computer's memory that may contain different values at various times throughout the execution of a program?
What is a location in the computer's memory that may contain different values at various times throughout the execution of a program?
Which of the following is a valid variable name in C++?
Which of the following is a valid variable name in C++?
Signup and view all the answers
Which of the following data types is assigned only an integer value 1 or 0?
Which of the following data types is assigned only an integer value 1 or 0?
Signup and view all the answers
What is the correct way to declare a variable as a string?
What is the correct way to declare a variable as a string?
Signup and view all the answers
Which of the following is a valid variable declaration?
Which of the following is a valid variable declaration?
Signup and view all the answers
What is the object used to input values from the keyboard?
What is the object used to input values from the keyboard?
Signup and view all the answers
What is the correct way to declare a constant variable?
What is the correct way to declare a constant variable?
Signup and view all the answers
What is the output of the statement cout << x + y << endl;
What is the output of the statement cout << x + y << endl;
Signup and view all the answers
Study Notes
C++ Basics
- The only function that C++ programs must contain is main().
Code Blocks
- Code blocks in C++ are signaled by { and } punctuation.
Statements
- Every statement in C++ should end with a ; (semicolon).
- . (dot) is not used to end statements.
Comments
- Comments are used to document a program and improve its readability.
- Comments can be written using / */*, but not \.
- Comments are neglected by the compiler.
- Comments can be written anywhere in the program, not just at the top.
Variables
- A variable is a location in the computer's memory that may contain different values at various times throughout the execution of a program.
- Variable names can start with _ (underscore), but not with a number or space.
- A valid variable name is delta_univ, but not delte univ or delta-univ.
Data Types
- bool is a data type that can only be assigned an integer value of 1 or 0.
- float and double are valid data types, but real is not.
- char is a data type used to define a single character, and can be declared as char ch = 'Z';.
Variable Declaration
- A valid variable declaration is int a;, but not int a,, int a, or int a:.
Constants
- A correct declaration of a constant is const float PI = 3.14;, but not float PI 3.14; or # define PI = 3.14;.
Input/Output Objects
- The object used to print information on the screen is cout.
- The object used to input a value from the keyboard is cin.
Studying That Suits You
Use AI to generate personalized quizzes and flashcards to suit your learning preferences.
Related Documents
Description
Test your knowledge of the fundamental concepts of C++ programming language, including functions and code blocks.