C++ Arithmetic Operator Introduction

Introduction

Operation Operator SymbolType
Addition+ Binary
Subtraction - Binary
Multiplication * Binary
Division/ Binary
Modulus% Binary
Negation- Unary

The following code shows using cout to display the results of arithmetic expressions in the statements of a complete program.

#include <iostream>
using namespace std;
int main()//www  . ja  va 2s . c  o m
{
   cout << "15.0 plus 2.0 equals "       << (15.0 + 2.0) << endl
   << "15.0 minus 2.0 equals "      << (15.0 - 2.0) << endl
   << "15.0 times 2.0 equals "      << (15.0 * 2.0) << endl
   << "15.0 divided by 2.0 equals " << (15.0 / 2.0) << endl;
   return 0;
}



PreviousNext

Related