Tech Study

Write a C# program to check the username and password

Introduction

I have used Visual Studio 2012 for debugging purpose. But you can use any version of visul studio as per your availability..

using System;
public class Stringexercise
{
    public static void Main()
    {
        string username, password;
        int ctr = 0;        
        do
        {
            Console.Write("Input a username: ");
            username = Console.ReadLine();
 
            Console.Write("Input a password: ");
            password = Console.ReadLine();
 
            if (username != "abcd" || password != "1234")
                ctr++;
            else
                ctr = 1;
 
        }
        while ((username != "admin" || password != "123456") && (ctr != 3));
 
        if (ctr == 3)
            Console.WriteLine("\nLogin attemp three or more times. Try later!");
        else
            Console.WriteLine("\nThe password entered successfully!");
 
        Console.ReadLine();
    }
}

Result

Write a C# program to check the username and password
Write a C# program to check the username and password

TaggedWrite a C# program to check the username and password

Python Examples

Introduction: Python Examples are the basic programming concepts of python like python syntax,python data types,,python operators,python if else,python comments etc.. …

Read more

C String Functions

C String Functions perform certain operations, It provides many useful string functions which can come into action. The <string.h> header …

Read more