Muzamil Niaz 03
Muzamil Niaz 03
Muzamil Niaz 03
FUNDAMENTAL
Name : MUAZAMIL NIAZBAIG
Roll no: 2303
Second Semester BS( IT)
Q#1 :WRITE A CALCULATOR C++ CODE USING
FUNCTION METHOD:
SOLUTION:
#include <iostream>
switch(op) {
case '+':
return m + n;
case '-':
return m - n;
case '*':
return m * n;
case '/':
if (n != 0) {
return m / n;
} else {
return 0;
default:
return 0;
int main() {
char op;
double value1,value2;
char again;
do {
cout << value1 << " " << op << " " << value2 << " = " << res << endl;
cout << "Do you want to calculate again? (yes/no): ";
return 0;