Help with a program have tired for hours cant figure this out

May 30, 2012 at 1:55am
so here the basics of the file
#include <cstdlib>
#include <iostream>

using namespace std;

int main(int argc, char *argv[])
{
srand (time(0));
int distance = 1;
int cont=0;
int menuChoice =1;
int choice;
int randDistance = rand()% (100 - 1 +1) +1;
do
{
for(cont; cont < distance; cont++)
{
cout << "|";
}
cin >> choice;
switch(choice)
{
case(1):
{



if(randDistance <= 30 || randDistance >= 60)
{
++distance;
}
if(randDistance >= 30 || randDistance <= 50)
{
}
if(randDistance >= 50 || randDistance <= 60)
{
distance = distance + 2;
}

}
}
}while(menuChoice == 1);







system("PAUSE");
return EXIT_SUCCESS;
}


The idea is that i want to have a random number evaluated then randomly it will either add 1 line to the program add no lines or add 2 lines, this is a small part of a larger program so the do while is necessary.
May 30, 2012 at 5:33am
Please indent your code, use code wrap, tell us what exactly doesn't work with the program, and give us any compiler errors.
May 30, 2012 at 6:07am
pls paste ur code using code tags, about ur problem you are accepting the choice in
 
cin>>choice

but in do while u are checking for menu choice, which is declared as 1 and never changed throughout program, u end up with a infinite while loop without any exit condition.
 
while(menuChoice == 1);
Topic archived. No new replies allowed.