write a program in C to print the sum of first n natural numbers ?
Answers
Answered by
0
Answer:
0 is the natural number.
Answered by
0
Answer:
#include <stdio.h>
int main()
{
int a,n,sum;
/* it is the range of naturalnumbers*/
printf("enter the range ");
scanf("%d",&n);
for(a=1;a<=n;a++)
{
sum=sum+a;
}
printf("the sum of natural is=%d",sum);
return 0;
}
Output:-
enter the range 6
the sum of natural is 21
Similar questions
English,
2 months ago
Accountancy,
2 months ago
Social Sciences,
2 months ago
Chemistry,
4 months ago
Physics,
4 months ago
Biology,
10 months ago
English,
10 months ago