EDN Admin
Well-known member
Pretty simple program just stuck.
I need to use a user controlled loop to get multiples of 5. That part I have right and at the end display the largest number that is a multiple of 5 from the numbers I entered.
It works and tells whether the number is a multiple of five but when I select a key to stop it goes into a infinite loop. You can read the display and it also shows the largest multiple entered but it keeps looping and doesnt stop. I think it
is just a slight tweek but for the life of me cant find where??
Here is my code:
<pre class="prettyprint # include<iostream>
using namespace std;
int main ()
{
int Num=0,
MaxNum=0;
char again=y;
while(again==y||again==Y)
{
cout<<"Get multiples of 5 ";
cin>>Num;
{
if (Num % 5==0)
{
cout<<Num<<" is a multiple of 5"<<endl;
}
if (Num>MaxNum)
{
MaxNum=Num;
}
}
}
cout<<MaxNum<<" is the largest multiple of 5."<<endl;
return 0;
}[/code]
<br/>
View the full article
I need to use a user controlled loop to get multiples of 5. That part I have right and at the end display the largest number that is a multiple of 5 from the numbers I entered.
It works and tells whether the number is a multiple of five but when I select a key to stop it goes into a infinite loop. You can read the display and it also shows the largest multiple entered but it keeps looping and doesnt stop. I think it
is just a slight tweek but for the life of me cant find where??
Here is my code:
<pre class="prettyprint # include<iostream>
using namespace std;
int main ()
{
int Num=0,
MaxNum=0;
char again=y;
while(again==y||again==Y)
{
cout<<"Get multiples of 5 ";
cin>>Num;
{
if (Num % 5==0)
{
cout<<Num<<" is a multiple of 5"<<endl;
}
if (Num>MaxNum)
{
MaxNum=Num;
}
}
}
cout<<MaxNum<<" is the largest multiple of 5."<<endl;
return 0;
}[/code]
<br/>
View the full article