Skip to content

Latest commit

 

History

History
39 lines (22 loc) · 1.39 KB

CppOperatorLogicalOr.md

File metadata and controls

39 lines (22 loc) · 1.39 KB

 

 

 

 

 

 

operator|| (pronounced as 'logical or operator') is an operator to state that at least one of multiple conditions must be true. In the example below, both the username 'Bilderbikkel' and 'Parachutemeisje' are correct.

 


#include <iostream> #include <string> int main() {   std::string user_name;   std::cout << "Please enter your username\n";   std::cin >> user_name;   if (user_name == "Bilderbikkel"     || user_name == "Parachutemeisje")   {     std::cout << "Welcome\n";   }   else   {     std::cout << "Access failed\n";   } }