need help

This is a discussion on need help within the C++ Programming forums, part of the General Programming Boards category; can somebody help me solve this quest write a for loop which wll produce the followingoutput 1 22 333 4444 ...

  1. #1
    Registered User
    Join Date
    May 2009
    Posts
    23

    Unhappy need help

    can somebody help me solve this quest
    write a for loop which wll produce the followingoutput
    1
    22
    333
    4444
    55555

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,310
    This quest doth indeed require a loop, unless thou desires recursion, template metaprogramming, or simple hard coding. Let us see what progress thy hath made, and we shall dispense advice with greater clarity.

    (Pardon my possibly flawed attempt at being fancy, and remember to read and follow the homework policy as you venture on your quests.)
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Registered User
    Join Date
    May 2009
    Posts
    23

    Smile

    hey thank you so please can you help me coz i am still a freshman at uni

  4. #4
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,310
    As I said, you should post what you have tried.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  5. #5
    Registered User
    Join Date
    May 2009
    Posts
    23

    Angry

    ok let see whose the king of C++ U GIVE ME YOUR SOLUTIONS AND I'LL GIVE U MINE

  6. #6
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,310
    No. My avatar is the witch queen of C++, and she seeks no suitors.

    But the point is this: we are not going to do your homework. Do it yourself, and approach us if you need help in fixing or improving your solution.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  7. #7
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,420
    OK, try this one
    Code:
    for ( i = 1000000 ; i <= 1000000 ; i++ ) {
      printf("1\n"
             "22\n"
             "333\n"
             "4444\n"
             "55555\n" );
    }
    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.

  8. #8
    Registered User
    Join Date
    May 2009
    Posts
    23

    Thumbs up

    hey thanks mate for your help i was just kidding about being the C++ KING THIS site is awesome

  9. #9
    Registered User
    Join Date
    May 2009
    Posts
    23
    hey sorry about yesterday for being rude.i've got a quest do you think deitel &deitel books for C++ programming is also good to use or can u recommend any other books

  10. #10
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,310
    Quote Originally Posted by luke luvevou
    i've got a quest do you think deitel &deitel books for C++ programming is also good to use or can u recommend any other books
    We have a book recommendation thread stickied in this forum, and there is a new forum dedicated to reviews. By the way, as much as I enjoy poking fun at your "quests", please say "question" when you mean it.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  11. #11
    Registered User
    Join Date
    May 2009
    Posts
    23

    Wink

    Quote Originally Posted by laserlight View Post
    No. My avatar is the witch queen of C++, and she seeks no suitors.

    But the point is this: we are not going to do your homework. Do it yourself, and approach us if you need help in fixing or improving your solution.
    hey I'm just making a sort form of it and by i am just a beginner in C++ i was just kidding about yesterday

  12. #12
    Registered User
    Join Date
    May 2009
    Posts
    23
    hey sorry for that somebody was disturbing me so i have to eliminate her

  13. #13
    Registered User NeonBlack's Avatar
    Join Date
    Nov 2007
    Posts
    435
    I don't know if this is right, but it works for me.

    Code:
    #include <iostream>
    int main(int argc, char** argv)
    {
    	for (int j=!argc; j-argc; j=j+!!argc, std::cout<<argc);
    	{
    		std::cout<<std::endl;
    	}
    	return !(argc-5)||main(!!argc+argc,argv);
    }
    I copied it from the last program in which I passed a parameter, which would have been pre-1989 I guess. - esbo

  14. #14
    Registered User
    Join Date
    Jan 2007
    Posts
    35
    Code:
    for (i=1;i<max;i++)
    {
       for(j=i;j>0;j--)
          { 
          cout<<i;
          }
    
    cout<<"\n";
    }

    try similar logic i guess it will work

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