To find corresponding value??

This is a discussion on To find corresponding value?? within the C Programming forums, part of the General Programming Boards category; Hey guys Was doing a question when I came across this problem. I was required to find the CORRESOPONDING value ...

  1. #1
    Registered User
    Join Date
    Mar 2003
    Posts
    8

    To find corresponding value??

    Hey guys

    Was doing a question when I came across this problem.
    I was required to find the CORRESOPONDING value if the charge is, for example, the lowest.

    This is how the printf is suppose to be like.

    Lowest charge= $xxx.xx and the corresponding length = xxx.

    -----------------

    Let say my lowest charge is $50. How to I refer it from my data file to output the corresponding length (which in this case, as from my data file, the value is 20).

    Your help is appreciated!

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    You don't provide enough information. That being said, I'll assume you have/want something like:
    Code:
    /* This is your data. */
    1  2
    3  4
    5  6
    7  8
    Say you're trying to find the corresponding value of 4.

    Read and find that 1 is less than 4.
    Read and find that 3 is less than 4.
    Read and find that 5 is greater than 4, so we use it. Thus, the corresponding value here is 6.

    Or, it could be (depending on what you're supposed to do) that you take the highest value that is less than or equal to 4. In which case, you'd pull data from 3, so the corresponding value would be 4.

    Without more information, I'll assume that's what you're supposed to do.

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

  3. #3
    Registered User
    Join Date
    Mar 2003
    Posts
    8
    Or, it could be (depending on what you're supposed to do) that you take the highest value that is less than or equal to 4. In which case, you'd pull data from 3, so the corresponding value would be 4.
    Opps sorry.. didnt clarify properly!

    But what I meant is the above quoted. How do I pull the date from 3 so that the corresponding value would be 4.

    How to I write the scrpit for this?

  4. #4
    Registered User
    Join Date
    Mar 2003
    Posts
    8
    umm can anyone help??

  5. #5
    Registered User
    Join Date
    Jan 2003
    Posts
    115
    can u rephrase your problem??

    do you mean scanning in the numbers?

    1 3
    2 4
    4 5

    while ( scanf( "%d %d", &num1, &num2 ) == 2 ) ??
    there are only 10 people in the world, those who know binary and those who dont

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problem building Quake source
    By Silvercord in forum Game Programming
    Replies: 16
    Last Post: 07-11-2010, 10:13 AM
  2. could not find -lwsock32.lib
    By thomas_joyee in forum C++ Programming
    Replies: 8
    Last Post: 07-14-2008, 01:28 PM
  3. How to find O of threads ?
    By jabka in forum C Programming
    Replies: 3
    Last Post: 03-11-2008, 01:25 PM
  4. how do u find 2nd largest number??
    By juancardenas in forum C Programming
    Replies: 8
    Last Post: 02-14-2003, 08:28 AM
  5. Q: Recursion to find all paths of a maze
    By reti in forum C Programming
    Replies: 7
    Last Post: 11-26-2002, 09:28 AM

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