I'm having a problem getting two For loops to excute correctly.
Is it posssible to have For, Do while and while loops (3) in the same code,
or 3 For Loops or 3 While loops? So far, the first loops overwrides the second when I exceute, even though everything is calculated, it just overwrites.
#include <iostream>
using namespace std;
int main()
{
cout << "---- WELCOME TO THE INCH CONVERTER! ----" << endl;
cout << endl;
cout << "Enter the original inches: ";
double a; // a represents initial inches value
cin >> a;
double b; // b represents my working math theory for multiples of 12
b = a * 0.084;
double c; // c represents my working math theory for nonmultiples of 12
c = a * 0.084 * 0.857;
double d; // multiples of 12
d = (b * 12) - a;
double e; // d is a variable in a tester, which determines nonmultiples of 12
e = (c * 12) - a;
;
while (a < 12) {
cout << "** Equivalent feet/inches: " << "0 " << "feet, " << a << " inches" << endl;
cout << endl;
cout << "---- THANK YOU. GOOD BYE! ----";
system ("Pause"); //This pauses the screen to prevent immediate closing event or looping.
return 1;
}
for (; d = 0.096; )
{
cout << "** Equivalent feet/inches: " << b << " feet, " << " multiple" << " inches";
system ("pause");
return 0;
}
for (; e < 10.4 && e < 0 && d > 0.096 ;)
{
cout << "** Equivalent feet/inches: " << c << "feet" << " nonmultiple" << " inches.";
system ("pause");
return 0;
}
If one loop goes in front 24 inches translates to 2 feet, but when the second loop is placed in front, i get 1.72 instead. It's not separating them based on
the limits I put in d = 0.096 and the others, where if d = 0.096 it still takes the form of the other loop. Is the first or one loop statement stronger than another?
In your case you may not want return statement. You should look at break statement instead. Break out of the innermost loop to continue on to the next loop.