/*to find the sum of first n even natural number*/
#include<stdio.h>
#include<stdlib.h>
int main( )
{
int i,j=2,n,sum=0;
printf ("enter n: ");
scanf ("%d",&n);
for (i=1; i<=n; i++)
{
sum+=j;
j+=2;
}
printf ("\nsum of even natural number=%d",sum);
system ("pause");
return 0;
}
No comments:
Post a Comment