Write a program to find sum of first 10 natural number in java

 Write a program to find sum of first 10 natural number in java

public class Sum
{
    public static void main(String args[]){
        int i , sum=0;
        for(i=0;i<=10;i++){
            sum += i;
        }
        
        System.out.println("Sum of first 10 natural number is "+sum);
    }
   
}

Output
Sum of first 10 natural number is 55

Comments

Popular posts from this blog

Calculate Compound Interest in JavaScript

How to make simple bill maker by using python tkinter

Make a GST Calculator using HTML and JavaScript