The sum of n natural numbers in C

 #include<stdio.h>

int main()

{

int i,sum=0,n;

printf("Enter the value of n");

scanf("%d", &n);

for(i=0; i<=n; i++){

     sum+=i;

}

printf("The sum of n natural numbers is %d", sum);

return 0;

}

Comments

Popular posts from this blog

create a num table in a new file in c

write a programme to compare time stamp in c

write a struct programme to keep bank details in c