Have my final tommarow, while reviewing I need a refresher on two things !

This is a discussion on Have my final tommarow, while reviewing I need a refresher on two things ! within the C++ Programming forums, part of the General Programming Boards category; First things first I would like to thank everyone that has helped me throughout this semester, I got a A ...

  1. #1
    Registered User
    Join Date
    Feb 2002
    Posts
    52

    Exclamation Have my final tommarow, while reviewing I need a refresher on two things !

    First things first I would like to thank everyone that has helped me throughout this semester, I got a A going into the final (I hope I got one going out :-) That out of the way here is the meat and potatos !

    -How do I find the minimum and maximuim of any amount of numbers... a slice of code would help me dearly.

    -How do I input information into an array, I think its
    /code
    array [3],[3] = x
    x=10
    code/

    Whops and maybe there is another :-)
    -I doubt if anyone will do this for my but here goes nothing... A Do While, For, While function that does prints every other number up to 10.




    Thanks for the help guys !!!

  2. #2
    Registered User
    Join Date
    Dec 2002
    Posts
    119
    It's really not that hard to find min/max. I'll give you some hints.

    Finding min integer:
    Say you have an int array, start looping through the array and assume the first munber is the minimum and save it into a variable. Then test that variable against each of the other elements of the array and if the current element is smaller than what's in your variable, then store that number in the variable. When you've finished looping through the array, you'll have the smallest number in the variable. Do the same for finding the largest.
    Not to hard eh?

    -Futura
    If you speak or are learning Spanish, check out this Spanish and English Dictionary, it is a handy online resource.
    What happens is not as important as how you react to what happens. -Thaddeus Golas

  3. #3
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    I'm not sure what you are asking on that first question. But here is a sample of the second.

    Example
    Code:
    int array[3][3] = {0}; //init array to zero
    array[0][0] = 2;  //first index set to 2
    array[2][2] = 2;  //last index set to 2
    Good luck.

  4. #4
    Registered User
    Join Date
    Feb 2002
    Posts
    93
    Code:
    for(int x = 0; x <= 10; x = x + 2)
    {
      cout << x << " ";
    }
    Code:
    int x = 0;
    while (x <= 10)
    {
      cout << x << " ";
      x = x + 2;
    }
    Code:
    int x = 0;
    do
    {
      cout << x << " ";
      x = x + 2;
    }while(x <= 10)

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. reviewing for final exam, need help with this question
    By jlmac2001 in forum C++ Programming
    Replies: 12
    Last Post: 11-26-2003, 08:37 AM

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