MAGIC NUMBER

  • Thread starter Thread starter WELCOME ###
  • Start date Start date
W

WELCOME ###

Hello every one.
The following is code built by C++ \ CLI . It's built well :
--------------------------------------------------
#include "stdafx.h"

#include <cstdlib>

using namespace System;

int main(array<System::String ^> ^args)

{

int magic;

int guess;

Console::Write(L"Enter Your Guess Number : ");

guess=Console::Read();

Random^ r = gcnew Random();

r->Next();

magic=7;

if(guess=7)

{

Console::WriteLine(L"BRAVO");

}

else

{

Console::WriteLine(L" SORRY..");

}

return 0;

--------------------------------------

When you compile this code,it compiles well except if & else.If one operates
the other not!!!

Please, can any person Help??!!

Thanks

===================================
 
WELCOME ### said:
Hello every one.
The following is code built by C++ \ CLI . It's built well :
--------------------------------------------------
#include "stdafx.h"

#include <cstdlib>

using namespace System;

int main(array<System::String ^> ^args)

{

int magic;

int guess;

Console::Write(L"Enter Your Guess Number : ");

guess=Console::Read();

Random^ r = gcnew Random();

r->Next();

magic=7;

if(guess=7)

{

Console::WriteLine(L"BRAVO");

}

else

{

Console::WriteLine(L" SORRY..");

}

return 0;

--------------------------------------

When you compile this code,it compiles well except if & else.If one
operates the other not!!!

Please, can any person Help??!!

Thanks

===================================
The C++ assignment operator is =.
The C++ equality operator is ==.
Check your Boolean expression. You're using the wrong operator.
 
Back
Top