Answer to Question #217470 in C++ for Rosie

Question #217470
C++: Write a program that sets a secret password (programmer's discretion). Ask the user to guess the password. If the guess is correct then print "You got it " Otherwise, print "Nope".
1
Expert's answer
2021-07-15T05:19:11-0400
#include<iostream>
using namespace std;
int main(){
	string password = "coder";
	string password_guess; 
	cout<<"Enter the password\n";
	cin>>password_guess;
	
	if(password == password_guess ){
		cout<<"You got it "<<endl;
	}
	else{
		cout<<"Nope\n";
	}
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS