pls answer this urgently....
Attachments:
QGP:
Wait a few minutes. I am answering
Answers
Answered by
1
Hey There, Here are the codes for both the patterns:
public class P1
{
public static void main(String[] args)
{
int k=1;
for(int i=1;i<=5;i++)
{
for(int j=5;j>=i;j--)
{
System.out.print(k+" ");
if((k/10)==0)
{
System.out.print(" ");
}
k++;
}
System.out.println();
}
}
}
____________________________________________________________
public class P2{
public static void main(String[] args)
{
for(int i=1;i<=5;i++)
{
for(int j=1;j<=i;j++)
{
System.out.print((j%2)+" ");
}
System.out.println();
}
}
}
___________________________________________
Hope it helps
Brainly Community
public class P1
{
public static void main(String[] args)
{
int k=1;
for(int i=1;i<=5;i++)
{
for(int j=5;j>=i;j--)
{
System.out.print(k+" ");
if((k/10)==0)
{
System.out.print(" ");
}
k++;
}
System.out.println();
}
}
}
____________________________________________________________
public class P2{
public static void main(String[] args)
{
for(int i=1;i<=5;i++)
{
for(int j=1;j<=i;j++)
{
System.out.print((j%2)+" ");
}
System.out.println();
}
}
}
___________________________________________
Hope it helps
Brainly Community
Similar questions