Hey everyone, i'm creating a program that requires the gas gadge to be updated everytime the speed changes. At the moment i'm manually entering the numbers, but later I will have the numbers being entered via txt file. Anyway, i'm having troubles getting the gas gadge to work, here is the code so far:

Code:
```/*Variables*/
//  FILE *numList;      //list of integers, manually enter numbers for now
int i;                        //for loop variable;
int temp;                //temp number
float num;               //speed in %

//  numList = fopen("c:\\numList.txt","r");

/*do loop*/
// do{

/*Prompt to enter number*/
scanf("%d", &temp);

num = temp /64 * 100;
printf("%.2f\n\n", num);

num = 50;
printf("\t|");
for(i=0;i>=num;i++)
{
printf("-");
}
printf("|");

// }while(num != -1);    /*exit do on '-1'*/

getch();```
The main problem is that the inputed number isn't being converted into a percentage, and I have no idea why. I know this might seem like a n00b question, but I can't see the problem.

I want the gadge to loop something like the:
|------------------------ |

or something like that, the dashes will represent the speed. Also, If anyone has any other suggestions about how the gadge show look, I'm all ears.

Thanks;
S0n1C!

2. http://dictionary.reference.com/browse/gauge

Originally Posted by S0n1C
The main problem is that the inputed number isn't being converted into a percentage
If you want to do floating point math, don't do integer math.
Code:
`num = temp /64 * 100;`

3. Yes, to get floating point number, put the temp variable into float data type.

And then, I think you should change the second expression within the for loop. I think it should be i <= 100, not i >= 100. Isn't it?

Then, one thing... why do you put 'num = 50;' over there?? I don't get it...

Anyway, keep trying!

4. Hey, i have 'num = 50' just for testing, because i couldn't get the percentage part to work. I just wanted to see if the gadge would work in the first place, ingnore that line of code, sorry forgot to document it out.

S0n1C!

5. This is going a little further than I should, but there's really not that much here besides what I've highlighted.
Code:
```#include <stdio.h>
#include <time.h>

/**
* Display a progress bar.
* @param  value   the current value
* @param  maxval  the maximum value
*/
void gauge(int value, int maxval)
{
static const int scale = 50; /* adjust per your preference */
double progress = (double)value / maxval;
int i, current = progress * scale;
/*
* Print bar |-----+-------|
*/
putchar('|');
for ( i = 1; i < current; ++i )
{
putchar('-');
}
putchar('+');
for ( ; i < scale - 1; ++i )
{
putchar('-');
}
putchar('|');
/*
* Print percentage.
*/
printf(" %g%%", progress * 100.0);
}

int main()
{
int i, top = 25;
for ( i = 0; i < top; ++i )
{
time_t now = time(NULL);
putchar('\r'); /* may work, may not */
gauge(i, top);
while ( time(NULL) == now ); /* ugly delay */
}
return 0;
}```
And 0% and 100% don't work the way you might expect. (I gotta leave something.)

6. Works great, thanks. I like the gauge, i'm now in the process of changing it. Making it look a little more graphical.

Thanks Again;
S0n1C!