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

Trending Topics

Online now

Members online
463
Guests online
2,251
Total visitors
2,714

Forum statistics

Threads
2,299,924
Posts
29,133,683
Members
1,201,218
Latest member
deadshot24
Back
Top