Computer Science, asked by Nik7117, 1 year ago

write a program in Java to print the following pattern

Attachments:

Nik7117: please please please answer this question

Answers

Answered by QGP
4
public class Pattern
{
    public static void main(String[] args)
    {
        int i,j,k;   //i,j,k are loop variables.
        int n=1;        //n is the value of the number printed in each line.
        int ch = 65;   //65 is the ASCII Value of "A".
        for(i=1;i<=5;i++)
        {
            for(j=1;j<=i;j++)
            {
                System.out.print(n);
            }
            n++;
            for(k=j;k<=6;k++)
            {
                System.out.print((char)ch);
            }
            ch++;
            System.out.println();
        }
    }
}


QGP: Hope This helps. I have checked it. It runs perfectly.
Similar questions