1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
|
#include <iostream>
#include <string>
using namespace std;
//Fucntion Prototypes
int totalOfAges(int& firstAge, int& secondAge, int& thirdAge, int& total);
int averageOfAges(int& firstAge, int& secondAge, int& thirdAge, int& average);
int candlesBlownOut(int& firstAge, int& secondAge, int& thirdAge, int& candles);
int main()
{
string firstName, secondName, thirdName;
int firstAge, secondAge, thirdAge;
int total, average, candles;
cout << "Input first name of first person. " ;
cin >> firstName;
cout << "Input first person's age. ";
cin >> firstAge;
cout << "Input first name of second person. ";
cin >> secondName;
cout << "Input second person's age. ";
cin >> secondAge;
cout << "Input first name of third person. ";
cin >> thirdName;
cout << "Input third person's age. ";
cin >> thirdAge;
cout << firstName << "is " << firstAge << "and has blown out " << candles << " birthday candles. " << endl;
cout << secondName << "is " << secondAge << "and has blown out " << candles << " birthday candles. " << endl;
cout << thirdName << "is " << thirdAge << "and has blown out " << candles << " birthday candles. " << endl;
cout << "The total of all ages is " << total << "." << endl;
cout << "The average age is " << average << ".";
return 0;
}
int totalOfAges(int& firstAge, int& secondAge, int& thirdAge, int&total)
{
total = firstAge + secondAge + thirdAge;
return total;
}
int averageOfAges(int& firstAge, int& secondAge, int& thirdAge, int &average)
{
average = (firstAge + secondAge + thirdAge)/3;
return average;
}
int candlesBlownOut(int& firstAge, int& secondAge, int& thirdAge, int &candles)
{
candles = 2;
return candles;
}
|