Displaying a set of patterns

This is a discussion on Displaying a set of patterns within the C++ Programming forums, part of the General Programming Boards category; Hi all, I need to write pseudo-codes for these 2 patterns. I did execute the program in C++,it displays it ...

  1. #1
    Registered User
    Join Date
    Jun 2010
    Posts
    1

    Displaying a set of patterns

    Hi all,

    I need to write pseudo-codes for these 2 patterns.

    I did execute the program in C++,it displays it like:

    *
    **
    ***
    ****
    *****
    ******
    but I am unable to display where there are the same amount of asterisks, I highlight them in red. I am unable to make it work well where the same amount of asterisks is being repeated on the 2 rows.

    I am placing my pseudocodes too.

    The pattern has the following format:

    1.

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

    2.

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

    Pseudo:
    1. For the ascending pattern:

    declare variables x,y,a as integers
    read a
    for x=0 to a increment x by 1
    begin
    for y=0 to x increment y by 1
    begin
    display "*"
    end for

    end for

    2. For the descending pattern:
    declare variables x,y,a as integers
    read a
    for x=0 to a-1 decrement x by 1
    begin
    for y=0 to x increment y by 1
    begin
    display "*"
    end for

    end for

    Plz I would like to have some suggestions to what I post..

    I am in a hurry to fix it.

    Thanks

  2. #2
    Registered User C_ntua's Avatar
    Join Date
    Jun 2008
    Posts
    1,853
    You want maybe (I am not sure if this is what you mean)
    declare variables x,y,a as integers, temp
    read a
    for x=0 to a increment x by 1
    begin
    if (x == 3 || x == 3)
    temp = x-1;
    else
    temp = x;

    for y=0 to temp increment y by 1
    begin
    display "*"
    end for
    end for

  3. #3
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,596
    Wow. How many times must we see this same question?

  4. #4
    ...and never returned. StainedBlue's Avatar
    Join Date
    Aug 2009
    Posts
    168
    Quote Originally Posted by Bubba View Post
    Wow. How many times must we see this same question?
    Until "how to print stars assignment" surpasses "programming homework forum" on all the search engine rankings.
    goto( comeFrom() );

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Compiling errors and using Cmake Set Policy
    By eligor in forum Linux Programming
    Replies: 2
    Last Post: 01-25-2010, 12:43 PM
  2. Need some help...
    By darkconvoy in forum C Programming
    Replies: 32
    Last Post: 04-29-2008, 03:33 PM
  3. Replies: 8
    Last Post: 01-18-2008, 03:06 AM
  4. The new FAQ
    By Hammer in forum A Brief History of Cprogramming.com
    Replies: 34
    Last Post: 08-30-2006, 10:05 AM
  5. Set default directory with GetTempDir?
    By Bajanine in forum Windows Programming
    Replies: 2
    Last Post: 05-04-2003, 11:36 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21