Skip to content

Sucharita993/hollow-Triangle

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 

Repository files navigation

hollow-Triangle

Creation of hollow triangle Here we have created a 6 row hollow triangle with * symbol with the for loop
The first for loop is for row creation

 for(int i=1;i<=n;i++)

The second for loop is for column

for(int j=1;j<=m-1;j++)

The third for loop is for display of *

 for(int k=1;k<=2*i-1;k++)

Since we are creating a hollow pyramid we take onlt first column and last column into consideration
And also the last row.

if(k==1 || (k==2*i-1 || i==n))
              System.out.print("*");

All the remaining elements of the rows and columns are left empty

else
             System.out.print(" ");

A new line is started after every row

 System.out.print("\n");

OUTPUT Screenshot 2021-05-18 080213

About

Creation of hollow triangle

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages