Contact Learn C
Copy

Program 317:Password Generator in C

Program 317:Password Generator using C
 
#include <stdlib.h>
#include <stdio.h>
#include<time.h>
int main() 
{
  int i,password,len;
  srand((unsigned int)time(NULL));
  printf("Enter Password Length and must be greater than 5\n");
  scanf("%d",&len);
  if(len>=5)
  {
     for(i=0;i<len;i++)
      {
      int k=rand()%128;
       if((k>=48&&k<=57)||(k>=65&&k<=90)||(k>=97&&k<=122)||(k>=35&&k<=37)||k==64)
       {
        printf("%c",k);
        }
        else
        {
         i--;
        }
      }
      printf("\n");
  }
  else
  {
   printf("Length should be greater than 5\n");
  }
  return(0);
}
Explanation:

//Coming Soon...

Output:
Password Generator in C

Password Generator in C



3 comments:

  1. Can you explain to me what is the use of this line?: if((k>=48&&k<=57)||(k>=65&&k<=90)||(k>=97&&k<=122)||(k>=35&&k<=37)||k==64)

    ReplyDelete
  2. I admire what you have done here. I like the part where you say you are doing this to give back but I would assume by all the comments that this is working for you as well. gasoline generator

    ReplyDelete

Donate

Download App and Learn when ever you want

Get it on PlayStore
Get it on Amazon App Store
Get it on Aptoide