Type Here to Get Search Results !

Java Program to find Sum of Natural Numbers

0

Java Program to find Sum of Natural Numbers

public class Demo {

    public static void main(String[] args) {

       int num = 10, count, total = 0;

       for(count = 1; count <= num; count++){
           total = total + count;
       }

       System.out.println("Sum of first 10 natural numbers is: "+total);
    }
}

Post a Comment

0 Comments

Recent-post