Reputation: 93
#include "stdafx.h"
#include <iostream>
using namespace std;
int main() {
int temp;
string phase;
cout << "the temperature is: ";
cin >> temp;
if (temp > 0 && temp < 100) {
phase = "liquid";
}
else if (temp < 0)
phase = "ice";
else
phase = "gas";
cout << "the phase is :" << phase << endl;
return 0;
}
I write C++ and I have can't display the variable phase . This also stops the compiler and I can't compile it.
Upvotes: 0
Views: 35
Reputation: 93
#include "stdafx.h"
#include <iostream>
#include <string>
using namespace std;
int main() {
int temp;
string phase;
cout << "the temperature is: ";
cin >> temp;
if (temp > 0 && temp < 100) {
phase = "liquid";
}
else if (temp < 0)
phase = "ice";
else
phase = "gas";
cout << "the phase is :" << phase << endl;
return 0;
}
Upvotes: 1