السلام عليكم ورحمة الله وبركاته
امم كتبت برنامج ولم اعرف اين الخلل في البرنامج هل من مساعده في اصلاحه ؟؟
#include<iostrea>
#include <cstdlib>
#include<ctime>
using namespace std;
int getRanNum(int range);
int main()
{
int A,B,C;
int choice, answer;
A=getRanNum(50);
B=getRanNum(50);
cout <<A<<" "<<B<<endl;
do
{
cout<<endl;
cout<<"choose 1 to solve multiplication problems"<<endl;
cout<<"choose 2 to solve addition problems"<<endl;
cout<<"choose 3 to solve subtraction problems"<<endl;
cout<<"choose 4 to solve division problems"<<endl;
cout<<"choose 5 to exit this program"<<endl;
cin>>choice;
switch (choice)
{
case 1:
C=A*B;
cout<<"plase enter the right answer"<<endl;
cin>>answer;
if (A*B==C)
{
cout<<"very good."
<<"your answer is correct"<<endl;
}
else
{
cout<<"no, Please try again."
<<"the answer is wrong"<<endl;
}
break;
case 2:
C=A+B;
cout<<"plase enter the right answer"<<endl;
cin>>answer;
if (A+B==C)
{
cout<<"very good."
<<"your answer is correct"<<endl;
}
else
{
cout<<"no, Please try again."
<<"the answer is wrong"<<endl;
}
break;
case 3:
C=A-B;
cout<<"plase enter the right answer"<<endl;
cin>>answer;
if (A-B==C)
{
cout<<"very good."
<<"your answer is correct"<<endl;
}
else
{
cout<<"no, Please try again."
<<"the answer is wrong"<<endl;
}
break;
case 4:
C=A/B;
cout<<"plase enter the right answer"<<endl;
cin>>answer;
if (A/B==C)
{
cout<<"very good."
<<"your answer is correct"<<endl;
}
else
{
cout<<"no, Please try again."
<<"the answer is wrong"<<endl;
}
break;
case 5:
cout<<"end the program"<<endl;
break;
defult:
cout<<"not availble choice"<< "please choose again"<<endl;
}while (choice!=5);
system("pause");
return 0;
}
int getRanNum(int range)
{
srand(time(0));
return (rand()%range)+1;
}شاكراً حسن تعاونكم مقدماً ..

