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

Trending Topics

Online now

Members online
1,128
Guests online
2,225
Total visitors
3,353

Forum statistics

Threads
2,316,904
Posts
29,188,766
Members
1,182,140
Latest member
Fabri777
Back
Top