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
Answers
Answered by
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
#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
Similar questions
Hindi,
6 months ago
Math,
6 months ago
Environmental Sciences,
1 year ago
Math,
1 year ago
Physics,
1 year ago