+ 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

5th Apr 2018, 4:18 PM
Kamaluddin Ahmed
Kamaluddin Ahmed - avatar
7 Respostas
+ 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
5th Apr 2018, 4:25 PM
Ipang
+ 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,
5th Apr 2018, 5:24 PM
Ipang
+ 3
Ipang is correct. Next time, please add relevant tags to the question.
5th Apr 2018, 4:29 PM
Daniel Nedergaard
Daniel Nedergaard - avatar
+ 3
What are relevant tags?
5th Apr 2018, 5:17 PM
Kamaluddin Ahmed
Kamaluddin Ahmed - avatar
+ 3
A relevant tag in this case could be C++. That way, when people search for C++ they can see the C++ questions.
5th Apr 2018, 5:20 PM
Daniel Nedergaard
Daniel Nedergaard - avatar
+ 3
thanks
5th Apr 2018, 5:22 PM
Kamaluddin Ahmed
Kamaluddin Ahmed - avatar
+ 3
Thanks guys my code is now successfully working😀
5th Apr 2018, 5:29 PM
Kamaluddin Ahmed
Kamaluddin Ahmed - avatar