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

Trending Topics

Online now

Members online
434
Guests online
1,377
Total visitors
1,811

Forum statistics

Threads
2,287,483
Posts
29,044,844
Members
1,216,560
Latest member
saelxx02
Back
Top