Q:

C Program to calculate sum of first N natural numbers

0

C Program to calculate sum of first N natural numbers

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

#include <stdio.h>
 
int main()
{
    int n,i;
    int sum;
 
    printf("Enter the value of N :");
    scanf("%d",&n);
 
    sum=0;
 
    for(i=1;i< n;i++)
        sum+=i;
 
    printf("\nSum is = %d",sum);
     
    return 0;
}

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now