### Guys check this calculator

 ``123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120`` ``````//tell me how i should i improve it //--------------------------------------------| //Made by Behzad Khoker | //Calculator with functions | //Version 1.0(Beta) //Please tell me how should i make it better| //--------------------------------------------- #include #include using namespace std; //Operation starts here------------------------------------------ void sum(){ cout<<"Enter a number"<>num; cout<<"Enter another number"<>num2; ans=num+num2; cout<<"The answer is "<>num; cout<<"Enter a small number"<>num2; ans=num-num2; cout<<"The answer is "<>num; cout<<"Enter another number"<>num2; ans=num*num2; cout<<"The answer is "<>num; cout<<"Enter a small number"<>num2; ans=num/num2; cout<<"The answer is "<>enter; switch (enter) { case 1: cout<<"enter a number"<>num; cout<<"sin "<>num; cout<<"cos "<>num; cout<<"tan "<>ent; switch (ent) { case 1: sum(); break; case 2: subtract(); break; case 3: multiply(); break; case 4: divide(); break; case 5: sin(); break; default: cout<<"invalid\n"; break;} system("pause"); }while(1); } //Operation Ends here------------------------------------------ void main(){ calculator(); } //By Behzad Khoker ``````

Don't allow user to divide by 0. Subtract can give negative answers (i.e. It doesn't need a larger first number). You don't need math.h for anything you're doing here and should change it to <cmath>. However, you could use it to square root numbers sqrt(n) or raise numbers to powers pow(n,p). I would suggest changing every int to doubles so you can have non-integers too.

A few suggestions, though there are many other improvements you can make...
Thankyou mats
Topic archived. No new replies allowed.