WAP to add and subtract 2 numbers using function and display result inside function in c++
WAP to add and subtract 2 numbers without function
// WAP to add and subtract 2 numbers using function and display result inside function. #include<iostream> using namespace std; void calculate(int, int); int main() { int a, b; cout<<"Enter two numbers: \n"; cin>>a>>b; calculate(a,b); return 0; } void calculate(int a, int b) { int add, sub; add = a + b; sub = a - b; cout<<"\nSum: "<<add; cout<<"\nSub: "<<sub; }
Output
Enter two numbers:
5
3
Sum: 8
Sub: 2