C Program for finding the sum of a series from 1 to n using do loop

in Steem AHP8 days ago

Image cover

Today I am sharing with you all through video C Program for finding the sum of a series from 1 to n using do loop. First of all, we have to take the value of N as input. Then we have to determine I=1 & S=0. And in the next step, if I<=N, we have to do the following ( S=S+I & I=I+1 ) Then we have to display the result and finish the program.

#include<stdio.h>
int main()
{
int i, n, sum;
printf("Enter numbers: ");
scanf("%d", &n);
sum=0;
i=1;
do {
sum = sum+i;
i++;
}while(i<=n);
printf("Result is: %d", sum);
return 0;
}

Thank you so much everyone for visiting my post.

IPFS Video

Posted with Speem

Sort:  

¡Hi friend!

#play

Image
Video reviewed by speem videos watcher @luisito01

Loading...

Your post have been rewarded by the Speak on Steem curator team!

Now you can promote your posts by sending SBD to @null. Promoted posts will gain visibility and extra support from our team. Learn more here
Ways to support us;

1000176409.gif

Curated By @kibreay001