cout<<"\t1 : Addition \n: ";
cout<<"\t2 : Subtraction \n: ";
cout<<"\t3 : Multipilication \n: ";
cout<<"\t4 : Division \n: ";
choice1 = getche();
switch(choice1)
{
case '1':
{
cout<<"Enter first number: " ;
cin>>x;
cout<<" Enter second number: ";
cin>>y;
answer= x+y;
cout<<"answer "<<answer <<endl;
system("pause");
break;
}
case '2':
{
cout<<"Enter first number: ";
cin>>x;
cout<<"Enter an other number: ";
cin>>y;
answer=x-y;
cout<<"answer is "<<answer<<endl;
system("pause");
break;
}
case '3':
{
cout<<"Enter first number: ";
cin>>x;
cout<<"Enter an other number: ";
cin>>y;
answer=x*y;
cout<<" answer is" <<answer <<endl;
system("pause");
break;
}
case '4':
{
cout<<"Enter first number: ";
cin>>x;
cout<<"Enter an other number: ";
cin>>y;
if(x!=0)
{
answer=x/y;
cout<<"answer "<<answer<<endl;
system("pause");
}
break;
}
}// end of inner switch
break;
}// end of case 1 arithmatic operation
case '2':
{
cout<<"\t1 : Sin function \n: ";
cout<<"\t2 : Cos function \n: ";
cout<<"\t3 : Tan function \n: ";
choice2=getche();
switch(choice2)
{
case '1':
{
cout<<"Enter a angle: ";
cin>>angle;
answer1=(sin(angle));
cout<<"answer is "<<answer1<<endl;
system("pause");
break;
}
case '2':
{
cout<<" Enter a number: ";
cin>>angle;
answer1=(cos(angle));
cout<<"answer is "<<answer1<<endl;
system("pause");
break;
}
case '3':
{
cout<< "Enter a number: ";
cin>>angle;
answer1=(tan(angle));
cout<<"answer is "<<answer1<<endl;
system("pause");
break;
}
}// inner switch
break;
}//inner case 2 trignomatic
case '3':
{
cout<<"\t1 : Natural log \n: ";
cout<<"\t2 : log with base 10 \n: ";
choice3=getche();
switch(choice3)
{
case '1':
{
cout<<" Enter a number: ";
cin>>x1;
answer1=log(x1);
cout<<"answer is "<<answer1<<endl;
system("pause");
break;
}
case '2':
{
cout<<"Enter a number: ";
cin>>x1;
answer1= log10(x1);
cout<<"answer is "<<answer1<<endl;
system("pause");
break;
}
}// end of switch
break;
}// end of case 3 logrithmic
case '4':
{
system("cls");
cout<<"\t1 : Press 1 for Power: ";
cout<<"\t2 : Press 2 for Square root: ";
cout<<"\t3 : Press 3 for square: ";
cout<<"\t4 : Press 4 for cude: ";
cout<<"Enter your choice: ";
choice4=getche();
switch(choice4)
{
case '1':
{
cout<<"Enter a number: ";
cin>>x1;
cout<<"Enter power: ";
cin>>y1;
answer1=pow(x1,y1);
cout<<"answer is "<<answer1<<endl;
system("pause");
break;
}
case '2':
{
cout<<"Enter a number: ";
cin>>x;
answer1=sqrt(x);
cout<<"answer is "<<answer1<<endl;
system("pause");
break;
}
case '3':
{
cout<<" Enter a number: ";
cin>>x;
answer1= x*x;
cout<<" answer is"<<answer1<<endl;
system("pause");
break;
}
case '4':
{
cout<<" Enter a number: ";
cin>>x;
answer1 =x*x*x;
cout<<" answer is"<<answer1<<endl;
system("pause");
break;
}
}// end of switch
break;
}// end of case power function
Try not to use system() functions for any stop you want in the program. It's like using a sledgehammer to kill a fly. It'd better be a damn big fly to do so.
In other words, it uses too much resources for the little task you need it for. Imagine hypothetically, where you're running some super heavy programs (Witcher 3, Crysis 2, Photoshop, Chrome, a benchmark tester) in the background and programming/doing your hw at the same time. The amount of computing power a system("pause") needs compared to a simple cin.ignore( 999, '\n' ) would be the difference in a crash or not.
Now imagine that in the real world, with a job. You'd get fired.