Search
 
SCRIPT & CODE EXAMPLE
 

CPP

C++ Arithmetic Operators

    int a, b, sum, difference, product, quotient, remainder;
    //Using all arithmetic operators, choose what you're looking for

    cout << "ADDITION" << endl;
    cout << "
";
    cout << "Enter number: " << endl;
    cin >> a;
    cout << "Enter the second number: " << endl;
    cin >> b;
    sum = a + b;
    cout << "The sum is: " << sum << endl;
    cout << "
";

    cout << "SUBTRACTION" << endl;
    cout << "
";
    cout << "Enter number: " << endl;
    cin >> a;
    cout << "Enter the second number: " << endl;
    cin >> b;
    difference = a - b;
    cout << "The difference is: " << difference << endl;
    cout << "
";

    cout << "MULTIPLICATION" << endl;
    cout << "
";
    cout << "Enter number: " << endl;
    cin >> a;
    cout << "Enter the second number: " << endl;
    cin >> b;
    product = a * b;
    cout << "The product is: " << product << endl;
    cout << "
";

    cout << "DIVISION" << endl;
    cout << "
";
    cout << "Enter number: " << endl;
    cin >> a;
    cout << "Enter the second number: " << endl;
    cin >> b;
    quotient = a / b;
    cout << "The quotient is: " << quotient << endl;

    remainder = a % b;
    cout << "The remainder is: "<< remainder << endl;
Comment

C++ Arithmetic Operators

a + b;
Comment

PREVIOUS NEXT
Code Example
Cpp :: c++ prime sieve 
Cpp :: c++ segmented sieve primes 
Cpp :: primes in range cpp 
Cpp :: not in c++ 
Cpp :: string to decimal c++ strtol 
Cpp :: header file for unordered_map in c++ 
Cpp :: Story of c++ 
Cpp :: convert string toupper and tolower in cpp 
Cpp :: restting a queue stl 
Cpp :: c++ colored output 
Cpp :: c++ do while loop 
Cpp :: size of pointer array 
Cpp :: struct and pointer c++ 
Cpp :: stl sort in c++ 
Cpp :: cin.getline 
Cpp :: c++ pause linux 
Cpp :: cudamemcpy 
Cpp :: even and odd sum in c++ 
Cpp :: stack implementation using class in c++ 
Cpp :: sina + sinb formula 
Cpp :: how to convert ascii to char in cpp 
Cpp :: how to add external library in clion 
Cpp :: argument vs parameter coding c++ 
Cpp :: how to compare two char* in c++ 
Cpp :: print two dimensional array c++ 
Cpp :: position of max element in vector c++ 
Cpp :: gcc suppress warning inline 
Cpp :: c++ loop through list 
Cpp :: cpp #include "" < 
Cpp :: class operator overloading c++ 
ADD CONTENT
Topic
Content
Source link
Name
2+4 =