Tuesday, April 19, 2022

Simple Login in C++

 A simple login is written in C++ programming language. I hope you will find our work useful. 

I am currently accepting programming work, IT projects, school and application development, programming projects, thesis and capstone projects, IT consulting work, computer tutorials, and web development work kindly contact me in the following email address for further details.  If you want to advertise on my website kindly contact me also in my email address also. Thank you.


My email address is the following jakerpomperada@gmail.com, jakerpomperada@aol.com, and jakerpomperada@yahoo.com.


My mobile number here in the Philippines is 09173084360.


Please subscribe to my channel  https://www.youtube.com/channel/UCOs-lpOoIeJoh6gpJthPoGg


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


Want to support my channel?

GCash Account

Jake Pomperada

09173084360


Paypal

https://paypal.me/jakerpomperada


Patreon

https://www.patreon.com/jakerpomperada


Thank you very much for your support





Program Listing

#include <iostream>

#include <string>


const std::string CorrectPassword("1234");

const int MaxLoginAttempts = 3;


int main()

{

  bool loggedIn = false;

  int loginAttempts = 0;

  std::string password;

  

  std::cout << "\n\n";

  std::cout << "\tSimple Login in C++";

  std::cout << "\n\n";

  while(!loggedIn && loginAttempts < MaxLoginAttempts)

  {

    std::cout << "\n";

std::cout << "\tEnter password : ";

    std::getline(std::cin, password);

    ++loginAttempts;

    std::cout << "\tAttempt Number : " << loginAttempts;

    if(password == CorrectPassword)

      loggedIn = true;

  }

  if(loggedIn) {

    std::cout << "\n\n";

    std::cout << "\tLogin successful!\n";

}

  else {

    std::cout << "\n\n";

    std::cout << "\tLogin failed!\n";

   }

}

No comments:

Post a Comment