Write a program to display Following Output:
Q1
1
1 2
1 2 3
1 2 3 4
Q2
1
2 3
4 5 6
7 8 9 10
Q3
1 1 1 1 1
1 1 1 1 1
1 1 1 1 1
1 1 1 1 1
1 1 1 1 1
Q4
1 1 1 1 1
2 2 2 2 2
3 3 3 3 3
4 4 4 4 4
5 5 5 5 5
Q5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
Q6
1
1 2 1
1 2 3 2 1
1 2 3 4 3 2 1
1 2 3 4 5 4 3 2 1
Q7
1
1 2 1
1 2 3 2 1
1 2 3 4 3 2 1
1 2 3 4 5 4 3 2 1
1 2 3 4 3 2 1
1 2 3 2 1
1 2 1
1
Q8
1
1 2 1
1 2 3 2 1
1 2 3 4 3 2 1
1 2 3 4 5 4 3 2 1
1 2 3 4 3 2 1
1 2 3 2 1
1 2 1
1
Q1
1
1 2
1 2 3
1 2 3 4
Q2
1
2 3
4 5 6
7 8 9 10
Q3
1 1 1 1 1
1 1 1 1 1
1 1 1 1 1
1 1 1 1 1
1 1 1 1 1
Q4
1 1 1 1 1
2 2 2 2 2
3 3 3 3 3
4 4 4 4 4
5 5 5 5 5
Q5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
Q6
1
1 2 1
1 2 3 2 1
1 2 3 4 3 2 1
1 2 3 4 5 4 3 2 1
Q7
1
1 2 1
1 2 3 2 1
1 2 3 4 3 2 1
1 2 3 4 5 4 3 2 1
1 2 3 4 3 2 1
1 2 3 2 1
1 2 1
1
Q8
1
1 2 1
1 2 3 2 1
1 2 3 4 3 2 1
1 2 3 4 5 4 3 2 1
1 2 3 4 3 2 1
1 2 3 2 1
1 2 1
1
Write Programs for the following Question below:
Comment the answers here..!!!
ReplyDeleteQ4: public class java {
ReplyDeletepublic static void main (String args[])
{
for(int i=1; i<=5; i++)
{
for(int j=1; j<=5; j++)
{
System.out.print(i);
}
System.out.println("");
}
}
}
Q1: public class java {
ReplyDeletepublic static void main (String args[])
{
for(int i=1; i<=5; i++)
{
for(int j=1; j<=i; j++)
{
System.out.print(j);
}
System.out.println("");
}
}
}
Nice job buddy...other programmers too are Welcomed..!!
ReplyDeleteQ2:
ReplyDeleteint k = 1;
for(int x = 1; x <= 4; x++){
for(int y = 1; y <= x; y++){
System.out.print(k);
k++;
}
System.out.println("");
}
Q5:
ReplyDeletefor(int x = 1; x <= 5; x++){
for(int y = 1; y <= 5; y++){ System.out.print(y);
}
System.out.println("");
}
Q6
ReplyDeletepublic static void main( String arg[] )
{
int tamano = 5;
for( int i = 1 ; i <= tamano ; i++ )
{
for( int x = i ; x <= tamano ; x++ )
{
System.out.print(" ");
}
for( int j = 1 ; j <= i ; j++ )
{
System.out.print("" + j);
}
for( int w = i-1 ; w >= 1 ; w-- )
{
System.out.print("" + w);
}
System.out.println();
}
}
Q7
ReplyDeletepublic static void main( String arg[] )
{
int tamano = 5;
for( int i = 1 ; i <= tamano ; i++ )
{
for( int x = i ; x <= tamano ; x++ )
{
System.out.print(" ");
}
for( int j = 1 ; j <= i ; j++ )
{
System.out.print("" + j);
}
for( int w = i-1 ; w >= 1 ; w-- )
{
System.out.print("" + w);
}
System.out.println();
}
for( int i = 1 ; i <= tamano ; i++ )
{
System.out.print(" ");
for( int x = 1 ; x <= i ; x++ )
{
System.out.print(" ");
}
for( int j = 1 ; j <= tamano-i ; j++ )
{
System.out.print("" + j);
}
for( int w = tamano-i-1 ; w >= 1 ; w-- )
{
System.out.print("" + w);
}
System.out.println();
}
}
Q8
ReplyDeletepublic static void main( String arg[] )
{
int tamano = 5;
for( int i = 1 ; i <= tamano ; i++ )
{
for( int x = i ; x <= tamano ; x++ )
{
System.out.print("");
}
for( int j = 1 ; j <= i ; j++ )
{
System.out.print("" + j);
}
for( int w = i-1 ; w >= 1 ; w-- )
{
System.out.print("" + w);
}
System.out.println();
}
for( int i = 1 ; i <= tamano ; i++ )
{
System.out.print("");
for( int x = 1 ; x <= i ; x++ )
{
System.out.print("");
}
for( int j = 1 ; j <= tamano-i ; j++ )
{
System.out.print("" + j);
}
for( int w = tamano-i-1 ; w >= 1 ; w-- )
{
System.out.print("" + w);
}
System.out.println();
}
}