Wednesday, 24 July 2013

C-Program to SUM of Numbers Upto a Limit (SUM of Natural Numbers Upto a Limit)


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.
Read more...

Implementation in C language :
  
#include<stdio.h>
main ()
{
      int n,sum=0,i;
      printf("Enter the limit\t");
      scanf("%d",&n);
      for(i=1;i<=n;i++)
     {
           sum=sum+i;
     }
     printf("Sum of numbers upto %d is \t%d",n,sum);




sakoncepts.blogspot.in
output


No comments:

Post a Comment