0% found this document useful (0 votes)
137 views

Password 3

This C++ program prompts the user to enter a password. It accepts input character by character and displays asterisks to hide the password. It then compares the input password to the string "farhan". If they match, access is granted and "Password Accepted" is displayed. Otherwise, "Invalid Password" is shown. The program ends by waiting for a key press.
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
137 views

Password 3

This C++ program prompts the user to enter a password. It accepts input character by character and displays asterisks to hide the password. It then compares the input password to the string "farhan". If they match, access is granted and "Password Accepted" is displayed. Otherwise, "Invalid Password" is shown. The program ends by waiting for a key press.
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Password 3

============================================

#include <conio.h>
#include <stdlib.h>
#include <string.h>
#include <iostream.h>

enum bool{false,true};

bool password()
{
int i=0;
char ch;
char p[30];
cout<<"\nEnter the Password: ";
cout.flush();
while((ch=getch())!='\r')
{
p[i]=ch;
cout<<"*";
cout.flush();
i++;
}
p[i]='\0';
if(strcmp(p,"farhan"))
{
cout<<"\nAccess is denied";
return false;
}
return true;

}
void main()
{
clrscr();
if(password())
cout<<"\nPassword Accepted";
else
cout<<"\nInvalid Password";
getch();
}
http://www.ravianeducation.blogspot.com
FARHAN: 03008855006

You might also like