-
September 27th, 2012, 08:57 PM
#1
Can anyone help me with my programming homework please!
I was assigned some homework today that is to do with while loops, but I am just completely lost here. I understand what while loops are, but I don't know what to do in this assignment. This was the assignment.
Write a count controlled loop than can print "i" char
the user is supposed to input a integer and that integer is how many asterisks there is on the blade, in this case it is 5.
* *
** ** **---------------
*******
** ** **
* ** * -10 Rows high
** -blade always connects on second row of handle
**
**
**
**------------------
These are the steps he told us to do it in.
1) *
**
***
****
*****
2) *
**
***
****
*****
****
***
**
*
3) * *
** **
*** ***
**** ****
**********
4) * *
** **
*** ***
**** ****
**********
**** ****
*** ***
** **
* *
5)* *
** ** **
*******
** ** **
* ** *
**
**
**
**
**
IF anyone could help me I would be extremely grateful!
-
September 27th, 2012, 08:59 PM
#2
Re: Can anyone help me with my programming homework please!
The asterisks got messed up when I posted the thread but this is what its supposed to look like.
-
September 27th, 2012, 10:11 PM
#3
Re: Can anyone help me with my programming homework please!
I would first do the loop on step one first. Notice that's only half of the shape of #2 so you just mirror the loop statement. Then you go from there.
-
September 27th, 2012, 10:21 PM
#4
Re: Can anyone help me with my programming homework please!
Originally Posted by Lethargic
I would first do the loop on step one first. Notice that's only half of the shape of #2 so you just mirror the loop statement. Then you go from there.
This is what I have so far
#include <cstdlib>
#include <iostream>
using namespace std;
int main(int argc, char *argv[])
{
char a;
int i;
a=42;
cout<<"Enter in number ";
cin>> i;
while(i>0){
cout<<a<<endl<<a;
i=i-1;
}
system("PAUSE");
return EXIT_SUCCESS;
}
I don't know what to do now. When I input a number it does however many asterisks, but how do I get the next row? Do I create another while loop?
-
September 28th, 2012, 12:15 AM
#5
Re: Can anyone help me with my programming homework please!
I would have to say, this isn't as easy as I thought. Yeah, create loops for other rows.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|