the output is like this:
if n=5
* * * * *
* * * *
* * *
**
*
pls...... explain how for loop executes this one?
im just a newbie of C.
pls explain for loop outputfor loop
Page 1 of 1
2 Replies - 4537 Views - Last Post: 17 July 2007 - 04:40 AM
Replies To: pls explain for loop output
#2
Re: pls explain for loop output
Posted 17 July 2007 - 04:10 AM
grungekaze, on 17 Jul, 2007 - 03:08 AM, said:
the output is like this:
if n=5
* * * * *
* * * *
* * *
**
*
pls...... explain how for loop executes this one?
im just a newbie of C.
if n=5
* * * * *
* * * *
* * *
**
*
pls...... explain how for loop executes this one?
im just a newbie of C.
You would need to have a counter & during each you will print an '*' charactor for the value of the counter. At the end of each loop, decrease the counter by one. You will also need a 2nd counter to add the spaces, which will increase at the end of each loop.
Good luck!
#3
Re: pls explain for loop output
Posted 17 July 2007 - 04:40 AM
You wouldn't need a second counter for the spaces, as there is no problem in this simple program with just adding a space character after every *, eg:
printf ("* ");
Page 1 of 1
|
|

New Topic/Question
Reply




MultiQuote



|