My code is as below:

The logic for the code is in the function evaluate(). The code is working for +ve number, but not working for -ve numbers. What can be the issue?

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
int evaluate(char p[],int size, int num1);
void read_values();
void calc();
int values[100];
int i,temp,num,j,k,l=0,result=0,temp_position=0,values_size=0;
char p1[100],arr_temp[100],a[100];
int main(){
scanf("%s",p1);
read_values();
calc();
values[values_size]=evaluate(p1,100, values[values_size]);
printf("%s\n",p1);
for(j=0;j<values_size;j++)
{
printf("%d\n",values[j]);
}
return 0;}
void read_values(){
do
{
scanf("%d",&temp);
if(temp==1000)
break;
else
{
values[values_size]=temp;
values_size++;
}
}
while(values[values_size]!=1000);
}
void calc(){
k=0;
for(l=0;p1[l]!='\0';l++)
{
if((p1[l]=='(')) { temp_position=0;
while(p1[++l]!=')')
{
a[temp_position++]=p1[l];
}
arr_temp[k++]=evaluate(a,temp_position,values[values_size])+48;
}
else
arr_temp[k++]=p1[l]; }
values[values_size]=evaluate(arr_temp,100, values[values_size]);
values_size++;
}
int evaluate(char p[],int size, int num1){
for(i=0;p[i+1]!='\0';i++)
{
if(i==0)
{
if(p[0]>='a'&&p[0]<='z')
result = num1;
else
result =p[0]-48;
}
if (p[i]=='^')
{
if(p[i+1]>='a'&&p[i+1]<='z')
result=pow(result,num1);
else
result=pow(result,(p[i+1]-48));
}
}
return result;
}

**What I have tried:**
Input:

(x-2)^3-(x-3)

-1

1000

----------

Output:

Should have been -23, but I am getting -1.