Thread: beginner help c++

  1. #1
    Registered User
    Join Date
    Sep 2010

    beginner help c++

    hey mates I need some help and have some question.

    #include <iostream>
    #include <string>
    #include <cstdlib>
    #include <ctime> 
    using namespace std;
    int main()
    int in = 0;
    cout << "type a value" << endl;
    cin >> in;
    for(int j = 0; j < in; j++) 
    for(int i = 0; i <= j; i++)
    cout << "*";
    cout << endl;
    return 0;
    Is there a way to loop this program til I type the integer value 0, it will shut down?
    I would appreciated if anyone would add this to my code.

    A question

    for(int j = 0; j < in; j++)

    for(int i = 0; i <= j; i++)

    can anyone tell my in simplified laughed what they do? especially the second one, the first one kind of shows shows the "*" given what value you type, not sure.


  2. #2
    Registered User rogster001's Avatar
    Join Date
    Aug 2006
    Liverpool UK
    for your first question learn about while loops to do it.

    the second one what don't you understand? note IMO i think you should always use curly braces when writing for loops, even when there is only one statement following.
    Thought for the day:
    "Are you sure your sanity chip is fully screwed in sir?" (Kryten)
    FLTK: "The most fun you can have with your clothes on."

    "If I had thought of it and had some marketing sense every computer and just about any gadget would have had a little 'C++ Inside' sticker on it'"

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. ADO.NET in VS2008 or gdi+ (beginner question)
    By robgar in forum C# Programming
    Replies: 3
    Last Post: 10-04-2009, 02:40 AM
  2. Same old beginner question...
    By Sharmz in forum C Programming
    Replies: 15
    Last Post: 08-04-2008, 11:48 AM
  3. What are some good beginner programs I shouold make?
    By oobootsy1 in forum C# Programming
    Replies: 6
    Last Post: 08-09-2005, 02:02 PM
  4. Windows programming for beginner (Absolute beginner)
    By WDT in forum Windows Programming
    Replies: 4
    Last Post: 01-06-2004, 11:21 AM