First off this website has been my saving grace so far for my intro to C++ class.
Basically here is where i'm at:
My instructions are to:
Write a program solution to print all integer values between 1 and n that are multiples of 5 (i.e. evenly divisible by 5). This should be done with nested while loops. An inner while loop is controlled by a conditional expression determining when the last value for a particular n has been printed. An outer while loop should allow the user to enter a value, provide output for it, and then decide if he will enter a new value or quit.
So far my code is:
The problem I am having is when I enter Y to run another number, and enter my new number, it doesnt count multiples of 5 from zero, it starts off where I left off on the previous program.Code:#include <iostream>
using namespace std;
int main()
{
int x,a=0;
char choice;
do
{
system ("cls");
cout<< " Enter a number to see all multiples of 5 "<<endl;
cin>> x ;
cout<<" Multiples " << endl;
while (x>=a)
{
cout<< a << endl;
a=a+5;
}
cout<< " Try another number? Enter Y/N " <<endl;
cin>> choice;
}
while (choice == 'Y' || choice == 'y');
}
I just dont know where to go from here.
Thanks for any help!