Can anyone help me with my programming homework please!
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

Thread: Can anyone help me with my programming homework please!

  1. #1
    Join Date
    Sep 2012
    Posts
    3

    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!

  2. #2
    Join Date
    Sep 2012
    Posts
    3

    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.

    Name:  Capture.JPG
Views: 63
Size:  19.7 KB

  3. #3
    Join Date
    Sep 2012
    Posts
    10

    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.

  4. #4
    Join Date
    Sep 2012
    Posts
    3

    Re: Can anyone help me with my programming homework please!

    Quote Originally Posted by Lethargic View Post
    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?

  5. #5
    Join Date
    Sep 2012
    Posts
    10

    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
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center