Skip to content

Commit

Permalink
Sum of first N natural numbers pclubuiet#138
Browse files Browse the repository at this point in the history
  • Loading branch information
atul1837 committed Oct 4, 2019
1 parent 6dc4c55 commit cc2fb0a
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions C/first_n_natural_no_sum.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#include<stdio.h>
void main() {
int i, n, sum=0;
printf("please enter a no :-");
scanf("%d",&n);
for(i=0;i<=n;i++) {
sum+=i;
}
printf("sum of all natural no's till %d is :-%d", n, sum);
}

0 comments on commit cc2fb0a

Please sign in to comment.