-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQ6.cpp
More file actions
34 lines (27 loc) · 706 Bytes
/
Q6.cpp
File metadata and controls
34 lines (27 loc) · 706 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// 6. Write a function that checks if a username and password match predefined values. If the username is "admin" and the password is "1234", print "Login successful"; otherwise, print "Login failed."
#include <iostream>
#include <cstring>
using namespace std;
bool checkLoginCredentials(string name, string pass) {
if (name == "admin" && pass== "1234") {
return true;
}
else {
return false;
}
}
int main(){
string name,pass;
cout<<"Enter Username: ";
cin>>name;
cout<<"Enter Password: ";
cin>>pass;
bool result = checkLoginCredentials(name, pass);
if(result){
cout<<"Login Successful! \n";
}
else{
cout<<"Login Failed! \n";
}
return 0;
}