#include
#include
void main()
{
int i, n, sum = 0;
clrscr();
printf(“Enter an integer number\n”);
scanf (“%d”, &n);
for (i=1; i <= n; i++)
{
sum = sum + i;
}
printf (“Sum of first %d natural numbers = %d\n”, n, sum);
getch();
}
#include
void main()
{
int i, n, sum = 0;
clrscr();
printf(“Enter an integer number\n”);
scanf (“%d”, &n);
for (i=1; i <= n; i++)
{
sum = sum + i;
}
printf (“Sum of first %d natural numbers = %d\n”, n, sum);
getch();
}
No comments:
Post a Comment