🔒 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
  • 366
    Views
  • 1
    Participants
Last reply from:
-CLAY-

Online now

Members online
623
Guests online
8,328
Total visitors
8,951

Forum statistics

Threads
2,329,526
Posts
29,248,594
Members
1,156,477
Latest member
Ajami
Back
Top