# NEED HELP! :( Simple Calculator using Pointers.

• 05-02-2011
Blazefury5
NEED HELP! :( Simple Calculator using Pointers.
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();
Quote:

- 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.
is what is needed.
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;  }```
• 05-03-2011
Salem
Something like
Code:

```        cout<<"Please enter your first number:";         cin>>integerVariable1;                 cout<<"Please enter the desired operation:";         cin>>operation;         int result = Calculate( &integerVariable1, operation );```
I think with that, you should be able to get pretty close to the answer.
• 05-03-2011
Blazefury5
Code:

```cout<<"Please enter your first number:";         cin>>integerVariable1;                 cout<<"Please enter the desired operation:";         cin>>operation;         int result = Calculate( &integerVariable1, operation );```
k I see this and tried it it will include the variable 1 and operation, into the calculate but it wont let me take the variable two instead it just takes in variable 1 and uses it twice
how am I supposed to make it similar to
Code:

`int result = Calculate( &integerVariable1, &integerVariable2,operation );`
• 05-03-2011
Salem
Where are your edits to the Calculate function, so that it expects and uses another parameter?