C program to calculate sum of the series 1 + 11 + 111 + 1111 + ... N terms
To find (calculate) the sum of series 1+11+111+1111+... till N terms using C program - we are reading total number of terms by the user and using following steps:
- Declared variables to stores sum of the values (sum), loop counter (i) and a variable to store term (temp) value (like, 1, 11, 111,.. )
- Assigning 0 to the variable sum and initial value 1 to the temp
- Within the loop - first we are adding the temp value to the sum and them increasing the value of temp to make it next term value.
- And, after the loop – we are printing the value of the sum.