🔒 Closed Using void function

Status
Not open for further replies.

-CLAY-

Fanatic
Sample code

#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
void myoperation(char opr);
int num1, num2;
char opr;

cout << "Enter two integers: ";
cin >> num1 >> num2;
cout << endl;

cout << "Enter operator: + (addition), - (subtraction)," << " * (multiplication), / (division): ";
cin >> opr;
cout << endl;

cout << num1 << " " << opr << " " << num2 << " = ";
}

void myoperation(char opr){
switch (opr){

int num1;
int num2;

case '+':
cout << num1 + num2 << endl;
break;

case'-':
cout << num1 - num2 << endl;
break;

case'*':
cout << num1 * num2 << endl;
break;

case'/':
if (num2 != 0)
cout << num1 / num2 << endl;
else
cout << "ERROR \nCannot divide by zero" << endl;
break;

default:
cout << "îllégâl operation" << endl;
}
}

Yan po yung progress ko kaso yung sa may bandang division sa may if else statement di ko mapalabas yung result na dapat idisplay.

Paguide po sa mga master na dyan
 
Status
Not open for further replies.

About this Thread

  • 0
    Replies
  • 309
    Views
  • 1
    Participants
Last reply from:
-CLAY-

Online now

Members online
534
Guests online
846
Total visitors
1,380

Forum statistics

Threads
2,275,113
Posts
28,960,696
Members
1,233,598
Latest member
H3ll0World
Back
Top