Hi,
You seem to able to write loops etc., so I'll just provide you one possible approach and leave the coding to you.
It usually helps if you break down the problem into smaller ones.. The problem is to use for-loops to print out a certain number of lines, each with a certain number of words.
So we'll use a for-loop to print line-by-line and an inner for-loop to print the words in each line.
First you need to print 9 lines - so that means using an outer for-loop going from 1 to 9 (say the index is "i")
Then for each line, how many words do you need to print?
By inspection, it is equal to the line number (first line 1
word, 2nd line 2 words, etc.)
So this means the inner for-loop goes from 1 to i
So,
This will give you the correct number of words in the correct number of lines but, as you will see, all the values are wrong.
I'll leave it to you to see how to tweak this so that you get the right values.
Hint:- What you have to tweak is the amount that is added to 100*i every time
I mean the code is going to be short, but there are so many factors involved
Yes it'll take just 4 lines.
Hope this helps, let us know how it goes
[ July 18, 2005: Message edited by: Ravi Srinivas ]
[ July 18, 2005: Message edited by: Ravi Srinivas ]