# Thread: NEED HELP! :( Simple Calculator using Pointers.

1. ## 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();
- 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')
{
cin>>integerVariable1;

cin>>operation;

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;
}```

2. Something like
Code:
```	cout<<"Please enter your first number:";
cin>>integerVariable1;

cin>>operation;

int result = Calculate( &integerVariable1, operation );```
I think with that, you should be able to get pretty close to the answer.

3. Code:
```cout<<"Please enter your first number:";
cin>>integerVariable1;

`int result = Calculate( &integerVariable1, &integerVariable2,operation );`