Ticker

6/recent/ticker-posts

Sum of n numbers Program




Sum of n numbers - 


#include <stdio.h>

int main()
{ int n,i,s=0;
printf("Enter the number ");
 scanf("%d",&n);
 for(i=1;i<=n;i++)
 {  s=s+i;
    }
     printf("The sum is %d",s);
    return 0;
}

Output -

Enter the number 5
The sum is 15

Post a Comment

0 Comments