Program for Sum of n numbers 1 + 2 + .... + n

# include<stdio.h> #include<conio.h> void main() { int n; printf ( “enter n value”); scanf ( "%d", &am...

# include<stdio.h>
#include<conio.h>
void main()
{
int n;
printf ( “enter n value”);
scanf ( "%d", & n);
n = n * (n+1)/2;
printf ( “\n sum of n natural numbers is %d", n );
getch();
}

Out put :

 enter n value 3
sum of n natural numbers is 6

Related

C Programs 4327070128712844552

Post a Comment

emo-but-icon

item