SUM OF FIRST N NATURAL NUMBER'S
Code :
#include<stdio.h>
int main()
{
int n, i, sum=0;
printf("===========================================\n");
printf("\tSum Of First N natural numbers\n");
printf("===========================================\n");
printf("Enter Max number to sum : ");
scanf("%d", &n);
for(i=1; i<=n; i++)
{
sum = sum + i;
}
printf("\nSum of first %d natural number is %d\n", n, sum);
printf("-------------------------------------------\n");
return 0;
}
Come again Learn again !
< iCode Buzz />
No comments:
Post a Comment