Skip to content

Commit a2672b1

Browse files
committed
C codes
1 parent 70e7f05 commit a2672b1

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

natsum.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#include<stdio.h>
2+
int main()
3+
{
4+
int n,s;
5+
printf("enter a variable n");
6+
scanf("%d",&n);
7+
s=0;
8+
while(n!=0)
9+
{
10+
s=s+n;
11+
n--;
12+
}
13+
printf("sum of first n nos is %d",s);
14+
return 0;
15+
}

0 commit comments

Comments
 (0)