#include <iostream>
#include <string>
using namespace std;
int main(int argc, char *argv[])
{
int x = 0;
int c = x + 5;
string name;
int answer1;
cout << "what would you like your name to be?" << endl;
cout << ">"; cin >> name;
cout << "hello nice to meet you " << name << endl;
cin.get();
cout << "what is your favorite number " << name << endl;
cout << ">"; cin >> x;
cout << "Your favorite number is " << x << endl;
cin.get();
cout << "what is your favorite number +5?" << endl;
cout << ">"; cin >> c;
if( c != x+5 )
cout << "Wrong@@@@" << endl;
else if( c = x+5 )
cout << "Correct!!" << endl;
cin.get();
}
Try that.
Falco Girgis wrote:It is imperative that I can broadcast my narcissistic commit strings to the Twitter! Tweet Tweet, bitches!
#include <iostream>
#include <string>
using namespace std;
int main(int argc, char *argv[])
{
int x = 0;
int c = x + 5;
string name;
int answer1;
cout << "what would you like your name to be?" << endl;
cout << ">"; cin >> name;
cout << "hello nice to meet you " << name << endl;
cin.get();
cout << "what is your favorite number " << name << endl;
cout << ">"; cin >> x;
cout << "Your favorite number is " << x << endl;
cin.get();
cout << "what is your favorite number +5?" << endl;
cout << ">"; cin >> c;
if( c != x+5 )
cout << "Wrong@@@@" << endl;
else if( c == x+5 )
cout << "Correct!!" << endl;
cin.get();
}
this is seems correct but its not working i want it to puase after it says if your correct or not but it doesnt
The reason that piece of code is a bug is the '=' operator is actually the assignment operator. The '==' operator is used to test for equality. It's a very common error that the compiler doesn't catch, unless you have the warning level set to the highest.
if I have a bug like that won't it cause a memory leak or something?
No, memory leaks only occur when you dynamically allocate memory. You wont encounter them for a fair while until you are past understanding the basics.