substitutes prog - 02/04/2010 Sub program 1 #include...

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

View Full Document Right Arrow Icon
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);
Background image of page 1

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

View Full DocumentRight Arrow Icon
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;
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 10/15/2010 for the course ECE ECE 114 / taught by Professor Yin during the Spring '10 term at Cal Poly Pomona.

Page1 / 8

substitutes prog - 02/04/2010 Sub program 1 #include...

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

View Full Document Right Arrow Icon
Ask a homework question - tutors are online