Thread: problem creating program to the specific specification

  1. #16
    Registered User
    Join Date
    Nov 2008
    Posts
    42
    Quote Originally Posted by laserlight View Post
    What is your current code?
    well its basically the same as the first code in the first post, but I am struggling to change it so the triangle is upside down.

  2. #17
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by rushhour View Post
    well its basically the same as the first code in the first post, but I am struggling to change it so the triangle is upside down.
    So POST YOUR CURRENT code.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  3. #18
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Quote Originally Posted by rushhour
    well its basically the same as the first code in the first post, but I am struggling to change it so the triangle is upside down.
    Yes, of course, but then I can tell you that the answer is basically the same as the code in the first post

    Let's see what you have tried.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  4. #19
    Registered User
    Join Date
    Nov 2008
    Posts
    42
    Well I know it needs to be reversed somehow so that it prints fewer spaces in the first loop and more spaces towards the end of the loop. And the second loop to print more * in the beginning and less * towards the end of the loop. Im just having difficulty reversing it.

  5. #20
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Think of a formula that relates the number of spaces and the number of stars on each line. For example, does the sum of the number of spaces and number of stars per line ever change?
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  6. #21
    Registered User
    Join Date
    Nov 2008
    Posts
    42
    Quote Originally Posted by laserlight View Post
    Think of a formula that relates the number of spaces and the number of stars on each line. For example, does the sum of the number of spaces and number of stars per line ever change?
    Well is it something like this for example:

    Code:
    for(k = 1;  k<=i;k++)
    for the first loop and for example the second loop:

    Code:
    for(k=1;k<(n-i)*2;k++)
    tell me if i am heading in the right direction, then i can possibly do it
    Last edited by rushhour; 11-27-2008 at 03:02 PM. Reason: added second loop

  7. #22
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    I have not checked if your formulae are correct, but yes, you are on the* right track since (n-i) in the second loop causes its number of iterations to decrease and i increases.

    * or I should say a right track, since there are other possibilities.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  8. #23
    chococoder
    Join Date
    Nov 2004
    Posts
    515
    Quote Originally Posted by rushhour View Post
    But the thing is, I am stuck, and need advice from expert programmers. I joined this forum thinking I could get help. I find that I learn more when someone does it, and it helps me complete the other tasks set, if you get me. So please, just this once can you help me.
    you're stuck because you didn't put in any effort to actually learn what you're supposed to be learning.
    If you had you'd have had no trouble whatsoever writing a correctly working program on your own rather than scouring some book or website, finding something that looks similar to what you're supposed to do, and beg on some other website for people to "fix" it for you.

    With that attitude you'll never make it as a developer, but you might make it as a project manager.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problem with my program i cant figure out...
    By youareafever in forum C Programming
    Replies: 7
    Last Post: 11-01-2008, 11:56 PM
  2. Replies: 4
    Last Post: 05-25-2008, 12:31 AM
  3. simple frontend program problem
    By gandalf_bar in forum Linux Programming
    Replies: 16
    Last Post: 04-22-2004, 06:33 AM
  4. fopen();
    By GanglyLamb in forum C Programming
    Replies: 8
    Last Post: 11-03-2002, 12:39 PM
  5. Console Program Problem
    By Breach23 in forum C++ Programming
    Replies: 3
    Last Post: 10-19-2001, 12:35 AM