Saturday, November 14, 2009

Mathematical Operators


C++ Mathematical Operators

Addition (+)
Subtraction (-)
Multiplication (*)
Division (/)
Modulo (%)

A c++ program example that demonstrate the use of mathematical operators.


/* A C++ Program Example that performs Addition , Subtraction, Multiplication, Division and Modulo */

#include <iostream>

int main ()
{

    using std::cout;
    using std::endl;

    int a = 9, b = 4;

    cout << "Addition is : " << a + b << endl;
    cout << "Subtraction is : " << a - b << endl;
    cout << "Multiplication is : "<< a * b << endl;
    cout << "Division is : " << a / b << endl;
    cout << "Modulo is : " << a % b << endl;

    return 0;
}


Note :

Modulo operator is also known as remainder operator.

Please do comment if you don't understand any part or want to know more or just want to say thanks. I love programming and love to teach my friends. Your suggestions and appreciation will make this blog much better.
Want to learn more? View List Of All Chapters

4 comments: