C++ operators


  Translation results:

C++ is a statically typed, compiled, general-purpose, case-sensitive, irregular programming language that supports procedural programming, object-oriented programming and generic programming.

C++ is considered a mid-level language that combines the features of high-level and low-level languages.

C++ was designed and developed by Bjarne Stroustrup in 1979 at Bell Laboratories in Murray Hill, New Jersey. C++ further extended and improved the C language, originally named C with classes and later renamed C++ in 1983.

C++ is a superset of C. In fact, any legal C program is a legal C++ program.

C++ operatorssyntax

An operator is a symbol that tells the compiler to perform a specific mathematical or logical operation. C++ has a rich set of built-in operators and provides the following types of operators:

Arithmetic operators

Relational operators

Logical operators

Bitwise operators

Assignment operators

Miscellaneous operators

C++ operatorsexample

#include <iostream>using namespace std;
int main(){
int a = 21; int b = 10; int c;
c = a + b; cout << "The value of Line 1 - c is " << c << endl ;
c = a - b; cout << "The value of Line 2 - c is " << c << endl ;
c = a * b; cout << "The value of Line 3 - c is " << c << endl ;
c = a / b; cout << "Line 4 - The value of c is " << c << endl ;
c = a % b; cout << "The value of Line 5 - c is " << c << endl ;
int d = 10; // Test self-increment and self-decrement
c = d++; cout << "Line 6 - The value of c is " << c << endl ;
d = 10; //Reassign
c = d--; cout << "Line 7 - the value of c is " << c << endl ; return 0;}

Popular Recommendations

Home

Videos

Q&A