# Convert Fahrenheit to Celsius - Celsius with + or -

Page 1 of 1

## 1 Replies - 8198 Views - Last Post: 09 November 2009 - 09:25 PMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'http://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=137951&amp;s=0b42040a4dd4d3245ad13057ccea4021&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 abujamaal

• New D.I.C Head

Reputation: 2
• Posts: 10
• Joined: 17-September 09

# Convert Fahrenheit to Celsius - Celsius with + or -

Posted 09 November 2009 - 08:56 PM

I need help placing a + or - sign before the celsius number.

```/* Write a program that converts integer Farenheit temperatures from 0
to 212 degrees to floating-point Celsius temperatures with 3 digits
of precision. Use the formula celsius = 5.0 / 9.0*(fahrenheit - 32)
to preform the calculation. The output should be printed in two right-
justified columns of 10 characters each, and the Celsius temperatures
should be preceded by a sign of both positive and negative values. */

#include <stdio.h>
#include <stdlib.h>

int main()
{
double celsius;
int fahrenheit;

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

if (celsius <= 0 && celsius <= 100)
{
printf("%+10.3f", celsius);
}

system("pause");
return 0;
}

```

Thank you in advance

Is This A Good Question/Topic? 1

## Replies To: Convert Fahrenheit to Celsius - Celsius with + or -

### #2 abujamaal

• New D.I.C Head

Reputation: 2
• Posts: 10
• Joined: 17-September 09

## Re: Convert Fahrenheit to Celsius - Celsius with + or -

Posted 09 November 2009 - 09:25 PM

I have figured it out. Thanks to those who wanted to help. This is becoming easier as thing are repetative.

```/* Exercise 9.13: 9.13.c */
/* Write a program that converts integer Farenheit temperatures from 0
to 212 degrees to floating-point Celsius temperatures with 3 digits
of precision. Use the formula celsius = 5.0 / 9.0*(fahrenheit - 32)
to preform the calculation. The output should be printed in two right-
justified columns of 10 characters each, and the Celsius temperatures
should be preceded by a sign of both positive and negative values. */

#include <stdio.h>
#include <stdlib.h>

int main()
{
float celsius;
int fahrenheit;

for (fahrenheit = 0; fahrenheit <= 212; fahrenheit = fahrenheit++)
{
celsius = 5.0/9.0 *(fahrenheit - 32);
printf("%10d%", fahrenheit);

{
if (celsius >= 0 && celsius <= 100)
{
printf("%+10.3f\n", celsius);
}
else if (celsius < 0)
{
printf("%10.3f\n", celsius);
}
}
}

system("pause");
return 0;
}

```

This post has been edited by abujamaal: 09 November 2009 - 09:26 PM

Was This Post Helpful? 1

Page 1 of 1

 .related ul{list-style-type:circle;font-size:12px;font-weight:bold;}.related li{margin-bottom:5px;background-position:left 7px!important;margin-left:-35px;}.related h2{font-size:18px;font-weight:bold;}.related a{color:blue;}