Loops

Here I will explain you all most common and basic commands in C++.

iostream

This is a library that provides input and output operations. It includes the cout and cin objects for console output and input, respectively. Example:

#include <iostream>

int main() {
    std::cout << "Hello, world!" << std::endl;
    int num;
    std::cin >> num;
    return 0;
}
  

Variables

Variables are used to store and manipulate data. They must be declared with a data type before use. Example:

int age = 25;       // Declaring and initializing an integer variable
double pi = 3.14;   // Declaring and initializing a double variable
char letter = 'A';  // Declaring and initializing a character variable
  

Operators

C++ provides various operators for performing arithmetic, assignment, comparison, and logical operations. Example:

int a = 5, b = 3;
int sum = a + b;        // Addition
int difference = a - b; // Subtraction
int product = a * b;    // Multiplication
int quotient = a / b;   // Division

bool isEqual = (a == b);   // Equality comparison
bool isGreater = (a > b);  // Greater than comparison

bool logicalAnd = (a > 0) && (b < 10);  // Logical AND
bool logicalOr = (a > 0) || (b < 10);   // Logical OR