Write Two Separate Programs to Generate the Following Patterns Using Iteration (Loop) Statement:
Advertisements
प्रश्न
Write two separate programs to generate the following patterns using iteration (loop) statement:
(a)
टिप्पणी लिखिए
Advertisements
उत्तर
public class pattern1
{
public static void main( )
{
for (int i=1; i<=5; i++)
{
for(int j=1; j<=i; j++)
{
if(j %2==1)
System.out.print("*");
else
System.out.print("#");
}
System.out.println( );
}
}
}
shaalaa.com
Introduction of Iterative Constructs in Java
क्या इस प्रश्न या उत्तर में कोई त्रुटि है?
