#include <iostream>
using namespace std;
int main ()
{
int R,G,Y;
int r,g,y;
int a;
cout<<"enter your input"<<endl;
cin>>a;
if (a==R||r)
{
cout<<"please stop"<<endl;
}
else
if (a==G||g)
{
cout<<"you can go"<<endl;
}
else if (a==Y||y)
{
cout<<"prepare to stop"<<endl;
}
else
cout<<"Out of range"<<endl;
return 0;
}
renovat0 0 Newbie Poster
Recommended Answers
Jump to Postyour boolean logic is ill-formed inside of your if statements, instead of
if(a==R||r) //etc.
it should be
if((a == R) || (a == r)) //etc.
how your first logic reads is "if a equals R or if r".
how I think you wanted your …
Jump to Postif ( ReadBeforePosting() == true && PostHasCodeTags() == true ) { // reward OP with answers } else { MoreCluesOnHowToDoBetterNextTime(); }
All 5 Replies
wildgoose 420 Practically a Posting Shark
jesseb07 64 Junior Poster
Salem 5,265 Posting Sage
JameB 66 Junior Poster
renovat0 0 Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.