Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR 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;
 
PREVIOUS NEXT
Tagged: #Arithmetic #Operators
ADD COMMENT
Topic
Name
3+7 =