program
#include <stdio.h>
#include <conio.h>
void main()
{
int a, sum = 0;
printf("enter a number: ");
scanf("%d", &a);
printf("the first 10 natural number are: ");
for (int i = 0; i <= a; i++)
{
printf("%d \n", i);
sum = sum + i;
}
printf("the sum of the first %d natural number is %d ", a, sum);
getch();
}
OUTPUT
The first 10 natural number are: 0
1
2
3
4
5
6
7
8
9
10
the sum of the first 10 natural number is 55
0 Comments