Asep Kurnia X Asep Kurnia X - 3 months ago 18
C++ Question

if cin true or false from variable C++

please help me solve this..

int A=10;

cout<<"Answer this Question!";
cout<<"5 + 5 = ";cin>>A;
if(true) {
} else if (false) {



the answer is A=10, if user input right answer from the
int A=10
then notif use cout "Correct!" and if wrong is "Wrong!" .


In your above code,

if (true)

always evaluates to true, so it will always print "Correct!". However, I am guessing you are asking how do we check the user's input to see if they are correct? In that case, for your if statement, you want

if (A == 10)

and rather than an else if, just have an else statement since any answer other than 10 would be incorrect.

I suggest you look up basics of programming.