Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)
Hollow Inverted Right Triangle Star Pattern Java Program
Latest :

Hollow Inverted Right Triangle Star Pattern Java Program

Java program to print hollow inverted right triangle star pattern program. We have written below the print/draw hollow inverted right triangle asterisk/star pattern program in four different ways with sample example and output, check it out. At the end of the program, we have added compiler so that you can execute the below codes.

  • Using For Loop
  • Using While Loop
  • Using Do While Loop

Using For Loop

1) Read the n value using scanner class method as  sc.nextInt().

2) Run the outer for loop with the structure for(int i=n;i>0;i–) to iterate through rows, to iterate through columns run the inner for loops.

3) The 1st for loop prints character if the condition if(i==1 || i==n) is true and j<=i is true, with the structure

for(int j=1;j<=i;j++).

After completion of all iterations, the following pattern will be printed.

Using For Loop:

Output:

Using While Loop

1) Checks the condition at while i>0, if true it executes the inner statements.

2) checks the if condition if(i==1 || i==n)

a) if true j initialized to 1, executes the 1st inner while loop, this loop prints character if the condition while(j <=i) is true, then increases the j value by 1, repeats until the condition is false.

b) if false j initialized to 1, while loop prints character if ( if(j==1 || j==i) true and (j<=i)) otherwise prints space, then j value increased by 1, repeats until j<=i is false.

3) Cursor comes to next line i value decreased by 1 and condition at outer while will be checked, repeats until i>0 is false at outer while loop.

Output:

Using Do While Loop

1) In outer do loop checks the if condition

a)if true 1st inner do loop will execute, j initialized to 1 and prints the character once then checks the condition at while(++j <=i), if it is true then prints the character and then checks the condition, repeats until while(++j <=i) condition is false.

b) if false, j initialized to 1, the do loop prints the character if the condition if(j==1 || j==i) is true else prints space, then checks the condition at  while(++j<=i), repeats until while(++j<=i) condition is false.

2) Cursor comes to next line, then checks the condition at outer do-while loop while(–i>0), repeat until this condition is false.

Output:

More Java Programs:

x

Check Also

HCF Of Two & N Numbers Java Program | 3 Ways

Java program to find HCF of two numbers – The below given Java programs explains ...

atakoy escortatakoy escortbakırköy escortşişli escortbağcılar escortsightcaredeneme bonusu veren sitelerromabetdeneme bonusu veren sitelerdeneme bonusu veren sitelerDeneme Bonusu Veren SitelerDeneme Bonusu Veren SitelerDeneme Bonusu Veren SitelerDeneme Bonusu Veren Sitelersekabetdeneme bonusu veren sitelergrandpashabetgrandpashabetGrandpashabetdeneme bonusu veren sitelerdeneme bonusu veren sitelercasibomcasibom güncel girişdeneme bonusu veren sitelerdeneme bonusu veren sitelerdeneme bonusu veren sitelerdeneme bonusu veren sitelercasinofastbetwoonroyalbetdeneme bonusugrandpashabetdeneme bonusu veren sitelermarsbahis girişvaycasino girişmeritkingdeneme bonusu veren sitelerdeneme bonusu veren sitelerdeneme bonusu veren sitelerdeneme bonusu veren sitelerdeneme bonusu veren sitelerromabetistanbul escortgrandpashabetgrandpashabetgrandpashabetgrandpashabetelitcasinocasibomjojobetcasibomcasibom girişcasibom girişcasibomgrandpashabetcasibom girişcasibomcasibom girişcasibomcasibom güncel girişcasibomcasibom girişcasibomcasibom girişcasibom girişcasibom güncel girişgrandpashabetgrandpashabet girişgrandpashabetgrandpashabet girişbetgray güncel girişvdcasinograndpashabetgrandpashabetgrandpashabetgrandpashabetgrandpashabetGrandpashabetzbahiscasibom girişcasibom girişcasibom girişdeneme bonusubetcio girişbetkomdeneme bonusu veren sitelerRokubetjojobetDeneme Bonusu Veren SitelerjojobetcasibompadişahbetjojobetjcknepadişahbetBetsatVdcasinorotabetsekabetHoliganbetzbahiszbahisotobetnakitbahiskingroyalkingroyalmadridbetmadridbettarafbet토토사이트avrupabetmarsbahisLefkoşa İngilizce KursuportobettimebettimebetdizipalRokubet girişcasibombetparkbetparkcasibomcasibomcasibommeybetbetpuancasibom girişzbahiscasibommatbet girişvdcasino giriştempobetpusulabet girişgrandpashabet girişmeritking girişgrandpashabet girişmeritking girişbahiscom girişonwinmatadorbetjojobetsahabetmatadorbetonwinsahabetsahabet girişjojobet girişsahabetmatadorbet girişsahabetsahabetonwin güncel girişonwinonwinonwincasibomcasibomcasibomcasibom girişcasibomcasibom girişholiganbetpusulabetbetboobetparktempobetextrabetmegabahisbetpuansahabet güncel girişonwinmatadorbetholiganbetsahabetkralbet girişkralbetsahabetsahabet güncel girişsahabet güncel girişpusulabetmatadorbetbets10bets10 girişpusulabet girişonwin güncel girişsahabet güncel girişpusulabet girişbetboo girişpusulabetslotbarmatadorbetbetboomatbet orijinalbetparktempobetsahabet güncel girişextrabet güncel girişCasibombetpuanslotbarbahiscombetpuangrandpashabet girişcasibomcasibomcasinoper girişcasinoperPusulabetcasibom girişdedebetromabettambetdinamobetsahabetbetwoonfenerbahçebetofficejojobetgrandpashabetgrandpashabetgrandpashabetlunabetgrandpashabetmarsbahis