Jude made a calculator in cc+ language
- User
Jude made a calculator in cc+ language
- Assistant
That's great to hear! Do you have any more details on what features or functions the calculator has? As an AI language model, I can try to understand and learn from the code if you could share it as well.
- User
Do addition, subtraction, division and multiplication
- Assistant
Okay, here's a sample code for a simple calculator program in C++ that performs basic arithmetic operations (addition, subtraction, division, and multiplication):
#include <iostream> using namespace std; int main() { char op; float num1, num2; cout << "Enter operator either + or - or * or /: "; cin >> op; cout << "Enter two operands: "; cin >> num1 >> num2; switch(op) { case '+': cout << "The sum of " << num1 << " and " << num2 << " is " << num1+num2; break; case '-': cout << "The difference between " << num1 << " and " << num2 << " is " << num1-num2; break; case '*': cout << "The product of " << num1 << " and " << num2 << " is " << num1*num2; break; case '/': if(num2 == 0) { cout << "Error! Division by zero."; } else { cout << "The quotient of " << num1 << " and " << num2 << " is " << num1/num2; } break; default: cout << "Error! Invalid operator."; break; } return 0; }