im guess i try to start over somewhat
im trying to use user data until the user inputs -1
if the user inputed say 4 5 -1
my output would look something like
a counter the number of integers used ie 2
the sum ie 9
the largest number ie 5
the smallest number ie 4
the product ie 20
the avg ie 4.5
-1 should not be used to calculate any of the data below
i could use some help
teach myself c++ in 24 hours isnt seeming to help
Code:
#include <iostream> /*for cin and cout*/
int main () /*function main*/
{
int x=0,x2=0,x3=0,sum=0,number=0,product=0,largest=0,smallest=0,flag=0; /*declaration of variables*/
float avg;
//if (flag != -1) //here's the start of the loop
// std::cout << "Please enter an interger" << std::endl; /*input data*/
// std::cin >> flag;
do {
std::cout << "Show this again? ( -1 for no ): ";
std::cin >> flag;
} while ( flag != -1 );
sum = x + x2 +x3; /*total score*/
avg = (sum)/2; /*average score*/
std::cout << "The number of the integers is" << number << std::endl;
std::cout << "The sum of the integers is" << sum << std::endl;
std::cout << "The average of the integers is " << avg << std::endl;
std::cout << "The product of the integers is " << product << std::endl;
std::cout << "The largest integers is " << largest << std::endl;
std::cout << "The smallest integers is " << smallest << std::endl;
return 0;
//here's where user decides to stop or continue
std::cout << "enter -1 to stop, anything to do it all over again" << std::endl;
std::cin >> flag;
}