# Thread: To find corresponding value??

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

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

Quzah.

3. 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. umm can anyone help??

5. 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 ) ??