Rotate your phone or change to desktop for better experience

Rotate your phone or change to desktop for better experience

C Program to find out the sum of first n numbers

 // C Program to find out the sum of first n numbers


#include <stdio.h>


int main()

{

    int n,sum=0,i;

    printf("enter a number : ");

    scanf("%d",&n);

    

    for ( i = 1 ; i <= n ; i++)

    {

        sum=sum+i; 

    }

     

    printf("%d",sum);

return 0;

}

Post a Comment

0 Comments