3. Loading...
by CodeChum Admin
I wanna experiment on looping through a range of numbers that will be randomly inputted by the user. However, I don't want to let them see the loading percentage that is divisible by 4, so please exclude those for me when printing it out.
Thank you!
Instructions:
Input two integers in one line. The first inputted integer will be the starting point, and the second one shall serve as the ending point.
Use the power of loops to loop through the starting point until the ending point (inclusive), and print out each number within the range with the corresponding format shown on the sample output. However, skip the printing of statement if the integer is divisible by 4. Tip: Utilize the continue keyword to complete the process.
Input
A line containing two integers separated by a space.
2·10
Output
Multiple lines containing a string and an integer.
Loading...2%
Loading...3%
Loading...5%
Loading...6%
Loading...7%
Loading...9%
Loading...10%
#include <iostream>
using namespace std;
int main(){
cout<<"Input\nA line containing tow integers separated by a space.\n";
int start;
int end;
cin>>start;
cin>>end;
cout<<"\nOutput\nMultiple lines containing a string and an integer.\n";
for(int i = start; i <= end; i++){
if(i % 4){
cout<<"Loading..."<<i<<"%\n";
}
}
return 0;
}
Comments
Leave a comment