#include <iostream>
#include <math.h>
#include <string>
using namespace std;
string myname;
int main() {
string mood;
cout << "Hello How are you, can you please provide your name?: " << endl ;
cin >> myname;
cout << " Hello " << myname << " How are you?" << endl;
cin >> mood;
if (mood = "Good")
{
cout << " Good i am happy you feel well";
}else {
cout << " Why do you feel bad? ";
}
return 0;
}
Why is this program not working? I am trying to get the program to say hi and then get the name and then ask how are you with that said name [ got that down] and if the user enters good then the program executes " good i am happy you feel well" and any thing else " why do you feel bad"
please help
WHy is this not working?A simple asking program
Page 1 of 1
1 Replies - 266 Views - Last Post: 07 April 2010 - 03:33 PM
#1 Guest_tevin*
WHy is this not working?
Posted 07 April 2010 - 03:28 PM
Replies To: WHy is this not working?
#2
Re: WHy is this not working?
Posted 07 April 2010 - 03:33 PM
a single = is an assignment operator, you want the == comparison operator. Change your if to this
if (mood =="Good")
Page 1 of 1
|
|

New Topic/Question
Reply
MultiQuote






|