15,997,776 members
See more:
This is my code

```#include <stdio.h>
float fahrenheit;
void temperature_convertor(float Fahrenheit)
{
float C = Fahrenheit - 32;
float Ce = C * 5;
float Celsius =  Ce/9;
float Kelvin =  Celsius + 273.15f;
printf("Fahrenheit     Celsius     Kelvin \n---------------------------------------------\n%0.0f          %0.2f           %0.2f\n", Fahrenheit, Celsius, Kelvin);
}```

```#include <stdio.h>  // printf

void temperature_convertor(float Fahrenheit);

int main(void)
{
// test case 1
temperature_convertor(0);
printf("\n");

// test case 2
temperature_convertor(20);
printf("\n");

// test case 3
temperature_convertor(300);
printf("\n");

// test case 4
temperature_convertor(-20);
printf("\n");

// test case 5
temperature_convertor(137);
printf("\n");

// test case 6
temperature_convertor(-300);
printf("\n");

return 0;
}```

I'm trying to get the numbers and letters to align in the output, ie I want all celsius values to form a neat line before the word "celsius", the problem is that all the numerical results are slightly different and I end up with a janky line. Any help?

What I have tried:

I tried leaving more spacing, but other than that I'm kinda lost.
Posted
Updated 27-Sep-21 4:47am

## Solution 1

You didn't specify enough room for the numbers (see, for instance: printf - C++ Reference[^]).

Replace
Quote:
printf("Fahrenheit Celsius Kelvin \n---------------------------------------------\n%0.0f %0.2f %0.2f\n", Fahrenheit, Celsius, Kelvin);
with
```printf("Fahrenheit     Celsius     Kelvin \n---------------------------------------------\n      %4.0f     %7.2f    %7.2f\n", Fahrenheit, Celsius, Kelvin);
```

## Solution 2

Quote:
I tried leaving more spacing, but other than that I'm kinda lost.

printf - C++ Reference[^]