Skip to Content

🔹 Input in C++

In C++, input is generally taken from the user using the cin object (stands for console input). It works with the extraction operator >>.

Example:

int age; cout << "Enter your age: "; cin >> age;

Here, the user enters a value which gets stored in the variable age.

🔹 Operators in C++

Operators are symbols that perform operations on variables and values. They are the building blocks of any program.

  1. Arithmetic Operators → + , - , * , / , % (used for mathematical calculations)

  2. Relational Operators → == , != , > , < , >= , <= (used for comparison, result is true/false)

  3. Logical Operators → && , || , ! (used to combine conditions)

  4. Assignment Operators → = , += , -= , *= , /= , %= (used to assign values)

  5. Increment/Decrement Operators → ++ , -- (used to increase or decrease value by 1)

  6. Bitwise Operators → & , | , ^ , ~ , << , >> (used for operations on binary numbers)

  7. Ternary Operator → condition ? value1 : value2; (short form of if-else)

Rating
0 0

There are no comments for now.

to be the first to leave a comment.