title: Can you solve my problem and simplify my code? I could not find out with the clean solution for this specific problem
body: <p>Problem: To display the sum of this pattern for n terms like 1+11+111+1111+11111..n terms</p>
  <p>Test Data:</p>
  <p>Input the number of terms: 5.</p>
  <p>Expected Output:</p>
  <p>1 + 11 + 111 + 1111 + 11111
  The Sum is : 12345</p>
  <p>I am trying this way-&gt;</p>
  <pre><code>//To display the sum of series like 1+11+111+11111
  
   #include &lt;stdio.h&gt;
   int
   main(void){
  //Here i declared some variables for storing information
   int number,iteration,value=1,j,summation=0;
  
  
   //Message to user
   printf(&quot;Input the number of terms : &quot;);
   //taking input from the user
   scanf(&quot;%d&quot;,&amp;number);
   //this condition will work till the iteration reaches to the inputted number
  
   for(iteration=1; iteration&lt;=number; iteration++){
  
      
      for(j=1; j&lt;=iteration; j++){
              //To display the series like 1 11 111 1111 11111
              printf(&quot;%d&quot;,value);
  
  
          if(j==1){
          summation=summation+value;
  
          }
          else if(j==2){
          summation=summation+value*10;
          }
          else if(j==3){
          summation=summation+value*100;
          }
          else if(j==4){
          summation=summation+value*1000;
          }
          else if(j==5){
          summation=summation+value*10000;
          }
  
  
  
  
  }
  
  
  printf(&quot; &quot;);
  }
  printf(&quot;\n&quot;);
  //To display the summation
  printf(&quot;The summation is : %d&quot;,summation);
  return 0;}
  </code></pre>
  <p>Now my problem is: This code does not work according to my expectation. It is working up to input value 5. But when I want to give input  6 times then I need to add an else if condition additionally in my code. I need to do this task whenever I increase the input value.</p>
  <p>When the input value is 6 and i need to add and make the condition like that-&gt;</p>
  <pre><code>else if(j==6){
         summation=summation+value*100000;
               }
  </code></pre>
  <p>So I think, this is not the way of a proper solution to a problem. Every time I need to do the same thing for the inputted value. How can I solve this problem?. After that how can I simplify the solution? I believe that you guys are expert than me. Please share your knowledge with me. Thank you in advance.</p>