Write a program to print first ten natural numbers in java code example
Example: Write a program to print first ten natural numbers in java
public class Main
{
public static void main(String[] args)
{
int number = 10, sum = 0;
for(int i = 1; i <= number; ++i)
{
sum =sum + i;
}
System.out.println("Sum = " + sum);
}
}