-
Notifications
You must be signed in to change notification settings - Fork 37
/
Copy pathFahrenheittoCelsius.cpp
62 lines (53 loc) · 1.22 KB
/
FahrenheittoCelsius.cpp
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
54
55
56
57
58
59
60
61
62
Fahrenheit to Celsius Table
Send Feedback
Given three values - Start Fahrenheit Value (S), End Fahrenheit value (E) and Step Size (W), you need to convert all Fahrenheit values from Start to End at the gap of W, into their corresponding Celsius values and print the table.
Input Format :
3 integers - S, E and W respectively
Output Format :
Fahrenheit to Celsius conversion table. One line for every Fahrenheit and corresponding Celsius value. On Fahrenheit value and its corresponding Celsius value should be separate by tab ("\t")
Constraints :
0 <= S <= 80
S <= E <= 900
0 <= W <= 40
Sample Input 1:
0
100
20
Sample Output 1:
0 -17
20 -6
40 4
60 15
80 26
100 37
Sample Input 2:
20
119
13
Sample Output 2:
20 -6
33 0
46 7
59 15
72 22
85 29
98 36
111 43
/************************************************** SOLUTION *****************************************************************************/
#include<iostream>
using namespace std;
int main(){
/* Read input as specified in the question.
* Print output as specified in the question.
*/
int S,E,W;
cin>>S;
cin>>E;
cin>>W;
int C;
while(S<=E){
C=(S-32)*5/9;
cout<<S<<"\t"<<C<<endl;
S=S+W;
}
}