write a program c++ to find sum of first 10 natural numbers using while loop
Answers
Answered by
9
Explanation:
#include<stdio.h>
int main()
{
int i=1, sum=0;
while(i<=10)
{
sum=sum+i;
i++;
}
printf("Sum of first 10 natural numbers is %d", sum);
return 0;
}
Answered by
1
C++ program to print the sum of the first 10 natural numbers.
#include<stdio.h>
int main()
{
int i=1, sum=0;
while(i<=10)
{
sum=sum+i;
i++;
printf("Sum of first 10 natural numbers is %d", sum);
return 0;
}
- The output of the program will come out to be 55 as the sum of the first 10 natural numbers is 55.
Similar questions