Error error error system crash

please help sisters and brothers

Hello @rssrivastavarohan,

  1. A compilation error at line 194:
    You are returning a wrong type.

  2. Pass the root by reference in the replacesum() function.

I have corrected your code:

Hope, this would help.
Give a like if you are satisfied.

Bro when will pass node * root and when we pass node* &root . Please tell me In this case I’m really confused

Sure @rssrivastavarohan,

  1. You pass head by value i.e. node *head when you want to reflect the changes made on this root variable to be reflected back on the root object present in the main() function.

  2. You pass head by value i.e. node * head when you do not want to reflect the changes made on this root variable to be reflected back on the root object present in the main() function.

Example:
the head pointer of the linked list.

BTW, You need not to pass the root here by reference, it won’t make a difference.

Hope, this would help.
Give a like if you are satisfied.

bro you have typed similar Im confused. Check two statements.

Hey @rssrivastavarohan,

No, they are not.
They are complete inverse of each other.

Let’s understand with an example:
Suppose, there is a linked list: 1->2->3->4.

  1. I ask you to print the data of the second node i.e. 2

  2. I ask you to print the data of the second node and make it the head of the linked list i.e. skip one.

Code:
void print(head){
head=head->next;
cout<data;
return;
}

In the first case, you will pass by value while in the second case, you will pass head by reference.

Hope, it is clear now.

Thanks Bhai Kudos to you . Thankyou very much for your help.

Anytime @rssrivastavarohan,

Please, mark it as resolved.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.