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;                         
}

Recommended Answers

All 4 Replies

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).

break statement not within loop or switch

this is the error i get

As StuXYZ already suggested, drop these lines:

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.