Hey, im pretty sure that uninitialized local variable means that something isnt declared properly..im not seeing it though. if someone could just point it out to me id be very grateful.
#include <iostream>
using namespace std;
int main ()
{
int numbers_entered = 0;
char letter;
double number;
double number_1;
double number_2;
double max = -1000;
double min = 1000;
do
{
cout<<"Please enter the number."<<endl;
cin>>number;
numbers_entered++;
if (number > max)
{ max = number_1;
}
else
{ min = number_2;
}
cout<<"Would you like to enter another number? (y/n)?";
cin>> letter;
}
while (letter == 'y' || letter == 'Y');
cout<<"You entered "<< numbers_entered <<" numbers." <<endl;
cout<<"The maximum number entered is "<< number_1 <<"and the minimum number entered is "<< number_2 <<"."<<endl;
return 0;
}
Problem: Create a program that uses a loop to ask the user to enter a series of numbers. The loop will count how many numbers are entered (complete) and determine the maximum and minimum values of the numbers enters(error).
#include <iostream>
usingnamespace std;
int main()
{
int numbers_entered = 0;
char letter;
double number;
double max;
double min;
do
{
cout << "Please enter the number." << endl;
cin >> number;
numbers_entered++;
if (numbers_entered==1) { max=number; min=number; } // first number entered
if (number > max) max = number;
if (number < min) min = number;
cout << "Would you like to enter another number? (y/n)? ";
cin >> letter;
} while (letter == 'y' || letter == 'Y');
cout << "You entered " << numbers_entered << " numbers." << endl;
cout << "The maximum number entered is " << max << " and the minimum number entered is " << min << "." << endl;
}