Sequence Programing

here what i am supposed to do



Write a C++ program that inputs a number from the keyboard between 0 and 60 and then uses a for or while loop to display every following integer that is evenly divisible by 4. The last number that will be displayed is 100. In other words, if the number you input from the keyboard is 45, your program will output
48 52 56 60 … 92 96 100
Or if you input 60, your program will output
64 68 72 76 … 92 96 100

Your program should run multiple times. In other words, you should write code that prompts the user, “Do you wish to wish to display another series of numbers (Y(es) or N(o))?” and loops accordingly.
Place an error trap in your program that will reject any keyboard inputs < 0 or > 49. Use any wording you wish for the input prompt.



and so far i have this code




#include <iostream>
using namespace std;

int main()

{
int num,sum;

cout << "Enter a positive integer: ";
cin >> num;



while (num > 0 && num < 60 );

{

for(sum = 1; sum <= 10; sum++)
{
cout << num << endl;
}
else
{
cout << "Enter a Valid Number between 0 and 60"<< endl;
cin >> num;

}


return 0;

}
It'd be easier to delete your while and everything below and go from there.

Do these steps:
1. Input an integer:
1
2
3
4
5
6
int num = -1;
while (num < 0 || num > 60)
{
    cout << "Enter a number (0-60): 
    cin >> num;
} 


2. Loop from num to 100:
1
2
3
4
for (int i = num; i <= 100; i++)
{
    // output i if it is divisible by 4
}


3. Inside the for loop, do a cout if i is divisible by 4:
if (i%4 ==0) cout << i << " ";

4. Prompt if you want to go again and stick the whole thing in a while loop that goes until you get a no.
but then how would you make it ask wether you want to run again or not


Your program should run multiple times. In other words, you should write code that prompts the user, “Do you wish to wish to display another series of numbers (Y(es) or N(o))?” and loops accordingly.
Place an error trap in your program that will reject any keyboard inputs < 0 or > 49. Use any wording you wish for the input prompt.


sorry i am pretty new at c++
Last edited on
Topic archived. No new replies allowed.