write a program to demonstrate the for loop.

Category : Java | Sub Category : The Genesis of Java | By Runner Dev Last updated: 2020-09-27 13:06:19 Viewed : 209


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: