title: How do I create a function to change the value of the last node to 1000?
body: <p><a href="https://i.stack.imgur.com/wBSt5.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/wBSt5.png" alt="enter image description here"></a></p>
  
  <p>I tried to create a code for it. However, it didn't work. Here's my previous attempted code:</p>
  
  <pre><code>void modifyLastNode(node*) {
    curr = head;
    while (Curr != NULL &amp;&amp; curr-&gt;data != 99) {
      temp = new node;
      temp-&gt;data = 1000;
      temp-&gt;next = curr;
    }
  }
  </code></pre>