Need help making a Calculator program.
I need help on the function I have set, idk if I'm doing it correct or not. and how to have a function call for it. I tried using Calculate();
is what is needed.- Create a function called "Calculate" that takes in two integer pointers and - char variable as parameters. This function will return an integer value.
- Save the returned value into a new int variable called "result"
- Point "integerPointer" to the address of "result" and display the dereferenced value for integerPointer.
Code:#include<iostream> using namespace std; int integerVariable1; int integerVariable2; char operation; int result; int Dothemath; int Calculate(int *integerPointer,char operation); int main() { char again = 'y'; while (again == 'y') { cout<<"Please enter your first number:"; cin>>integerVariable1; cout<<"Please enter the desired operation:"; cin>>operation; cout<<"Please enter your second number:"; cin>>integerVariable2; int* integerPointer=0; integerPointer=&integerVariable1; cout<<*integerPointer<<operation; integerPointer=&integerVariable2; cout<<*integerPointer; cout<<"="; integerPointer=&result; cout<<*integerPointer; cout<<"\nCare to try again? (y/n)"; cin>>again; } return 0; } int Calculate(int *integerPointer,char operation) { int result; if(operation=='+') { result=*integerPointer+*integerPointer; } if(operation=='-') { result=*integerPointer-*integerPointer; } return result; }