Something wrong in my code , help me !
Hello , I just started to learn c++ yesterday , and something is wrong in my code and I can't figure out what !!!
When I enter 0 , it keep saying : Cool you are alive !
But I want it to say : rip when hp ==0
Code:
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
int main()
{
bool isAlive(true);
int hp(100);
cin >> hp;
if (hp ==0)
{
isAlive == false;
}
else
{
isAlive == true;
}
if (isAlive)
{
cout << "cool you are alive" << endl;
}
else
{
cout << "rip" << endl;
}
return 0;
}
When I enter 0 , it keep saying : Cool you are alive !
But I want it to say : rip when hp ==0
