Site icon DataFlair

C Project – How to Create Login Page

Program 1

#include<stdio.h>
#include<conio.h>
#define clrscr() system("cls")
int main()
{
    clrscr();
     char ch1,ch2,ch3,ch4;
     static int i=0;
   pin: printf("\nEnter pin(only 4 digit): ");
    ch1=getch();
    printf("*");
    ch2=getch();
    printf("*");
    ch3=getch();
    printf("*");
    ch4=getch();
    printf("*");
    if(ch1=='1' && ch2=='2' && ch3=='3' && ch4=='4' ) 
        printf("\n You are valid user............. WEL COME");
    else
    {
         i++;
         if(i==3)
         {
            printf("\n ..........Contact to admin your account is locked................ ");
            exit(0);
         }
         else
         {
          printf("\n Pin is incorrect enter again: ");
          goto pin;
         }  
    }

    return 0;
}

Program 2

#include<stdio.h>
#include<conio.h>
#define clrscr() system("cls")
int main()
{
      char user[50], password[50],ch;
      int i=0;
      clrscr();
      printf("Enter User Name: ");
      gets(user);
      printf("Enter Password(for exit press enter or tab) :  ");
      while(1)
      {
            ch=getch();
            if(ch==9 || ch==13)
            break;
            printf("*");
            password[i]=ch;
            i++;
     }
     printf("\n Password is : %s",password);
}

Program 3

#include<stdio.h>
#include<conio.h>
#define clrscr() system("cls")
int main()
{
    char ch;
    clrscr();
    printf("Enter a character : ");
    ch=getche();
    printf(" %c :   %d ",ch,ch);
    return 0;   
}

 

Exit mobile version