Double type with declaration and initialization - C++ Data Type

C++ examples for Data Type:double

Description

Double type with declaration and initialization

Demo Code

#include <iostream>
using namespace std;
int main()//from  ww w  .java2s .  c  o  m
{
   double grade1 = 85.5;
   double grade2 = 97.0;
   double total, average;
   total = grade1 + grade2;
   average = total/2.0; // divide the total by 2.0
   cout << "The average grade is " << average << endl;
   return 0;
}

Result


Related Tutorials