1 + 2 + 3 + ..... + n
To do so, we need to start a loop from 1 and need to do sum till n. Here is the program:
#include <stdio.h> int main() { int i, last_num, sum = 0; printf("Enter the last number of the series: "); scanf("%d",&last_num); for(i=1;i<=last_num;i++){ sum = sum + i; } printf("The sum of the series is: %d",sum); return 0; }
Now you can do sum of any series with the help of above program.
Hey admin,
ReplyDeleteof course this blog is doing a very good job of serving useful information. I'm proud to be a part of its Readers community.
for more programs visit my web
http://www.hhhprogram.com/