Infinite loop and counter issues

Displaying positives numbers between 10 and 20, How do I stay in the loop?

//Is Number between 10 and 20
cout << "\n\n\n\n\n\n\n";
cout << "\n" << setw(26) << "Enter Number: " ;
cin >> Numb;

//Clear the screen
system("cls");

//Calculate if the number is between 10 and 20
if ( Numb >= LOW && HIGH >= Numb, Counter++ )
{
cout << "\n\n\n\n\n\n\n";
cout << "\n" << setw(26) << "Enter Number: " ;
cin >> Numb;
cout << "\n\n" << setw(26) << "Count: "<< Counter;
cout << "\n\n";
system ("pause");
system("cls");
}
else(Numb < LOW && HIGH < Numb);
{
cout << "\n\n\n\n\n\n\n";
cout << "\n" << setw(26) << "Enter Number: " ;
cin >> Numb ;
return 0;
}}
//End main program
Last edited on

First why do you have so many new line characters? Also please put your code in using this syntax found here: http://www.cplusplus.com/articles/z13hAqkS/ .

What loop?
Thats a if statement. Here is the link to understand more about what your wanting and what your doing(trying to do)...http://www.cplusplus.com/doc/tutorial/control/

If you get rid of the system("cls"); Im pretty sure that will end the loop like out come and if you go to the link above this comment you should find what your looking for; loops that is...
So your code says go down 8 lines. Ask the user to "Enter Number: ". You take in a value from the user in variable "Numb" ; thats assuming you have more to this code that would declare the variable with a data type of some sort. Never mind. Please look at all the links provided.

Here is a link that tells you what \n does...
http://www.cplusplus.com/doc/tutorial/constants/

Escape code Description
\n newline



Last edited on
Topic archived. No new replies allowed.