# Help Needed C Programming

#### Ralf

Joined Mar 16, 2009
31
i have a problem with this:

let say i type in 7 and it will display a 25
and the max i can type in is 10 and the display number max will be 29

how to i program with this condition using C language?

sorry if u all don't understand what i trying to ask.. please let me know that the information is not clear, so that i can ask my friend to help me rephrase.

#### thatoneguy

Joined Feb 19, 2009
6,349
What is the formula to convert 7-> 25 and 10->29

When you say the Max would display as 29, are there other numbers it could display when 10 is entered?

Are the numbers base 10, hexadecimal, octal, or "other"?

What are you using for a keypad for numeric entry?

Which microcontroller/compiler? (this doesn't matter too much, but they aren't all perfectly compatible)

#### Shmurk

Joined Aug 13, 2007
24
I know nothing about it but here's a beginning of a solution:

7 is 25, 10 is 29, which "could" mean that we increase the value with 4/3 at each step, like this:
• 7 -> 75/3
• 8 -> 79/3
• 9 -> 83/3
• 10 -> 87/3
and if we go "down" instead, the first value is: 0 -> 47/3.

So a formula "could" be: f(x) = 47/3 + (x * 4/3), which is in C:
Rich (BB code):
float f(float x) {
return 47.0/3.0 + (x * 4.0/3.0);
}
Edit: If the "max" is 10, then the code would be:
Rich (BB code):
float f(float x) {
if (x >= 10) return 29;
return 47.0/3.0 + (x * 4.0/3.0);
}
or something...

Last edited: