Need some answers to these super short problems

This is a discussion on Need some answers to these super short problems within the C++ Programming forums, part of the General Programming Boards category; Hey folks, Got an exam tomorrow and need these done in C++ in a short time. They're very easy exercises ...

  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,648
    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
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,434
    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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  4. #4
    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 02:23 PM.

  5. #5
    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

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

  7. #7
    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.

  8. #8
    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?

  9. #9
    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 04:42 PM.

  10. #10
    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;
                            }

  11. #11
    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

  12. #12
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,648
    '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.

  13. #13
    Registered User
    Join Date
    Feb 2009
    Posts
    329
    Quote Originally Posted by Sebastiani View Post
    Alternately, you can use Gauss's equation: ( N * ( N + 1 ) ) / 2.
    Looking at his assignment he is required to use loops, but yes Gauss's equation would be simpler!

  14. #14
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,648
    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.

  15. #15
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,648
    Quote Originally Posted by darren78 View Post
    Looking at his assignment he is required to use loops, but yes Gauss's equation would be simpler!
    Ah, right - the looping requirement. Overlooked that.

Page 1 of 2 12 LastLast
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, 05:46 PM

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