title: C: How can I print out individual digits of an integer number with a plus sign in the middle?
body: <p>Example Of Code</p>
  <pre><code>#include &lt;stdio.h&gt;
  
  int sum(int n); //Prototype
  
  int main(void){
      int number;
      printf(&quot;Enter number: &quot;);
      scanf(&quot;%d&quot;, &amp;number);
      printf(&quot;%d = %d\n&quot;, number, sum(number));
  }
  
  //Sum Function
  int sum(int n){
      int total = 0;
      while (n != 0)
      {
          total += n % 10;
          n /= 10;
      }
      return total;
  }
  </code></pre>
  <p>How do I print the below sentence taking into account that the number can be dynamically chosen by the user using a scanf function and I already have a dynamic function that calculates the sum of each digit.</p>
  <pre><code>Current Output: &quot;12345 = 15&quot;
  Desired Output: &quot;1 + 2 + 3 + 4 + 5 = 15&quot;
  </code></pre>
  <p>Edit: Hi all! I have updated my question to include my original code to make it clearer what I was trying to achieve. Thank you guys so much for your help!</p>