Answer to Question #180817 in C++ for Darren

Question #180817

Write a program to work like a calculator that perform the addition, subtraction, multiplication and division operation. Your program should use the function call method to call four sub functions to do the arithmetic operations. Example of output:


cout << sum(6,2) << end1 //will print 8

cout << subtract(6,2) << end1 //will print 4

cout << multiply(6,2) << end1 //will print 12

cout << divide(6,2) << end1 //will print 3


1
Expert's answer
2021-04-13T06:30:10-0400
#include <iostream>


using namespace std;


int sum(int a, int b){
    return a + b;
}
int subtract(int a, int b){
    return a - b;
}
int multiply(int a, int b){
    return a * b;
}
float divide (int a, int b){
    return a / b ;
}


int main()
{
    cout << sum(6,2) <<endl; //will print 8


    cout << subtract(6,2) << endl; //will print 4


    cout << multiply(6,2) << endl; //will print 12


    cout << divide(6,2) << endl; //will print 3


    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS