// Robert A. Simpson

// course number cs132

// sept. 1,1997

// unit 1

// This is my first C++ program !

// I will ask for 3 integers, then I will have the computer

// print the average, product, smallest and largest of the

// 3 integers.

// This will tell the C++ program what files I need to run my program

#include <iostream.h>

// This is the main part of the program.

main()

{

// declare all variables that will be used in the program

int a; // First number

int b; // Second number

int c; // Third number

int sum; // sum of all numbers

int ave; // average of all numbers

int pro; // product of all numbers

int sm; // smallest of all numbers

int lg; // largest of all numbers

// This will ask for 3 integers

cout <<"Enter three(3) integers: ";

cin >>a;

cin >>b;

cin >>c;

// This will compute the numbers.

sum=a+b+c;

pro=a*b*c;

ave=sum/3;

sm=a;

if (sm>b)

sm=b;

if (sm>c)

sm=c;

lg=a;

if (lg<b)

lg=b;

if (lg<c)

lg=c;

// This will print the results.

cout <<" " <<endl;

cout <<"The sum is " << sum <<endl;

cout <<"The average is " << ave <<endl;

cout <<"The product is " << pro <<endl;

cout <<"The smallest is " << sm <<endl;

cout <<"The largest is " << lg <<endl;

return 0;

}

program list

Home Page