|
|
#1 (permalink) |
|
Banned
Join Date: Jul 2006
Posts: 3,142
Reputation: 101
|
Code:
#include <iostream.h>
int main(void)
{
int DegreeF = 41;
float DegreeC = .55;
DegreeC= (DegreeF-32);
cout << "Fehreinhiet to Celsius = ";
cout << DegreeC;
cout << '\n';
}
Last edited by bonneau_14; 01-08-2008 at 08:00 PM. |
|
|
|
|
#2 (permalink) |
|
Master Chief's Windex
|
On the last line either put a :
cin Code:
#include <iostream.h>
int main(void)
{
int DegreeF = 41;
int somevar;
float DegreeC = .55;
DegreeC= (DegreeF-32);
cout << "Fehreinhiet to Celsius = ";
cout << DegreeC;
cout << '\n';
cin >> somevar;
}
or as long as you include the windows.h file you can use sleep(x) Code:
#include <iostream.h>
#include <windows.h>
int main(void)
{
int DegreeF = 41;
float DegreeC = .55;
DegreeC= (DegreeF-32);
cout << "Fehreinhiet to Celsius = ";
cout << DegreeC;
cout << '\n';
sleep(5);
}
There are other more efficient and standardized ways of doing so but the above two will both work and are relatively straight forward.
__________________
Last edited by SilentSiren; 01-07-2008 at 04:31 AM. |
|
|
|
|
#3 (permalink) |
|
Banned
Join Date: Jul 2006
Posts: 3,142
Reputation: 101
|
Code:
#include <iostream.h>
int main(void)
{
int DegreeF = 41;
int somevar;
float DegreeC = 1.8;
DegreeC= (DegreeF-32);
cout << "Degrees in Fahrenheit = ";
cout << DegreeF;
cout << '\n';
cout << "41 degrees Fahrenheit is equilvelent to ";
cout << DegreeC;
cout << " Celsius";
cout << '\n';
cin >> somevar;
}
41-32 = 9[divided by]1.8 = 5 degrees celsius. my program goes to is "41-32 = 9" then it outputs the answer 9 Last edited by bonneau_14; 01-08-2008 at 11:02 PM. |
|
|
|
|
#4 (permalink) |
|
Master Chief's Windex
|
A Thank You wouldnt go amiss lol.
First of! Children complain "When will we ever use Algebra?!?" well see below : DegreeC= (DegreeF-32); where DegreeF = 41 so if we convert it all into numbers:- 1.8 = (41-32) So its inefficient as your formula isnt complete or making much sense. Typically you only use variable replacements for numbers in your code if it is going to be large if it is small like this you could just forget the vars and use the numbers but for the sake of good programming here is how it should look based on your suggested formula: As a note if you use floating variables then you should store results in a floating type in my opinion memory at this level isnt much of a biggy. Code:
#include <iostream.h>
int main(void)
{
int DegreeF = 41;
int adjust = 32;
int somevar;
float DegreeC = 1.8;
float Result;
Result = (DegreeF-adjust)/DegreeC;
cout << "Degrees in Fahrenheit = ";
cout << Result;
cout << '\n';
cout << 'DegreeF';
cout << " degrees Fahrenheit is equilvelent to ";
cout << Result;
cout << " Celsius";
cout << '\n';
cin >> somevar;
}
__________________
|
|
|
|
|
#5 (permalink) |
|
Banned
Join Date: Jul 2006
Posts: 3,142
Reputation: 101
|
thank you! i meant to put that in my post above but i got distracted before finishing it. I am quite aware that i'll need algebra--i knew that before i started to learn how to script. in two and a half years i'm going to post-secondary school to become a computer programmer; i thought if i knew C++ school would be a bit easier.
this is a exercise at the end of a chapter in a book and it wants me to use this formula: so i put the 1.8 where the 5/9 is and i get a error and it won't compile.but i can see there are some extra steps i need to do in order for it to work. I am sorry for the delayed thank you; you have my gratitude.EDIT: when i edited my code with your edit something didn't work right; i got some random 12 digit number. but i have resolved the problem. and again i thank you, now i can move on in the book. Last edited by bonneau_14; 01-08-2008 at 11:27 PM. |
|
|
|
|
#6 (permalink) |
|
Still learning the ropes
Join Date: Jan 2008
Posts: 27
Reputation: 10
|
Man thats confusing....i wish i knew programmming. Whats the easiest way to learn the basics?
__________________
~Pig
[br] The pig is hungry.Click here to feed the pig! Pig levels up when you feed him.Please feed the pig.[br][url=http://www.pokeplushies. |
|
|
|
|
#7 (permalink) |
|
Crumbly, but Good
|
Easiest way to start is to take a course, to get the basics. I found that really helped. But you can do it online, it's not that much harder, especially if you have someone (I.E. this forum) you can ask when you need help. Check out this thread if you want to get started:
http://www.onrpg.com/boards/1215.html
__________________
|
|
|
|
|
#8 (permalink) |
|
Dixie Banana Bar
Join Date: Dec 2007
Posts: 276
Reputation: 10
|
I'm attending computer science university and i can easily tell yuo all that teachers actually DID NOT TEACH YOU ANYTHING thay just stay there talking about frayed air for 4. .. 5 even 7 hours 'bout programming ethics . Then at the end of the course they ask you to implement a huge system from nothing.
So , actually, in my opinion the milestone from which i've started learning about programming is " C Language" of Kernighan & Ritchie and then if you want to move to any other lenguage just buy a reference manual ..
__________________
" Here we go our step so silent Here we go our blooded trace the Jester Race " http://mjalkar.mybrute.com |
|
|
| Thread Tools | |
| Display Modes | |
|
|