C++ Arithmetic Operator Order of precedence for primary operators

Description

C++ Arithmetic Operator Order of precedence for primary operators

Order      Operator//from   w ww .j ava2s.co  m
First      Multiplication, division, modulus remainder (*, /, %)
Second     Addition, subtraction (+, -)
#include <iostream>
using namespace std;
int main()
{
   float avg, grade1, grade2, grade3;
   grade1 = 87.5;
   grade2 = 92.4;
   grade3 = 79.6;
   avg = grade1 + grade2 + grade3 / 3.0;
   cout << "The average is " << avg << "\n";
   return 0;
}



PreviousNext

Related