Computer Science, asked by shorthair, 1 year ago

PROGRAM FOR CALCULATORS
ANY LANGUAGE

Answers

Answered by ShakyaSk
3

Program:

// C++ program to create calculator using

// switch statement

#include <iostream>

using namespace std;

// Main program

main()

{

char op;

float num1, num2;

// It allows user to enter operator i.e. +, -, *, /

cin >> op;

// It allow user to enter the operands

cin >> num1 >> num2;

// Switch statement begins

switch (op) {

// If user enter +

case '+':

cout << num1 + num2;

break;

// If user enter -

case '-':

cout << num1 - num2;

break;

// If user enter *

case '*':

cout << num1 * num2;

break;

// If user enter /

case '/':

cout << num1 / num2;

break;

// If the operator is other than +, -, * or /,

// error message will display

default:

cout << "Error! operator is not correct";

break;

} // switch statement ends

return 0;

}


shorthair: thnk u very much
Anonymous: u most welcome
ShakyaSk: thnk u very much for marking brainliest
Annuktaa: Hey sk can I know one thing because I don't know hindi so please tell what is "talav" in English..I saw u r good in hindi that's why
ShakyaSk: i don't know sorry
ShakyaSk: i think it is "talab" not talav
Annuktaa: Can be
Annuktaa: Good night
Similar questions