Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.
Login
Login
OnlineGDB Q&A
Questions
Unanswered
Tags
Ask a Question
Ask a Question
How To Make A Password?
+1
vote
asked
Nov 12, 2018
by
Marshall
(
390
points)
1
flag
Hey guys just wondering if anyone knew how to code a password in c++
#howto
Your answer
Your name to display (optional):
Email me at this address if my answer is selected or commented on:
Email me if my answer is selected or commented on
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please
log in
or register.
2 Answers
+1
vote
answered
Nov 12, 2018
by
Ryan White
(
160
points)
Here's my best solution:
#include <iostream>
#include <string>
using namespace std
int main() {
string password;
cout<<"Enter the password:\n";
cin>>password;
if (password == "whatever the correct one is here") {
cout<<"Correct!\n";
//then put whatever code you want to run here
} else {
cout<<"Incorrect!\n";
exit(0);
//if the password was incorrect, the program ends.
}
Your comment on this answer:
Your name to display (optional):
Email me at this address if a comment is added after mine:
Email me if a comment is added after mine
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please
log in
or register.
0
votes
answered
Nov 12, 2018
by
anonymous
here is my answer in c language
#include<stdio.h>
#include<string.h>
int main(){
char a[6];
scanf("\n%s",a);
if(strcmp(a,"Satyam")==0)
{
printf("Device Unlocked");
}
else{
printf("Incorrect password");
}
}
Your comment on this answer:
Your name to display (optional):
Email me at this address if a comment is added after mine:
Email me if a comment is added after mine
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please
log in
or register.
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...