C++ is a powerful general-purpose programming language. It was created by Bjarne Stroustrup in 1979 at Bell Laboratories. It is used to develop operating systems, browsers, games, and other applications. C++ supports mainly support programming like object oriented. C++ is a flexible language aims to make writing programs easier and more pleasant for the individual programmer.
Reserved words are keywords that have standard predefined meanings in C++ language. These keywords can only be used for their intended purpose; they cannot be used as programmer defined identifiers.
The following list the keywords or reserved words of the C++ language:
Keyword | Keyword | Keyword | Keyword |
---|---|---|---|
asm | else | new | this |
auto | enum | operator | throw |
bool | explicit | private | true |
break | export | protected | try |
case | extern | public | typedef |
catch | false | register | typed |
char | float | reinterpret_cast | TypeName |
class | for | return | union |
const | friend | short | unsigned |
const_cast | goto | signed | using |
continue | if | sizeof | virtual |
default | inline | static | void |
delete | int | static_cast | volatile |
do | long | struct | wchar_t |
double | mutable | switch | while |
dynamic_cast | namespace | template | and |
or | not | requires | nullptr |
Data values passed in a program may be of different types. Each of these data types are represented differently within the computer’s memory and have different memory requirements. These data types can be augmented by the use of data type qualifiers / modifiers.
The data types supported in C++ are described below:
Data Type | Keyword | Size | Range |
---|---|---|---|
Boolean | bool | 1 Byte | 0 (false), 1 (true) |
Character | char | 1 Byte | -127 to 127 OR 0 to 255 |
Integer | int | 4 Bytes | -2,147,483,648 to 2,147,483,647 |
Floating Point | float | 4 Bytes | 1.5 x 10^-45 to 3.4 x 10^38 |
Double Floating Point | double | 8 Bytes | 5.0 x 10^-345 to 1.7 x 10^308 |
A constant is an identifier whose value remains unchanged throughout the program. Constants are used in two ways, they are:
⦁ Literal Constants
⦁ Defined Constants
Literal constants are data used for representing fixed values. They can be used directly in the code.
Example: 1, 2.5, ‘c’, “good” etc.
In C++, we can create symbolic constant whose value remains unchanged but used as a variable. A symbolic constant can be created using the #define preprocessor directive or const keyword.
const int LIGHT_SPEED=299792458;
#define LIGHT SPEED 299792458
A variable is nothing but a name given to a storage area that our programs can manipulate. Its value can change during program execution. Each variable in C++ has a specific data type, which determines the size and layout of the variable’s memory.
• A variable name contains alphabets, numbers, and the underscore.
• A variable name must start with a letter or an underscore.
• Variable names are case sensitive. (Sum and sum are different)
• A variable name cannot be a keyword.
• A variable name cannot be longer than 32 characters.
Variable declaration is a process in which we create storage space for variable in memory. A variable declaration consists of data type and name of the variable written as follow: data_type variable_name;
int sum;
Assign initial value to a variable is known as variable initialization. It can be initialized during declaration or separately. The equal sign is used to assign value written as follows: data_type variable_name = value;
int sum = 3;
Variables that can store alphanumeric value that consist of multiple characters are called strings. In C++, strings are used by one-dimensional array of characters, which is terminated by a null character \0.
0 of 10 Questions completed
Questions:
You have already completed the quiz before. Hence you can not start it again.
Quiz is loading…
You must sign in or sign up to start the quiz.
You must first complete the following:
0 of 10 Questions answered correctly
Your time:
Time has elapsed
You have reached 0 of 0 point(s), (0)
Earned Point(s): 0 of 0, (0)
0 Essay(s) Pending (Possible Point(s): 0)
Which of the following is a reserved word in C++?
What is the size of the “float” data type in C++?
How can you define a symbolic constant in C++ using the “const” keyword?
Which of the following is NOT a rule for naming variables in C++?
What is the process of creating storage space for a variable in memory called?
How can you initialize a variable during declaration in C++?
Which data type is used to store alphanumeric values consisting of multiple characters in C++?
How is a string terminated in C++?
Who created the C++ programming language?
What is the size of the “bool” data type in C++?