C++ Help!!!

This is a discussion on C++ Help!!! within the C++ Programming forums, part of the General Programming Boards category; This is an assignment I have an I cannot figure it out for the life of me. Task 1: Write ...

  1. #1
    Registered User
    Join Date
    Oct 2007
    Posts
    1

    Talking C++ Help!!!

    This is an assignment I have an I cannot figure it out for the life of me.

    Task 1: Write the following function to sort three numbers in increasing order

    Void sort(int num1, int num2, int num3)

    The main program should read the three numbers from key board and invoke the above function

    Task 2: Write a function that computes the sum of the digits in an integer (integers with 3 digits only. Ex: 234, 345 etc)
    Hint: Use the % operator to extract digits and the / operator to remove the extracted digit. For instance, to extract 4 from, use 234 % 10 (=4). To remove 4 from 234, use 234/10 (=23).


    Any help would be greatly appreciated.

  2. #2
    The larch
    Join Date
    May 2006
    Posts
    3,573
    Task 1: ...
    Void sort(int num1, int num2, int num3)
    I don't believe this would work. May-be you meant:
    Code:
    void sort(int& num1, int& num2, int& num3);
    Task 2: Write a function that computes the sum of the digits in an integer (integers with 3 digits only. Ex: 234, 345 etc)
    Use the % operator to extract digits and the / operator to remove the extracted digit. For instance, to extract 4 from, use 234 % 10 (=4). To remove 4 from 234, use 234/10 (=23).

    What part of this you don't understand?
    I might be wrong.

    Thank you, anon. You sure know how to recognize different types of trees from quite a long way away.
    Quoted more than 1000 times (I hope).

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