hello everyone plss tell me whats wrong with my code

#include <iostream>
#include <cstdlib>


using namespace std;
int main(void)

{   
int choice;             
do 
{  
cout<<"Welcome To Hayzam's TimeTable\n";
cout<<" press 0 to quit\n";
cout<<"1- Sunday\n";
cout<<"2- Monday\n";
cout<<"3- Tuesday\n";
cout<<"4- Wendesday\n";
cout<<"5- Thursday\n";
cout<<"6- Friday\n";
cout<<"7- Saturday\n";
cin>>choice;   
}
while (true);
if (choice == 0) 
exit (1); 
switch (choice)
{
case 1:
cout << "maths/n"; 
cout << "english/n"; 
cout << "arabic/n"; 
cout << "social/n"; 
cout << "biology/n";
cout << "physics/n"; 
cout << "games/n"; 
cout << "mpt/n";     
break;

case 2:
cout << "english/n"; 
cout << "islamic/n"; 
cout << "arabic/n"; 
cout << "social/n"; 
cout << "maths/n"; 
cout << "chemistry/n"; 
cout << "physics/n"; 
cout << "games/n";
break;
      
case 3:
cout << "maths/n"; 
cout << "computer/n"; 
cout << "social/n"; 
cout << "biology/n"; 
cout << "chemistry/n"; 
cout << "games/n"; 
cout << "english/n"; 
cout << "maths/n";
break;

case 4:
cout << "english/n"; 
cout << "mpt/n"; 
cout << "arabic/n"; 
cout << "games/n"; 
cout << "maths/n"; 
cout << "islamic/n"; 
cout << "social/n"; 
cout << "biology/n";
break;

case 5:
cout << "arabic/n"; 
cout << "maths/n"; 
cout << "games/n"; 
cout << "islamic/n"; 
cout << "mpt/n"; 
cout << "social/n"; 
cout << "english/n"; 
cout << "computer/n";
break;

case 6:
cout << "Holiday/n";
break;

case 7:
cout << "Holiday/n"; 
break;                           
 default:
 cout<<"That is not a option\n";
}
system ("pause");
return 0;                         
}

The problem is the while(true); iine and the } on the line above.
[lines 22,23]

The while loop does not allow you to go into the switch statement. Therefore to fix
it just move it to the line above you return 0; (between line 93/94).

As StuXYZ already suggested, drop these lines:

10. do
11. {
22. }
23. while (true); // endless loop

Edited 6 Years Ago by tesuji: n/a

This article has been dead for over six months. Start a new discussion instead.