C++ Function Definition with its own local variable

Description

C++ Function Definition with its own local variable

#include <iostream>
using namespace std;
#include <iomanip.h>
compute_sale(int gallons); 
int main()//from  ww w  . ja  v  a2 s.  c om
{
   int gallons;
   cout << "How many gallons of paint did you buy? ";
   cin >> gallons;         
   compute_sale(gallons);  
   return 0;
}
compute_sale(int gallons)
{
   float price_per = 12.45;    
   cout << "The total is " << setprecision(2) << (price_per*(float)gallons) << "\n";
   return 0;                   
}



PreviousNext

Related