What does the following program print? - Java Language Basics

Java examples for Language Basics:while

Description

What does the following program print?

Demo Code

public class Main 
{
   public static void main(String[] args)
   {//from   ww  w .  j  a v a2s  . c  o m
      int x = 1;
      int total = 0;

      while (x <= 10) 
      {
         int y = x * x;
         System.out.println(y);
         total += y;
         ++x;
      } 

      System.out.printf("Total is %d%n", total);
   } 
}

Result


Related Tutorials