Need HELP with Program

This is a discussion on Need HELP with Program within the C Programming forums, part of the General Programming Boards category; Are you trying to actually display what the minimum number was? If so, shouldn't you put that into a variable ...

  1. #16
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Are you trying to actually display what the minimum number was? If so, shouldn't you put that into a variable some place when it is less than the current minimum? If so, you don't want to start the value of "minimum" low, you want it high, so that, when you start entering numbers, it will find one lower than your default value, and put it there instead.

    Quzah.
    Hope is the first step on the road to disappointment.

  2. #17
    Registered User
    Join Date
    Sep 2004
    Posts
    24
    yes i want the computer to spit out the lowest number that the user entered. So i need to make minimum = a large number when declaring min or do something with this? or neither?
    Code:
       if (input <= maximum)

  3. #18
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Do you actually know how to think things out? If so, do it. Walk though it on paper:
    Code:
    number = small number
    get input
    if input less than small number
        number = input
    Ok, so what happens if input is greater than small number, and they don't input anything more? Have you saved their smallest input? Yes? No?

    Code:
    number = big number
    get input
    if input less than big number
        number = input
    What about now?

    We're not here to do everything for you. If you really don't want to learn, give it up. If you do, then take a moment and actually think about what you're trying to do. It's not a race. Just take your time and figure out what you need to do, and then how to do it.

    Quzah.
    Hope is the first step on the road to disappointment.

  4. #19
    Registered User
    Join Date
    Sep 2004
    Posts
    24
    look quzah..if you dont want to help me then dont reply to my post. I can do without the smart comments about my learning ability. I am new at this and dont know what im doing. I dont want you to do everything for me and you have not even come close to doing that. thanks anyway for your help

  5. #20
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    You don't seem to understand. You need to take the time and think through your program. It's not a hard concept. If you want to be a programmer, even as a hobbyist, you have to take the time to think your project through.

    You aren't doing that. You are simply saying "this didn't work, now this didn't work". Think about why it doesn't work. Think about what exactly is supposed to happen, and why it is or isn't.

    If you don't take the time to learn that process, there is no point in even trying to continue.

    Quzah.
    Hope is the first step on the road to disappointment.

  6. #21
    Gawking at stupidity
    Join Date
    Jul 2004
    Location
    Oregon, USA
    Posts
    3,164
    I think what quzah is trying to point out is that dividing your challenge into logic and specifics portions helps get you to where you're going when you're stuck. For instance, say you're trying to find the end of a string. You know the end of strings always have a special character at the end to mark the end of the string. So you write some logic down.

    Code:
    Iterate through string
      If current character equals EndOfString marker
        Break out of loop
    Then you can turn it into specifics:
    Code:
    for(i = 0;;++i)
      if(string[i] == '\0')
        break;
    The same logic applies to pretty much every programming language and pretty nearly corresponds to how you'd look for the end of a string yourself. So even if you're really new to a programming language you can usually get the logic written down. Then it's just a matter of finding out how the programming language you're using implements that logic.
    If you understand what you're doing, you're not learning anything.

  7. #22
    Registered User
    Join Date
    Sep 2004
    Posts
    24
    can someone tell me why the minimum is still figuring zero in as a number? what do i need to do to fix this?

    Code:
    void findMinimum()
    {
      int minimum = 0;
      int number = 0;
      int count = 0;
      printf("\nEnter Numbers (Enter 0 to Stop): ");
    for(;;)
     {
      scanf("%d",&number);
    if (number != 0)
        {
    if (count == 0)
      minimum = number;  
      count ++;
    if (number < minimum ) 
      {minimum = number; }
        }
    else
        {
      printf("\nYou entered %d numbers with a minimum of: %d",count,number);
    break;
        }
     }
    }

  8. #23
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Quote Originally Posted by Jeff
    can someone tell me why the minimum is still figuring zero in as a number? what do i need to do to fix this?

    Code:
    void findMinimum()
    {
      int minimum = 0;
    I don't have the desire or time to keep going over this. I gave you a perfect illustration of this exact series of events, and obviously you, rather than opting to learn from it, ignored it. This has been answered before. All it requires is that you think about what's going on in your code.

    Quzah.
    Hope is the first step on the road to disappointment.

  9. #24
    Registered User
    Join Date
    Sep 2004
    Posts
    24
    Quote Originally Posted by quzah
    I don't have the desire or time to keep going over this.Quzah.
    Then dont!!

  10. #25
    Gawking at stupidity
    Join Date
    Jul 2004
    Location
    Oregon, USA
    Posts
    3,164
    Code:
    void findMinimum()
    {
      int minimum = 0;
    ...
    if (number < minimum ) 
      {minimum = number; }
    Unless number is negative it will never be less than minimum.

    Like quzah said in an earlier post:
    Quote Originally Posted by quzah
    you don't want to start the value of "minimum" low, you want it high, so that, when you start entering numbers, it will find one lower than your default value, and put it there instead.
    If you understand what you're doing, you're not learning anything.

  11. #26
    Super Moderator
    Join Date
    Sep 2001
    Posts
    4,913
    He won't, but by that comment, quzah is actually trying to help you, because quzah is not alone in thinking this. If you follow the advice quzah gives to a lot of people on this board, then you are more likely to get more help from lots of other people.

Page 2 of 2 FirstFirst 12
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Issue with program that's calling a function and has a loop
    By tigerfansince84 in forum C++ Programming
    Replies: 9
    Last Post: 11-12-2008, 12:38 PM
  2. Need help with a program, theres something in it for you
    By engstudent363 in forum C Programming
    Replies: 1
    Last Post: 02-29-2008, 12:41 PM
  3. Replies: 4
    Last Post: 02-21-2008, 09:39 AM
  4. My program, anyhelp
    By @licomb in forum C Programming
    Replies: 14
    Last Post: 08-14-2001, 10:04 PM

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