#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 Postelse if (a==Y||y)
What exactly are you trying to do?
else if (a == 1 ) ???You really need more description of what you're trying to do!
R,G,Y, r,g,y aren't even initialized!
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 …
All 5 Replies
wildgoose
420
Practically a Posting Shark
jesseb07
64
Junior Poster
Salem
5,138
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.