C++ Tutorial Keywords
Syntax
- Keywords: C++ has 84 keywords that are reserved and cannot be used as variable names or identifiers.
- Data Types: C++ supports various data types such as int, float, double, char, etc.
- Operators: C++ supports various operators such as arithmetic, relational, logical, etc.
Example
#include <iostream>
using namespace std;
int main() {
int num1 = 5;
int num2 = 10;
int sum = num1 + num2;
cout << "Sum of " << num1 << " and " << num2 << " is " << sum;
return 0;
}
Output
Sum of 5 and 10 is 15
Explanation
In the above example, we have declared two integer variables num1
and num2
and performed addition using the +
operator and stored the result in another integer variable sum
. The final output is displayed using the cout
statement.
Use
Keywords are a fundamental part of the C++ language, and one must have a good understanding of them to write efficient programs. By using the right keywords, one can declare variables, control the flow of the program, and perform various operations.
Important Points
- Keywords in C++ are reserved and cannot be used as variable names or identifiers.
- C++ supports various data types such as int, float, double, char, etc.
- C++ supports various operators such as arithmetic, relational, logical, etc.
Summary
In this tutorial, we learned about the syntax and examples of various C++ keywords, their use, important points to keep in mind, and a brief overview of data types and operators in C++.