Thread: Need some answers to these super short problems

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Jan 2010
    Posts
    8

    Need some answers to these super short problems

    Hey folks,
    Got an exam tomorrow and need these done in C++ in a short time. They're very easy exercises and I'm just too busy with my websites and other projects . I'd be glad to reward the one who'll finish these for me with a domain (www.thetechtalks.com)...

    I need those finished in 2 hours:

    http://i49.tinypic.com/259lkdy.jpg


    Thanks

  2. #2
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    Welcome to the board. Please read our homework policy. In other words, write some code and post whatever questions you have here, if you get stuck.

    Cheers.

  3. #3
    Registered User
    Join Date
    Jan 2010
    Posts
    8
    Quote Originally Posted by Sebastiani View Post
    Welcome to the board. Please read our homework policy. In other words, write some code and post whatever questions you have here, if you get stuck.

    Cheers.
    Im offering a domain in exchange for this...

    Im just too busy with other stuffs folks. Would appriciate some help

  4. #4
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,318
    Quote Originally Posted by dnilra View Post
    Im offering a domain in exchange for this...
    Right, so you were publicly offering a bribe for others to help you break the rules?

    Think again!
    My homepage
    Advice: Take only as directed - If symptoms persist, please see your debugger

    Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"

  5. #5
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,666
    What a load of rubbish - pathetic excuse.
    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.

  6. #6
    Registered User
    Join Date
    Feb 2009
    Posts
    329
    Even for a beginner, this is only a couple of hours work I would imagine! It's pretty much all the same code. You'd better get some caffeine in!
    Last edited by darren78; 01-12-2010 at 03:23 PM.

  7. #7
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    Perhaps something like this would be more appropriate, then? Point is, this just isn't the forum for such a thing. Good luck.

  8. #8
    Registered User
    Join Date
    Jan 2010
    Posts
    19
    Someone should just write the ugliest code they can imagine, that still fulfill those extremely simple criteria.

  9. #9
    Registered User
    Join Date
    Jan 2010
    Posts
    8
    Ok Ive started to do those on my own...

    I dont understand the second one at all: Write a program to calculate the sum of N numbers.

    Can anybody explain what does that mean?

  10. #10
    Registered User
    Join Date
    Feb 2009
    Posts
    329
    Quote Originally Posted by dnilra View Post
    Ok Ive started to do those on my own...

    I dont understand the second one at all: Write a program to calculate the sum of N numbers.

    Can anybody explain what does that mean?
    'N numbers' means any given number.

    Therefore, in rough pseudo-code, I assume it is asking if the user chose number 10, the SUM of N numbers would be 1+2+3+4+5+6+7+8+9+10. You just need to write a simple loop to do this.
    Last edited by darren78; 01-12-2010 at 05:42 PM.

  11. #11
    Grey Wizard C_Sparky's Avatar
    Join Date
    Sep 2009
    Posts
    50
    Here's the first one. I'll be expecting my domain in two hours.

    Code:
    #include <iostream>
    
    using
                    namespace
        std
    
                    ;
    
    int
    
                main
    (
    
            ){int
    
            x                           =
    0
    
        ,
    
        n
    
                        =
    
    
    
                        51
            ;
    
        for             (
    
        int
    
        i                                               =
    
                      0
                      /*Carefully note this section*/
                      ; i                <
     n               ;                  ++
                i
    
        )                                {
    
            cout                         <<
    
                    i
    
    <<                   endl             ;
    }
    
        return 0;
                            }

  12. #12
    Registered User
    Join Date
    Jan 2010
    Posts
    8
    Quote Originally Posted by darren78 View Post
    'N numbers' means any given number.

    Therefore, in rough pseudo-code, I assume it is asking if the user chose number 10, the SUM of N numbers would be 1+2+3+4+5+6+7+8+9+10. You just need to write a simple loop to do this.
    I think that's it, thanks.
    Quote Originally Posted by C_Sparky View Post
    Here's the first one. I'll be expecting my domain in two hours.

    Code:
    #include <iostream>
    
    using
                    namespace
        std
    
                    ;
    
    int
    
                main
    (
    
            ){int
    
            x                           =
    0
    
        ,
    
        n
    
                        =
    
    
    
                        51
            ;
    
        for             (
    
        int
    
        i                                               =
    
                      0
                      /*Carefully note this section*/
                      ; i                <
     n               ;                  ++
                i
    
        )                                {
    
            cout                         <<
    
                    i
    
    <<                   endl             ;
    }
    
        return 0;
                            }
    Dude, The domain will be for who'll make all not just the first one. I made that in like 10 secs

  13. #13
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    Quote Originally Posted by C_Sparky View Post
    Here's the first one. I'll be expecting my domain in two hours.
    <snip>
    Just FYI, gratuitous space != obfuscation.

  14. #14
    Grey Wizard C_Sparky's Avatar
    Join Date
    Sep 2009
    Posts
    50
    Quote Originally Posted by Sebastiani View Post
    Just FYI, gratuitous space != obfuscation.
    Yeah I just wanted to quickly make something confusing looking so that's what I got

  15. #15
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    'N numbers' means any given number. Therefore, you will need to prompt the user to select a number to use and store in a variable.

    Therefore, in rough pseudo-code, if the user chose number 10, the SUM of 1 to N numbers would be 1+2+3+4+5+6+7+8+9+10. You just need to write a simple loop to do this.
    Alternately, you can use Gauss's equation: ( N * ( N + 1 ) ) / 2.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Creating a 2-D tile system...
    By Raigne in forum C++ Programming
    Replies: 14
    Last Post: 05-24-2007, 04:51 PM
  2. Unexplained "unhandled exception"
    By ulillillia in forum C Programming
    Replies: 6
    Last Post: 04-19-2007, 11:19 AM
  3. Say what? - Weird error.
    By Blackroot in forum C++ Programming
    Replies: 6
    Last Post: 08-15-2006, 11:54 PM
  4. Rectangle List Craziness
    By SMurf in forum C Programming
    Replies: 1
    Last Post: 05-01-2006, 06:24 PM
  5. Practice C Problems, with answers
    By john123 in forum C Programming
    Replies: 3
    Last Post: 12-01-2002, 06:46 PM