Write your question here.
How to I create one loop after the next? I am trying to create a program that will run three times using different loops. i'm not sure what I am doing wrong here. please help!
[code]
#include<iostream>
#include <string>
#include <string>
#include <cstdlib>
using namespace std;
int main()
{
bool die( const string & msg );
int number;
int count;
int total;
int max;
cout<<"input number";
cin>>number>0||die("user input failure");
cout<<"input your maximum number";
cin>>max>0||die("user input failure");
count=0;
while ((count*number)<max && max!=0){
total=number*count;
cout<< total<<", ";
count=count+1;
}
if (total=(max-number)&&(max>0))
cout<<total;
I don't understand your question.
You seem to ask how to write a statement after a statement.
1 2 3 4
int main() {
std:: cout << "Hello"; // statement A
std:: cout << "world"; // statement B
}
Statement B is after A. These statements happen to contain global object, operator and literal constant, but there could be if, while, or for in their place. The statements here are independent of each other.
Your program already has multiple statements, so that cannot be the question.
Is the beef in the "use"? You wrote "three times, differently". Similar to:
1 2 3 4
int main() {
std:: cout << "Hello"; // statement A
std:: cout << 'H' << 'e' << "llo"; // statement B
}
Both A and B achieve the same thing, differently. You are already using function. Lets use them more:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
void loopA( int num, int max ){
}
void loopB( int num, int max ){
}
void loopC( int num, int max ){
}
int main() {
int a = 0;
int b = 0;
// read values to a and b
loopA( a, b );
loopB( a, b );
loopC( a, b );
return 0;
}