Hello everybody,

I'm new here and also pretty new to the C-language.

Here is the Problem:

I have several floats and I need to print them out, but they should be in one line at the end. But C always prints them with the first number on the same level, so if the numbers are not the same length it doesn't look good. What I need to do is to make the end "levelled".

how can i do that?

thanks a lot

liricas

2. hmm i'm sorry but i still can't figure it out (even with the help of wikipedia)

3. Use the field width specifier:

printf("%FieldWidthSpecifierNumberf", somefloat);

4. Perhaps you should use something like this

Code:
`printf("%.5f", num);`
This would limt the decimal points up to 5 placs.

-ssharish

5. Code:
```The total number of books ordered: 6
The average movie price: \$ 595.50
The minimum movie price: \$ 45.99
The maximum movie price: \$ 2345.77```
This is the output I get.

But the output should look like this

Code:
```The total number of books ordered: 3
The average movie price: \$ 13.45
The minium movie price:  \$  6.55
The maximum movie price: \$ 15.95```
the end should be nicely leveled....

how can i achieve that?

6. So what is your code to print that?

--
Mats

7. Code:
```   printf("The total number of movies ordered: %.0f\n",numbooks);
printf("The average movie price:\t\$ %.2f\n",average);
printf("The minimum movie price:\t\$ %.2f\n",lowest);
printf("The maximum movie price:\t\$ %.2f\n\n",highest);```
this is the code

thx for any help

8. May be this

Code:
``` printf("The average movie price:\t\$ %5.2f\n",average);
printf("The minimum movie price:\t\$ %5.2f\n",lowest);
printf("The maximum movie price:\t\$ %5.2f\n\n",highest);```
-ssharish

9. Originally Posted by ssharish2005
May be this

Code:
``` printf("The average movie price:\t\$ %5.2f\n",average);
printf("The minimum movie price:\t\$ %5.2f\n",lowest);
printf("The maximum movie price:\t\$ %5.2f\n\n",highest);```
-ssharish
worked out perfectly!

thank you soo much

liricas