English, asked by rajeshkumar02jp1u1ik, 1 year ago

How to print..
44444
44144
44244
44344
44444
in java...?

Answers

Answered by QGP
12
public class School     //Creating Class
{
    public static void main(String[] args)      //Creating main() function
    {
       int k=4;    // Declaring and initializing an integer type variable k
       
       for (int i=0;i<5;i++)        //A loop which will iterate 5 times, for our 5 rows
       {
           System.out.println("44"+k+"44");  //We print "44 (middle number)  44". k is that middle number
           
           if(k==4)         //Just after printing first row, we reset value of k to zero
                k=0;
                    
           k++;         //Now value of k keeps increasing by 1
       }
    }
}


Similar questions