Computer Science, asked by Anonymous, 1 year ago

write a program to deter;ine the sum of first n natural numbers by using of for loop or go to statement in c programming .


Anonymous: hello
Anonymous: Yes
Anonymous: Hello

Answers

Answered by Anonymous
2
hey mate here is your answer

#include <stdio.h>
int main()
{
int n, i, sum = 0;

printf("Enter a positive integer: ");
scanf("%d",&n);

i = 1;
while ( i <=n )
{
sum += i;
++i;
}

printf("Sum = %d",sum);

return 0;

hope it help
mark as brainliest

Anonymous: With for loop program
Anonymous: thank u
Anonymous: welcome...
Anonymous: its my pleasure
Similar questions