Write a program to print sum on first 10 natural numbers.
#include
int main()
{
int i, sum;
for(i=1;i<=10;++i);
{
sum =sum + i;
}
printf("The sum is = %d",sum);
}

Respuesta :

A program that prints the sum on the first 10 natural numbers is:

  • int sum=0;
  • int i=1;
  • for(i=1; i <= 10 ; i++) // the value of i will be from 1 to 10
  • {sum=sum+i; //each number will get added to the variable ‘sum’}
  • System.out.println(sum); //

What is a program?

A computer program in a programming language is a set of instructions and commands written in a language that a computer can execute or understand. 

Using the For Loop program, the variables of the first 10 natural numbers can be written as:

  • int sum=0;
  • int i=1;
  • for(i=1; i <= 10 ; i++) // the value of i will be from 1 to 10
  • {sum=sum+i; //each number will get added to the variable ‘sum’}
  • System.out.println(sum); //

Learn more about writing a program here:

https://brainly.com/question/23275071