How do I repeat this?

How would i repeat this code?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include <iostream>

using namespace std;
int main()

    {
    double celsius;
    double fahrenheit;
    cout<<"The degrees in celsius: ";
    cin>>celsius;
    fahrenheit = celsius*9/5;
    fahrenheit = fahrenheit+32;
    cout<<"\n In fahrenheit it is "<<fahrenheit<<"\n";
    system ("pause");
    return 0;
    }
Last edited on
what do you mean by repeat? If you want it to loop, you would use a while or for loop. For example;
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include <iostream>

using namespace std;
int main()
    {
    double c, f;
    int x = 1;
    while(x != 0) {
    cout<<"The degrees in celsius: ";
    cin>>c;
    f = (9/5)*c+32;
    cout<<"\n In fahrenheit it is "<<f<<"\n";
    cout<<"Enter 0 to quit, 1 to continue:\n";
    cin>>x;
    }
    system ("pause");
    return 0;
    }
Topic archived. No new replies allowed.