Question 17 : Write a program in Java to print the following pattern :
54321
5432
543
54
5
Java Program :
public class pattern_4
{
public static void main()
{
int i,j;
for(i=1;i<=5;i++)
{
for(j=5;j>=i;j--)
{
System.out.print(j);
}
System.out.print("\n");
}
}
}
i need the answer for this pattern
ReplyDelete*
***
*****
***
*
for(i=1;i<=5;i=i+2)
Delete{
for(j=1;j<=i;j=j+2)
{
System.out.print("*");
}
System.out.println();
}
for(i=3;i>=1;i=i-2)
{
for(j=1;j<=i;j=j-2)
{
System.out.print("*");
}
System.out.println();
}
This comment has been removed by the author.
ReplyDelete//output
ReplyDelete//*
//**
//***
//****
//***
//**
//*
public static void pattern_ch2(){
for(int row=1; row<=5; row++){
for(int col=1; col<=row; col++){
System.out.print("*");
}
System.out.println();
}
for(int row=4; row>=1; row--){
for(int col=row; col>=1; col--){
System.out.print("*");
}
System.out.println();
}
}
i need that patten
ReplyDelete54321
5432*
543**
54***
5**** sent me program
can u answer the pattern 5
ReplyDelete54
543
5432
54321
Here you go, Teja
ReplyDeleteJava code :
import java.util.*;
import java.lang.*;
import java.io.*;
class pattern
{
public static void main (String[] args)
{
int row, col ;
for(row=5 ; row>=1 ; row--)
{
for(col=5 ; col>=row ; col--)
{
System.out.print(col) ;
}
System.out.print("\n") ;
}
}
}
This comment has been removed by the author.
ReplyDeleteThis comment has been removed by the author.
ReplyDelete@orange gorgeous
ReplyDeletepublic class pattern
{
public static void main()
{
int i,j;
for(i=1;i<=4;i++)
{
for(j=1;j<=4;j++)
{
System.out.print("*");
}
System.out.print("\n");
}
}
}
Can you help me..
ReplyDeletePattern program of a+1/3+a+2/5+a+3/7+..... to n
54321
ReplyDelete4321
321
21
21
solution for dis???
class AB
Delete{
public void accept()
{
int a=5;int b=1;
for ( int i=5;i>0;i--)
{
for( int j=i;j>=b;j--)
{
System.out.print(j);
}
System.out.println();
a--;
}
}
}
_ _ _ *
ReplyDelete_ _ * *
_ * * *
* * * *