Results 1 to 2 of 2

Thread: HELP ME with this......

  1. #1
    amani
    Guest

    HELP ME with this......

    Hi guys,

    I need some help from you using C++.

    The problem is.....

    to print '*'s. Accept from the user the no. of columns........

    for eg: The user enters 5. I need to display...

    *
    ***
    *****
    ***
    *

    If you observe this........there are 5 columns..........b'cos I entered 5. If the user enters 9, then I need to display these '*'s in 9 cols.....

    Hope you guys understood.

    I need this........PLEASE..

  2. #2
    Member
    Join Date
    May 2001
    Location
    UK
    Posts
    40
    Hi Amani,

    Not sure this is exactly what you are after, but its a start

    #include <iostream.h>

    int main()
    {

    int n = 0;

    do
    {
    cout << "Please enter a odd number!" ;
    cin >> n;
    if (n%2==0)cout << "You have entered a even number! Please try again." <<"\n";
    else cout <<"\n" << "Thanks you.." << "\n\n";
    }
    while (n%2==0);

    for (int i=1;i <= n;i++)
    {
    for (int y=1, int z=n;y <= i && z >= i ;y++,z--)cout << "*" ;
    cout << "\n";
    }

    return 0;

    }


    HTH

    hmm

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width