Hi. I'm new to C programming.

This is a discussion on Hi. I'm new to C programming. within the C Programming forums, part of the General Programming Boards category; I want to know how to make this using for loop a little program that will display something like this ...

  1. #1
    Registered User
    Join Date
    Oct 2008
    Posts
    2

    Hi. I'm new to C programming.

    I want to know how to make this using for loop

    a little program that will display something like this


    Enter a Number : 10 << number entered.

    then it will display this

    0
    0 1
    0 1 2
    0 1 2 3
    0 1 2 3 4
    0 1 2 3 4 5
    0 1 2 3 4 5 6
    0 1 2 3 4 5 6 7
    0 1 2 3 4 5 6 7 8
    0 1 2 3 4 5 6 7 8 9

    thanks in advance if you guys help

  2. #2
    Registered User
    Join Date
    Jan 2008
    Posts
    225
    So what have you done so far?
    Use nested for loop and do data tracing. You will get it. It's not so hard as it looks.

  3. #3
    deletedforumuser
    Guest
    Code:
    	for(int i = 0; i < 10; i++)
    	{
    
    		for(int c = 0; c < i + 1; c++)
    		{
    
    			cout << c;
    
    		}
    
    		printf("\n");
    
    	}
    Here, it takes 20 seconds to make, you might want to learn the for loop before going any farther in programming.
    Last edited by kevinawad; 10-16-2008 at 08:21 PM.

  4. #4
    Registered User
    Join Date
    Oct 2008
    Posts
    2
    oh ok i understand now. thanks.

  5. #5
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,592
    Wow, free answer on a plate - smooth
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  6. #6
    Registered User
    Join Date
    Nov 2005
    Posts
    673
    Showing a man how to do something teaches him a little. Making him do it himself teaches him a lot, and doing it for him teaches him nothing.

    Kevin please read the bolded part of that phrase.

  7. #7
    Captain Crash brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,246
    A combination of C++ and C I/O calls is..weird.
    Code:
    //try
    //{
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);
    //}

  8. #8
    Registered User
    Join Date
    Oct 2008
    Posts
    61
    well quick answer man....no explanation..erm..

  9. #9
    deletedforumuser
    Guest
    Haha, i didn't even realize i used cout to print text.

    I'm not a C programmer, i used cout and then printf, how stupid am i.

    Oh well, i guess i won't make the code for people next time.

  10. #10
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    Well its a C forum anyway, so Kevin's answer contains code that will earn the OP a big fat donut on the assignment.

  11. #11
    deletedforumuser
    Guest
    But really, i have way more logic then before, first time i started programming, it would take me about 1 hour to find about how to make this code,

    Go check my first thread and laugh at me. I was 13. Now im 15.

    I'm doing alot of improvement, at my school, they teach me Visual basic. It is so easy.

    The problems im having now are maths. I don't want maths to burn down my dream to actually make a game company.

    If i finally make a game company, that's because of this forum and you guys who help me.



    I'm right now planning on working on a 2d online role playing game at the age of 17.

    I still have 2 years left to begin working on this project. I will accomplish 2d graphic programming for sure way before 2 years.

    Most of the game programmers don't even know anything about games.
    The thing that helps me continue working on programming is{

    This forum,
    The online games,
    My mom for telling me she will invest all the money i need on my company and she will pay any programming course if i need some.
    My friends for calling me a nerd even tho i am mentally.

    Well, that's the story of my life.

  12. #12
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    Just take some Trig and Linear algebra and you will be fine. Ok? I don't think that is too steep for you and should cause your dreams to fade into oblivion.

    And look, here is the deal. Development teams specialize. I am always one of those "math guy" so I usually end up doing stuff like 3d and special effects in a team. While other times the non-mathematically inclined guys get put on building dev tools or loaders or other areas that are not as math oriented.

    You will have to get your algebra down pretty cold. I think that is just a given... I mean in honesty us programmer types are usually pretty decent in algebra and geometry if nothing else. And that sort of comes with practice even if you don't crack open books. Eventually you will just sort of second nature yourself into basic math reasoning skills.

Popular pages Recent additions subscribe to a feed

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