Check the code i've the written the doubt as comment

 nonwrapsum=kadane(a,n);
    int total_sum=0;
    for(int i=0;i<n;i++)
    {   total_sum+=a[i];
        a[i]=-a[i];
    }

    int wrapsum;
    wrapsum=total_sum + nonwrapsum;// when I'm using nonwrapsum the output comes as 23
    wrapsum=total_sum + kadane(a,n); // when i'M using the function itself the output comes as 22 why it is so?

ans is different because in first case nowrapsum is the result of fucntion called before inverting the sign of array
but in later one the function is called after inverting the sign

wrapsum=total_sum + nonwrapsum;
this is incorrect