Menu
Coddy logo textTech

Recap - Validation Function

Part of the Fundamentals section of Coddy's C++ journey — lesson 56 of 74.

challenge icon

Challenge

Easy

Write a function named is_valid that gets two string arguments, username and password.

The function will return true if the username and password are valid in the system, otherwise false.

Our system contains only two valid usernames - "admin" and "user".

The valid password for username "user" is "qwerty".

For username "admin" any password is valid!

Try it yourself

#include <iostream>
#include <string>

bool is_valid(std::string username, std::string password) {
    // Write your code below
    
}

int main() {
    std::string user, pass;
    std::cin >> user;
    std::cin >> pass;
    bool res = is_valid(user, pass);
    std::cout << (res ? "true" : "false");
    return 0;
}

All lessons in Fundamentals