This is my first time posting in here, hopefully I am doing it right.
Basically I need help trying to figure out some code that I wrote for class using C. The purpose o
The simplest answer to why that is happening is because one loop prints spaces like this represented by -.
----------
---------
--------
-------
------
-----
and so on. The hashes are printed like this
------#
-----##
----###
---####
--#####
-######
since hash printing loop at second stage needs to print equal no of hashes more to complete the pyramid it can be solved by two methods one by copying and pasting hash loop twice or by making the loop run twice next time by following modification
for ( int hash = 0; hash <= tall*2; hash++ )
{
printf ( "#" );
}
The logic to build such loops is simple the outermost loop prints one line feed to seperate loops,the inner loops are responsible for each lines contents. The space loop puts spaces and hash loop appends hash at end of spaces. [My answer can be redundant because i did not read other answers so much carefully,they were long] Result:
#
###
#####
#######
#########
###########