techhipbettruvabetnorabahisbahis forumutaraftarium24edusedusedueduedueduseduseduedusedus Java Inverted Mirrored Right Triangle Star Pattern
Latest :

Java Inverted Mirrored Right Triangle Star Pattern

Java program to print Inverted mirrored right triangle star pattern program. We have written below the print/draw inverted mirrored 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 the scanner object sc and store the value in the variable n.

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

3) The outer loop executes the inner loops if the condition i>0 is true. The 1st inner loop prints space if the condition j>0, it runs with the structure for(int j=n-i;j>0;j–), the 2nd inner loop prints character if the condition j<i is true,runs with the structure  for(int j=0;j<i;j++).

4) In this example n=7, the condition i>0 is true at the outer loop, in the 1st inner loop the condition fails, comes to next inner loop checks the condition. Here if the condition is true then it prints the character, this loop prints the characters from j=0 to j=6, 1st iteration completed, this pattern will be printed *******.

5) for n=6, the 1st inner loop prints one space, the 2nd inner loop prints character from j=0 to j=5. After total iterations of the outer loop, this pattern will be printed.

Output:

Using While Loop

1) Checks the condition at while i>0 if it is true then j value initialized to j=n-i

a) 1st inner loop prints space if j–>0 is true, this loop repeats until the condition is false. If false, j initialized to 0.

b) 2nd inner loop prints character if j++<i is true, this loop repeats until the condition is false, executes the next statement “System.out.println();

2) Cursor comes to next line i value decreased by value 1 and checks the condition at outer loop. It repeats until the condition is false

Output:

Using Do-While Loop

1) j value initialized to n-i and while loop prints the space if the condition j–>0 is true. If false j initialized to j=0.

2) Inner do loop prints the character once then it checks the while condition ++j<i, if it is true then it prints character, it repeats until the condition while(++j<i); is false, next cursor comes to next line.

3) Then it checks the condition while(–i>0) at outer do loop, if it is true then do loop executes the inner code, it repeats until the condition is false.

Output:

For More Java Programs Check Here – More than 500+ Java Programs are Published Here

techhipbettruvabetnorabahisbahis forumutaraftarium24edusedusedusedusedueduseduseduseduedu
x

Check Also

Rhombus Star Pattern Program In Java – Patterns

Java program to print Rhombus star pattern program. We have written the below print/draw Rhombus ...

cratosroyalbetgrandpashabetgrandpashabethttps://mobilebarhawaii.com/ballettea tropazhacklinkgrandpashabetonwinonwin girişselcuksportshdbahsegelatakoy escortatakoy escortcratosroyalbetonwinligobetkingroyal girişJojobetgrandpashabetİzmit escortbakırköy escortdeneme bonusu veren sitelerhalkali escortgrandpashabetonwinyurtiçi kargoesenyurt anal escortbets10starzbetmaltcasinomaltcasinojojobet girişfixbetkucukcekmece escortistanbul escortstarzbetjojobetfast creditsightcareİstanbul Escortantalya escortNorabahisfixbetmaltepe escortÜmraniye Escortholiganbetbets10takipçi satın aldeneme bonusu veren sitelerkingroyalnerobetetrabetcashback girişcasibomjojobetholiganbetsahabetcasibomcasibommariobetgrandpashabetGrandpashabetGrandpashabetholiganbetdeneme bonusu veren sitelermarsbahisGrandpashabetholiganbet güncel girişjojobet girişmarsbahisdeneme bonusu veren sitelermeritkingmatbethttps://markaescort.org/bolgeler/kartalartemisbet güncel girişescort kadıköyholiganbetsahabet girişonwin girişpusulabetmarsbahis giriş güncelmarsbahis güncel girişsahabetbahiscomkulisbetarnavutkoy escorttempobettarafbetsavoybettingsahabetsekabetmobilbahismadridbetbetturkeyholiganbet girişzbahismeritbetbets10ultrabetdinamobetbetkanyonstarzbetsuperbetinbetzulasuperbetinbetebetmilanobetbetturkey girişholiganbet girişmarsbahistempobetbetebetpusulabetonwin,onwin giriş,onwin güncel giriş,onwin giriş adresisahabetsekabet girişmatbet girişmarsbahis girişonwinmarsbahis girişsahabet girişsekabet girişmatbetbetturkey,betturkey girişimajbet,imajbet giriş,imajbet güncel giriş,imajbet resmi girişsahabetsahabetholiganbetkralbetmarsbahis,marsbahis güncel giriş , marsbahis giriş,marsbahis adresonwinsahabet,sahabet giriş,sahabet güncel giriş,sahabet resmi girişpusulabetmeritkingmavibetmobilbahiskingroyalbetebetnakitbahisMatbetholiganbetmetamaskmarsbahiskingroyalonwinmatbetpusulabetholiganbet girişmarsbahisgrandpashabetdinamobetbayconti girişGrandpashabetbetebetholiganbetsekabetbetsatholiganbetjojobetkingbettinggrandpashabet girişgrandpashabetjustin tv1xbethttps://canlicasino.shorthandstories.com/https://canlicasino.shorthandstories.com/deneme bonusu veren sitelerjojobetimajbet girişjojobet girişjojobet girişgamdomsahabetİzmit escortdeneme bonusukralbet güncel girişbetexperholiganbet girişjojobetsekabetsekabet girişpadişahbetistanbul escortgrandpashabetmarsbahistipobetmadridbetHoliganbet marsbahisholiganbetholiganbetimajbetjojobetistanbul, escortdumanbetcasibomjojobetdeneme bonusudeneme bonusu veren sitelerrestbetgrandpashabet girişgrandpashabet girişmadridbetLimanbetdeneme bonusu veren sitelerdeneme bonusu veren siteleronwinonwinonwinbetturkey girişholiganbetdinamobetmarsbahis