#include <cstdio> #include <iostream> #include <cmath> // A Calculator made in C++ void Addition() { int xx; int yy; std::cin >> (xx); std::cin >> (yy); std::cout << (xx + yy) << std::endl; } void Substraction(){ int xx; int yy; std::cin >> (xx); std::cin >> (yy); std::cout << (xx - yy) << std::endl; } void Division(){ int xx; int yy; std::cin >> (xx); std::cin >> (yy); std::cout << (xx / yy) << std::endl; } void Multiplication(){ int xx; int yy; std::cin >> (xx); std::cin >> (yy); std::cout << (xx * yy) << std::endl; } void Power(){ int xx; int yy; std::cin >> (xx); std::cin >> (yy); std::cout << pow(xx, yy) << std::endl; } void Squareroot(){ int xx; std::cin >> (xx); std::cout << sqrt(xx) << std::endl; } void question(){ int x; std::cout << ("What do you want to do (0 to quit, 1+, 2-, 3/, 4*, 5^, 6sqrt") << std::endl; std::cin >> (x); } int main() { [[maybe_unused]] int x; question(); if ((x = 1)) { Addition(); question(); } if ((x = 2)) { Substraction(); question(); } if ((x = 3)) { Division(); question(); } if ((x = 4)) { Multiplication(); question(); } if ((x = 5)) { Power(); question(); } if ((x = 6)) { Squareroot(); question(); } if ((x = 0)) { system("PAUSE"); return 0; exit; abort; } }
https://github.com/terracraft321/Calculator/blob/df1d4610d86fdab134e54aa630aa1c7f1e4d1daa/main.cpp