Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

A password for a computer system must 1) have exactly 8 characters 2) consist of

ID: 3623381 • Letter: A

Question

A password for a computer system must

1) have exactly 8 characters
2) consist of only alphabetic characters and digits
3) have at least one digit
4) have at least one alphabetic character

write as program accept or reject a sequence of characters entered from the keyboard as a password. If the input does not meet the requirments for a password have the program ask for another attempt and specify which requirment was not meet. If the password meets the requirment should state the fact and terminate.

Explanation / Answer

please rate - thanks

#include <stdio.h>
#include<conio.h>
int main()
{char pw[15];
int good,digit,alpha,i;
do
{digit=0;
alpha=0;
good=0;
printf("Enter a password: ");
scanf("%s",&pw);
for(i=0;i<pw[i]!='';i++)
   if(isdigit(pw[i]) )
         digit++;
   else if(isalpha(pw[i]))
         alpha++;

if(i!=8)
    {printf("must have exactly 8 characters ");
     good=1;
     }
if(digit==0)
      {printf("must have at least 1 digit ");
       good=1;
       }    
if(alpha==0)
      {printf("must have at least 1 alphabetic character ");
       good=1;
       }
if(digit+alpha!=8)
      {printf("must have only alphabetic characters and digits ");
       good=1;
       }  
printf(" ");            
}while(good!=0);     
printf("%s is a valid password ",pw);                   
getch();
return 0;
       
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote