write a program to demonstrate the for loop.

Category : Java | Sub Category : The Genesis of Java | By Prasad Bonam Last updated: 2020-09-27 07:36:19 Viewed : 512


write a program to demonstrate the for loop.            

Description : Initialize x and then give for loop and then show the output line in which I show output line and after this our main program end.


Code:

/**

 *

 * write a program to demonstrate the for loop.

 */

 

class ForTest { // This line daclare a new class & the class defination is start.

     public static void main(String a[]) { // This line begins the main() method.

         int x; // daclare a integer x.

 

         for (x = 0; x < 10; x = x + 1) // for loop start

 

              System.out.println("this is x: " + x); // this line show value of x

     } // end of main program

 

// end of a class



OUTPUT:


Search
Related Articles

Leave a Comment: