+ 1
My code isnt working properly ,pls tell me what i am doing wrong.
I want a function to print "Wrong code" if I input wrong password and print "correct code" if I enter correct password but it doesn't work properly please tell me what I am doing wrong pls pls pls Here is my code (What is wrong in it?) https://code.sololearn.com/cKLAsVRR3k5O/?ref=app
7 odpowiedzi
+ 4
Here you go, notice that since you only have two choice (right/wrong password) it was unnecessary to use else if, use if paired with else would be sufficient, keep coding : )
int main()
{
int x;
cin >> x;
if (x == 1234)
{
cout<<"Access granted";
}
else
{
cout<<"Access denied";
}
return 0; // forgot semicolon here
}
(Edit)
Please edit and put relevant tags in question (for future reference)
Hth, cmiiw
+ 4
@Kamaluddin Ahmed, it's the text under the question title ("guys" "pls"), as @Daniel Nedergaard suggested, use words that can describe which language a question was referring to, it helps those who wants to answer to understand the question is relevant to a certain language : )
Thanks,
+ 3
Ipang is correct. Next time, please add relevant tags to the question.
+ 3
What are relevant tags?
+ 3
A relevant tag in this case could be C++. That way, when people search for C++ they can see the C++ questions.
+ 3
thanks
+ 3
Thanks guys my code is now successfully working😀