{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

substitutes prog

substitutes prog - Sub program 1#include"stdafx.h#include...

This preview shows pages 1–3. Sign up to view the full content.

02/04/2010 Sub program 1 #include "stdafx.h" #include <iostream> using namespace std; int pmeter (); int nmeter (); double gallons (); double mpg ( int previous, int newm, double mpg); int main () { int previous, newm; double gal, fmpg; previous=pmeter(); newm=nmeter(); gal=gallons(); fmpg=mpg(previous, newm, gal); cout<< "Miles per gallon for the last tank of gas = " <<fmpg<<endl; return 0; } int pmeter () { int previous; cout<< "Previous odometer reading: " ; cin>>previous; return previous;} int nmeter() { int newm; cout<< "New odometer reading: " ; cin>>newm; return newm;} double gallons () { double gal; cout<< "Gallons needed to fill up the tank: " ; cin>>gal; return gal;} double mpg ( int previous, int newm, double gal) { double fmpg; fmpg=(newm-previous)/gal; return fmpg;} Sub Program 2 #include "stdafx.h" #include <iostream> using namespace std; double radius (); double diameter ( double r); double area ( double r); double circumference ( double r);

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
int main () { double r,d,a,c; { r=radius (); d=diameter (r); c=circumference(r); a=area (r); cout<<endl<< "Diameter of a circle with a radius= " <<r<< " is " <<d<<endl; cout<< "Circumference of a circle with a radius= " <<r<< " is " <<c<<endl; cout<< "Area of a circle with a radius= " <<r<< " is " <<a<<endl; } return 0; } double radius () { double r; cout<<endl<< "Input Radius: " ; cin>>r; while (r<0) { if (r<0) cout<<endl<< "The Radius must be a positive integer." <<endl;
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

Page1 / 8

substitutes prog - Sub program 1#include"stdafx.h#include...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online