Logo 
Search:

Java Articles

Submit Article
Home » Articles » Java » Homework HelpRSS Feeds

Program to show the use of While Loop

Posted By: Malak Malik     Category: Java     Views: 3950

A Java Program to show the use of While Loop.

Code for Program to show the use of While Loop in Java

publicclass JAVA_028
 {

    publicstaticvoid main(String[] args)
    {
       int limit=20;
       int sum=0;
       int i=1;
 
       while(i<=limit)
       {
          sum+=i;
          i++;
       }

       System.out.println("Sum of first 20 integers = " + sum);
    }
 }
  
Share: 


Didn't find what you were looking for? Find more on Program to show the use of While Loop Or get search suggestion and latest updates.

Malak Malik
Malak Malik author of Program to show the use of While Loop is from Lahore, Pakistan.
 
View All Articles

 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
No Comment Found, Be the First to post comment!