Loop for converting F and C

I need to write a code to convert Fahrenheit and Celsius and it has to go up to 20 this is what I have so far and don't answer if you're one of those snobby programmers

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
 #include<iostream>  

 #include<iomanip>  

 using namespace std;  

    

 double tocelcious(const double & fahrenheit);  

   

 int main() {  

     cout<<setprecision(2);  

    double f;  

    cout<<"Enter a fahrenheit degree: ";  

 cin>>f; 
 


    

 for (int i = 0; i <= 20; ++i)

	
         cout<< tocelcious(i) <<endl;  

    cout<<"Equivalent Celcious Value: "<<tocelcious(f)<<endl; 

	



    return 0;  

 }  

   





 double tocelcious(const double& fahrenheit) {  

     return (fahrenheit-32)*0.56; 


 } 
Last edited on
Please edit your post and make sure your code is [code]between code tags [/code] so that it has syntax highlighting and line numbers, as well as proper indentation.
http://www.cplusplus.com/articles/jEywvCM9/

You didnt ask a question. What specific part do you need help with?
Please, post with code tags http://www.cplusplus.com/articles/jEywvCM9/

You didn't ask any question.
and don't answer if you're one of those snobby programmers

I'm curious. What was the reasoning that led you to believe that it would be a good idea to introduce yourself to this forum by being belligerent towards the people from whom you're seeking help?
You mean the effect of line 15. "Two digits", you say. Two digits you see. That is the default.

There are other options too. See http://www.cplusplus.com/reference/ios/fixed/

However, would it make sense to print on one line both F and the corresponding C? That way your loop would create a (two-column) table.
Topic archived. No new replies allowed.