# Help Needed C Programming

Discussion in 'Programmer's Corner' started by Ralf, Mar 17, 2009.

1. ### Ralf Thread Starter Active Member

Mar 16, 2009
31
0
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.

2. ### thatoneguy AAC Fanatic!

Feb 19, 2009
6,357
718
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)

3. ### Shmurk Member

Aug 13, 2007
24
0
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:
Code ( (Unknown Language)):
1. float f(float x) {
2.     return 47.0/3.0 + (x * 4.0/3.0);
3. }
Edit: If the "max" is 10, then the code would be:
Code ( (Unknown Language)):
1. float f(float x) {
2.     if (x >= 10) return 29;
3.     return 47.0/3.0 + (x * 4.0/3.0);
4. }
or something...

Last edited: Mar 18, 2009
4. ### Ralf Thread Starter Active Member

Mar 16, 2009
31
0
to thatoneguy

1st qns: no.. the max is 10. and it must display a 29 on my 2 LED
2nd qns: is a decimal number
3rd qns: is a thermistor that sense temperature and i will convert this using ADC to display in 7 segment.
4th qns: Microchip PIC18f24k20 , is a C compiler( when i install C compiler it include mcc18 file inside.)