techhipbettruvabetnorabahisbahis forumutaraftarium24edusedueduseduseduseduedueduedusedu C Program Half Diamond Star Pattern | C Pattern Programs
Latest :

C Program Half Diamond Star Pattern | C Pattern Programs

C program to print a half diamond star pattern – In this article, we will brief in on the several methods used to print a half diamond star pattern in C programming.

Suitable examples and sample programs have also been added so that you can understand the whole thing very clearly. The compiler has also been added with which you can execute it yourself.

The ways used to do so in this specific article are as follows:

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

As we all know, a diamond is a very popular shape that is generally used in daily life, unlike the actual thing which is extremely expensive.

This is how a half diamond star pattern looks like:

As you can see, firstly, you need to enter the number of rows to print the diamond star.

Then, the number that you have entered, those many rows will be printed on both sides of the middle.

Thus, the ways to print a half diamond star pattern are as follows:

Using For Loop

  1. Read the no.of rows, symbol and store the rows number into n, symbol into ch.

2) The 1st for loop iterates through rows with the structure for(i=1;i<=n;i++).

a) The 2nd for loop iterates through columns with the structure for(j=1;j<=i;j++).

It prints symbol.

b) Cursor comes to next line after each iteration of the 1st for the loop.

An upper part of the half diamond pattern will be formed after all iterations of above for loops.

3) The 3rd for loop iterates through rows with the structure for(i=n-1;i>0;i–).

a) The 4th for loop iterates through columns with the structure for(j=1;j<=i;j++)

It prints symbol.

b) Cursor comes to next line for each iteration of the  3rd for the loop.

A lower part of the half diamond will be formed after all iterations of 3rd for loop, 4th for the loop.

Output:

Using While Loop

  1. The 1st while loop iterates through rows until the condition i<=n becomes false.

a)The 2nd while loop iterates through columns until the condition j<=i becomes false.

It prints symbol.j value increased by 1.2nd while loop again checks the condition.

b) Cursor comes to next line.i value increased by 1. The 1st while loop again checks the condition.

2,3 steps represent the upper part of the half diamond star pattern.

2) i=n-1, The 3rd while loop iterates through rows until the condition i>0 becomes false.

a) The 4th while loop iterates through columns until the condition j<=i becomes false.

It prints symbol.j value increased by 1. The 4th while loop again checks the condition.

b) Cursor comes to next line. i value decreased by 1. The 3rd while loop again checks the condition.

Output:

Using Do-While Loop

  1. For half part of the half diamond star pattern.

2) The 1st do-while loop iterates through rows.

a) The 2nd do-while loop iterates through columns.

It prints symbol.j value increased by 1.

Checks the condition j<=i. If condition true then loop iterates again. Repeats until the condition becomes false.

b) Cursor comes to next line.i value increased by 1.

c) Checks the condition i<=n. If the condition is true then the loop iterates again. Repeats until the condition becomes false.

For below half part of the half diamond star pattern.

3)i=n-1, The 3rd do-while loop iterates through rows.

a) j=1, The 4th do-while loop iterates through columns.

It prints symbol. j value increased by 1.

Checks the condition j<=i. If the condition is true then loop iterates again. Repeats until the condition becomes false.

b) Cursor comes to next line.i value decreased by 1.

c) Checks the condition i>0. If the condition is true, loop iterates again. Repeats until the condition becomes false.

Output:
techhipbettruvabetnorabahisbahis forumutaraftarium24eduedueduseduseduedueduseduedusedu
x

Check Also

C Program To Find Maximum Between Three Numbers | C Programs

C Program to find maximum between three numbers –  In this article, we will detail ...

grandpashabetgrandpashabetgrandpashabethttps://mobilebarhawaii.com/ballettea tropazcasibom girişcasibomhacklinkgrandpashabetbets10onwinonwin girişselcuksportshdgrandpashabetholiganbetatakoy escortatakoy escortsisli escortjojobetCasibomtürk pornomatbetcratosroyalbetdeneme bonusu veren sitelergrandpashabetonwinligobetgonabetJojobetsahabethttps://www.escortbayanlariz.net/betwoonsahabetcasibomcasibom girişTekirdağ escortjojobetbakırköy escortdeneme bonusu veren sitelerhalkali escortgrandpashabet girişcasibom girişankara escort bayancasino siteleriultrabetgrandpashabet girişholiganbetonwinholiganbetSekabetgrandpashabetesenyurt anal escortLunabetnakitbahisjojobetgrandpashabetİstanbul Escorthttps://www.gvscolombia.com/betebetdeneme bonusu veren sitelerJojobet GirişstarzbetsavoybettingsavoybettingjojobetfixbetBetturkey girişcasibom güncel girişkucukcekmece escortholiganbetimajbetkingroyalmadridbetmatbetmavibetmeritbetmeritkingonwinotobetmeritbetimajbetcasibomsekabetbetvolebetordercasinolevantArtemisbetmadridbetmavibetmeritking girişotobetjojobetholiganbetholiganbet girişonwincasibom girişcasibom girişsahabet girişmadridbetbetturkey girişmarsbahis giriş güncelsahabet güncel giriştipobetistanbul escortscanlı bahisstarzbetmegabahisjojobetenbetvbettrromabetcasibom girişcasibomcasibom güncel girişjojobetmegabahisjojobet girişmarsbahiszbahisperabetbakırköy escortdeneme bonusu veren sitelerbetebet güncel girişdumanbetsightcarebilyoneronwinonwinsahabetbets10,bets10 giriş,bets10 güncel giriştipobetmarsbahis,marsbahis güncel giriş , marsbahis giriş,marsbahis adresmarsbahis,marsbahis güncel giriş , marsbahis giriş,marsbahis adressekabetpradabettarafbetmilanobetmilanobetpusulabettempobetpusulabettempobetpusulabetjojobetbets10madridbetBostancı escort Bağcılar escorttümbetjojobet,jojobet girişsekabet girişjojobet,jojobet girişjojobetbornova escortcasibomtipobetjasminbetİstanbul Escortbahis sitelericasibomjojobet girişJojobet Girişankara escortzbahiszbahis girişzbahis güncel girişholiganbetcasibomsonbahisdeneme bonusu veren siteler 2025vaycasinocasinomaxizbahisotobet girişimajbetcasibomvaycasinojojobet girişbetturkeymarsbahis girişmatbet girişmarsbahisbetturkeybetexperdeneme bonusu veren sitelermariobetwinxbetbetexperbetofficegonebetgrandpashabetgrandpashabet güncelpusulabetpusulabetcasibom girişonwin,onwin giriş,onwin güncel giriş,onwin giriş adresitipobetbetebetmarsbahisultrabetholiganbetjojobetfixbetkulisbetnakitbahispinbahisrestbettipobettrendbetultrabetjojobetholiganbetotobetbetexperpusulabetasyabahisparibahistambettipobetHoliganbet girişfixbetvaycasinojojobet,jojobet girişonwinhttps://sahipleniyorum.com/jojobetjojobet girişmegabahismatbetcasibomcasibom girişmaltepe escortsahabet girişmecidiyeköy escortsekabet girişjojobettipobetbetturkeygonabettipobetcasibom girişimajbetimajbet girişCasibommavibetmavibet güncelJojobet girişMAVİBETİMAJBETmavibetzbahismarsbahisforum bahiscasibom giriştakipçi hilesivaycasinocashback girişjojobetgonebetjojobetjojobetgüncel girişcasinoroyalcasibom