# Making of a basic calculator in C++ Part (2/8)

2
148 Hello guys, I hope you are enjoying this c++ programming series. So, the next things we need to know to make a calculator is how to perform mathematical operations. It is quite easy as we will see.

cout << 8+9 << endl;.

cout << 9-2 << endl;

cout << 8*2 << endl;

cout << 8/2 << endl;

cout << 9%2 << endl;

cout << 8%2 << endl;

I guess you can easily guess the output of the first four lines which is 17, 7, 16 and 4 respectively. What mighty you see new is “%” (modulo) operator. Modulo operator returns the remainder. Hence 9%2 is equal to 1 and 8%2 is equal to 0. The operators you saw above are called arithmetic operator.

#### Check the First Part Also

Before going further, we will study another data type which we skipped earlier. I know some of you might guess it and it is boolean. A variable with boolean data type can be assigned only two values true and false. As per the conventions, false is assigned value 0 and true can be assigned value of any non-zero integer (by default 1 is assigned for true).

### Examples…

cout << 8>9 << endl;

cout << 9>=2 << endl;

cout << 8==8 << endl;

First statement is false and hence output will be 0. Similarly for second statement output will be 1. “==” operator is used to check the equality of 2 statements. “>”, “>=”, “==” are called relational operator.