#include <iostream>//required to perform C++ stream I/O
#include <iomanip>//required to manipulate C++ I/O Stream
using namespace std;//for accessing C++ Library Members
//function begins main program execution
int main ()
{
//define variables
float sum;//the total of three input numbers
float average;//the three input numbers divided by 3
float first_number;//the first number the user enters
float second_number;//the second number the user enters
float third_number;//the third number the user enters
float median;//the middle number when three numbers are arranged in order
float maximum;//the largest of the three input numbers
float minimum;//the smallest of the three input numbers
cout << "This program will determine the sum, average, median,\n maximum and minimum of three input numbers.";//Display program information to the user
cout << "\nPlease input the first number: ";//prompt user for input
cin >> first_number;//gets input from user
cout << "\nPlease input the second number: ";//prompt user for input
cin >> second_number;//gets input from user
cout << "\nPlease input the third number: " ; //prompt user for input
cin >> third_number; //gets input from user
cout << "\nThe three numbers entered are: " <<first_number <<second_number <<third_number <<endl;//displays input to user
sum=(first_number+second_number+third_number); //calculates value of all 3 numbers that user input
cout << "\nThe sum is : " <<sum<<endl; //displays sum calculation result to user
average=(first_number+second_number+third_number)/3; //calculates average of three numbers entered
cout << "\nThe average is: " <<average<<endl; //displays average calculation result to user
if (first_number >= second_number && first_number <=third_number) //evaluates the size of the number
cout << "\nThe median number is " <<median <<endl; //outputs median to user if logical conditions are met
else
if (second_number >= first_number && second_number <= third_number) //evaluates the size of the number
cout << "\nThe median number is " <<median <<endl; //outputs median to user if logical conditions are met
else
cout << "\nThe median is: " <<median <<endl; //displays median number to user
if (first_number > second_number && first_number >third_number) //evaluates the size of the number
cout << "\nThe maximum number is " <<maximum <<endl; //outputs evaluation to user if logical conditions are met
else
if (second_number > first_number && second_number > third_number) //evaluates the size of the number
cout << "\nThe maximum number is " <<maximum <<endl; //outputs evaluation to user if logical conditions are met
else
cout << "\nThe maximum number is " <<maximum <<endl; //outputs evaluation to user if logical conditions are met
if (first_number < second_number && first_number < third_number) //evaluates the size of the number
cout << "\nThe minimum number is " <<minimum <<endl; //outputs evaluation to user if logical conditions are met
else
if (second_number < first_number && second_number < third_number) //evaluates the size of the number
cout << "\nThe minimum number is " <<minimum <<endl; //outputs evaluation to user if logical conditions are met
else
cout << "\nThe minimum number is " <<minimum <<endl; //outputs evaluation to user if logical conditions are met
return 0;
1>e:\intro2programming\project3\p3ktg\p3ktg\p3ktg.cpp(52) : warning C4700: uninitialized local variable 'median' used
1>e:\intro2programming\project3\p3ktg\p3ktg\p3ktg.cpp(61) : warning C4700: uninitialized local variable 'maximum' used
1>e:\intro2programming\project3\p3ktg\p3ktg\p3ktg.cpp(70) : warning C4700: uninitialized local variable 'minimum' used
If I can get the teacher to accept this error free, I might just make a B
#include <iostream>//required to perform C++ stream I/O
#include <iomanip>//required to manipulate C++ I/O Stream
usingnamespace std;//for accessing C++ Library Members
//function begins main program execution
int main ()
{
//define variables
float sum;
float average;
float first_number; // dont need
float second_number; //dont need
float third_number; // dont need
cout << "This program will determine the sum, average, median,\n maximum and minimum of three input numbers.";
cout << "\nPlease input the first number: ";
cin >> first_number;
cout << "\nPlease input the second number: ";
cin >> second_number;
cout << "\nPlease input the third number: " ;
cin >> third_number;
cout << "\nThe three numbers entered are: " <<first_number <<second_number <<third_number <<endl;
sum=(first_number+second_number+third_number);
cout << "\nThe sum is : " <<sum<<endl;
average=(first_number+second_number+third_number)/3;
cout << "\nThe average is: " <<average<<endl;
if (first_number >= second_number && first_number <=third_number)
cout << "\nThe median number is " << first_number << endl;
elseif (second_number >= first_number && second_number <= third_number)
cout << "\nThe median number is " << second_number <<endl;
else
cout << "\nThe median is: " <<third_number <<endl;
if (first_number > second_number && first_number >third_number) //evaluates the size of the number
cout << "\nThe maximum number is " <<first_number <<endl; //outputs evaluation to user if logical conditions are met
elseif (second_number > first_number && second_number > third_number) //evaluates the size of the number
cout << "\nThe maximum number is " <<second_number <<endl; //outputs evaluation to user if logical conditions are met
else
cout << "\nThe maximum number is " <<third_number <<endl; //outputs evaluation to user if logical conditions are met
if (first_number < second_number && first_number < third_number) //evaluates the size of the number
cout << "\nThe minimum number is " <<first_number <<endl; //outputs evaluation to user if logical conditions are met
elseif (second_number < first_number && second_number < third_number) //evaluates the size of the number
cout << "\nThe minimum number is " <<second_number <<endl; //outputs evaluation to user if logical conditions are met
else
cout << "\nThe minimum number is " <<third_number <<endl; //outputs evaluation to user if logical conditions are met
system("pause");
return 0;}
Uninitialized variable means that you are using a variable that has no set value. Initialize all of your variables to zero or some other value before you use them. (Unless there is input that initializes them)
Also that code is error free, those are just warnings.