I have to write a program that converts Fahrenheit from 0 to 212 to floating-point Celsius with 3 digit of precision. The output should be printed in two right-justified columns of 10 characters each and the Celsius should be preceded by sign for both positive and negative values. please help me thanks. this is what i have:

#include <stdio.h>

int main(void)
{
	int fahrenheit;
	double celsius;

	for (fahrenheit = 0; fahrenheit <= 212; fahrenheit++)
	{
		celsius = 5.0 / 9.0 * ( fahrenheit - 32 );
		printf("\t%+.3f\n", celsius);
	}

	return 0;
}

Okay your code has a lot of errors.

Lets start here, you need to always include iostream.
Second don't use void main.
Third it does not work well to use printf.

Here is your code recompiled, is this what you want?

#include <iostream>
using namespace std;

int main() {
    
    int fahrenheit;
    double celsius;
    
    for (fahrenheit = 0; fahrenheit <= 212; fahrenheit++) {
    
    celsius = 5.0 / 9.0 * ( fahrenheit - 32 );
    cout << "\t%+.3f\n" << celsius;
}
 cout <<"\n\n";
 system("PAUSE");
 return 0; 
}

Try compiling it and running it, it worked in my compiler.

Any problems feel free to ask, I am not a pro but I have a few years
into c++ programming.

One more thing:
If you are going to do a lot of big decimal numbers include
math.h

Like this: #include <math.h>

i did it but it didn't come out in two columns of 10 characters, how do you do that? thanks for helping

thank you everyone for your help and time, i compiled it and it work thnx :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.