Error: system was not declared in this scope

#include<iostream>
#include<conio.h>
#include<cmath>
using namespace std;
int main ()
{
char choice, choice1, choice2, choice3, choice4;
int x,y;
double x1,y1;
int answer;
double answer1;
double angle;
cout<<" Welcome to TwoSixEight Geeka Scientific Calculator : ";
cout << " Coded by Jenell Joanne James";
do

{

cout<<"\t1 : Arithmetic Operations \n: ";
cout<<"\t2 : Trigonometric Functions \n: ";
cout<<"\t3 : Logarithmic Functions \n: ";
cout<<"\t4 : Power Functions \n: ";
choice = getche();


switch(choice)

{
case '1':

{

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

}// outer switch
}while(choice!= '5');

return 0;
}
Where do you declare system... or #include the header that does so?
closed account (oGN8b7Xj)
#include <cstdlib>
thank lechuga2000 i got it....
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.
Come on, code tags - we have talked about this already ......
Topic archived. No new replies allowed.