catogory:
tags:
Concept Introduction :
Find the sum of Natural numbers upto a limit.
For example:
natural numbers are 1 2 3 4 5 6 7 8 9 10 .....etc
if input is 4, output is 1+2+3+4=10 and
if input is 7,output is 1+2+3+4+5+6+7=28
Below program helps you to find sum of natural numbers upto your choices
How to Implement :
First initialize a variable sum(just say) as zero to clear previous values in that variable.
Then read the limit. Initialize another variable i(say) as 1. By using a loop, add the value of variable i to the variable sum until it satisfies the condition given variable is less than or equal to limit. and increment the variable i by one in each iterations.
Print value of Sum as output
Implementation in C language :
main ()
tags:
Concept Introduction :
Find the sum of Natural numbers upto a limit.
For example:
natural numbers are 1 2 3 4 5 6 7 8 9 10 .....etc
if input is 4, output is 1+2+3+4=10 and
if input is 7,output is 1+2+3+4+5+6+7=28
Below program helps you to find sum of natural numbers upto your choices
How to Implement :
First initialize a variable sum(just say) as zero to clear previous values in that variable.
Then read the limit. Initialize another variable i(say) as 1. By using a loop, add the value of variable i to the variable sum until it satisfies the condition given variable is less than or equal to limit. and increment the variable i by one in each iterations.
Print value of Sum as output
Implementation in C language :
main ()
{
int n,sum=0,i;
printf("Enter the limit\t");