Help?

A

Allan

I need help writing a program. I need to convert temps. from fahernheit to
celsius. This is what I have. Can someone help?

// This program is for converting temperatures recorded in Fahrenheit to
Celsius.

#include <iostream>

using std::cout; //program uses cout
using std::cin; //program uses cin

// Beginning main program

int main()

{
int outputcelsius
int userinputfahrenheit

cout <<Enter a Temperature in Fahrenheit\n";
cin >>

outputcelsius = (userinputfahrenheit-32)*(5/9)

return 0;

}
 
K

Kevin Goodsell

Allan said:
I need help writing a program. I need to convert temps. from fahernheit to
celsius. This is what I have. Can someone help?

Please use descriptive subject lines. You are much more likely to get
help that way.

As for your problem, you failed to ask a C++ question, so the only C++
answer I am able to give is, "Design an algorithm. Implement it in C++."
// This program is for converting temperatures recorded in Fahrenheit to
Celsius.

#include <iostream>

using std::cout; //program uses cout
using std::cin; //program uses cin

// Beginning main program

int main()

{
int outputcelsius
int userinputfahrenheit

cout <<Enter a Temperature in Fahrenheit\n";
cin >>

outputcelsius = (userinputfahrenheit-32)*(5/9)

Did you really want to multiply by 0? 5/9 == 0. If you don't know why,
read up on integer math in your C++ book.
return 0;

}

-Kevin
 
G

Gianni Mariani

Allan said:
I need help writing a program. I need to convert temps. from fahernheit to
celsius. This is what I have. Can someone help?

// This program is for converting temperatures recorded in Fahrenheit to
Celsius.

#include <iostream>

using std::cout; //program uses cout
using std::cin; //program uses cin

// Beginning main program

int main()

{
int outputcelsius
int userinputfahrenheit

cout <<Enter a Temperature in Fahrenheit\n";
cin >>

outputcelsius = (userinputfahrenheit-32)*(5/9)

return 0;

}

What were the compiler errors ?

Here are a couple of hints.

5/9 is not well represented by an "int" type. You might want to try a
type that represents fractional quantities.

the line "cin >>" is probably a typo, you probably meant

"cin >> variable".

The outputcelsius is computed but you never show anyone, the program
exits and all the hard work about computing the value is lost. What do
you want to do with the result ?

G
 
J

Jacek Dziedzic

.... plus you're definitely missing some semicolons here and there
and an opening quote on the "cout" line.

- J.
 
K

Kevin Goodsell

Jacek said:
... plus you're definitely missing some semicolons here and there
and an opening quote on the "cout" line.

To whom are you referring? Please quote some context when replying so we
know what you are replying to.

-Kevin
 
J

Jacek Dziedzic

Kevin Goodsell said:
To whom are you referring? Please quote some context when
replying so we know what you are replying to.

All right, all right. My newsserver somehow missed the
OP's post, hence my reply to a reply, but I hoped the OP
would use the "apply logic" principle and realize I was
talking to him. I'm pretty sure you did too.

BTW, I realize that some people have an allergic reaction
to top-posting or overquoting, etc. but I thought that
no-quoting was perfectly OK when I had only a single
sentence to say. Might reconsider that though.

- J.
 
K

Kevin Goodsell

Jacek said:
All right, all right. My newsserver somehow missed the
OP's post, hence my reply to a reply,

There's nothing wrong with that, but if you copy & paste a bit to give
context to your reply, it helps avoid confusion.
but I hoped the OP
would use the "apply logic" principle and realize I was
talking to him. I'm pretty sure you did too.

BTW, I realize that some people have an allergic reaction
to top-posting or overquoting, etc. but I thought that
no-quoting was perfectly OK when I had only a single
sentence to say. Might reconsider that though.

A rule of thumb is to assume that people reading your message 1) might
not have seen other messages in the thread yet, and 2) have news clients
that don't thread messages. Both of these will be true in some cases.

-Kevin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,814
Latest member
SpicetreeDigital

Latest Threads

Top