Not understanding

int sum_replacement(node*root)
{

if(root==NULL)
return 0;

else if(root->right==NULL and root->left==NULL)
return root->data;

// recursive part

int leftsum=sum_replacement(root->left);
int rightsum=sum_replacement(root->right);

int temp=root->data;
root->data=leftsum+rightsum;
return temp+leftsum+rightsum;

}

i this sum_replacement function, what is work of leftsum and rightsum and how they are working, please explain me i detail.

This is a postorder traversal.
Means the order is left - right and then you work for root.
Postorder traversal is done when you start finding results from the bottom of the tree and moving upwards towards the root. Here the result of the root node depends on the result of left and the right subtree.
So if you are at a particular root, leftsum will store the result of left subtree
And rightsum will store the result of the right subtree.
You then perform these operations which is required by the question

int temp=root->data;
root->data=leftsum+rightsum;
return temp+leftsum+rightsum;