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

Problem 3 Write a function named enterNewPassword. This function takes no parame

ID: 3599964 • Letter: P

Question

Problem 3 Write a function named enterNewPassword. This function takes no parameters. It prompts the user to enter a password until the entered password has 8-15 characters, including at least one digit. Tell the user whenever a password fails one or both of these tests Problem 4 Implement the GuessNumber game. In this game, the computer Think of a random number in the range 0-50. (Hint: use the random module.) Repeatedly prompt the user to guess the mystery number lf the guess is correct·co gratulate the user for wnning. If the guess is ioorrect, let the user know if the guess is too high or too low * After 5 incorrect guesses, tell the user the right answer The following is an example of correct input and output. 'm thinking of a number in the range 0-50. You have five tries to guess it Guess 1? 32 32 is too high Guess 27 18 18 is too low Guess 3? 24 You are right: I was thinking of 24

Explanation / Answer

(3)C program to do so -

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
void enterNewPassword()
{
char p[16] ;
int i , l , ch=1 ;
while(ch)
{
printf("Enter password ");
scanf("%s",p);
l=strlen(p);
if(l<8)
{
printf("Length is less than 8 , try again ");
continue;
}
else
if(l>15)
{
printf("Length is greater than 15 , try again ");
continue;
}
  
for(i=0;i<l;i++)
{
if(p[i]=='0'||p[i]=='1'||p[i]=='2'||p[i]=='3'||p[i]=='4'||p[i]=='5'||p[i]=='6'||p[i]=='7'||p[i]=='8'||p[i]=='9')
{
printf("Password Accepted ");
ch=0;
break;
}
}
if(ch!=0)
{
  
printf("There should be at least one digit ");
printf("Try again ");
ch=1;
break;

}
}   
}
int main()
{
enterNewPassword();
return 0;
}

(4)C program to do so -

#include<stdio.h>
#include<stdlib.h>

int main()
{
int a=rand()%51;//0 to 50 any random number
int ch =1 , g ,c=0, i=0;
printf("I am thinking a number 0 to 50 , make your guess ");
while(ch=1)
{
printf("Enter guess %d ",c+1);
scanf("%d",&g);
  
if(g>a)
{
printf("Your guess is too high ");
c=c+1;
}
else if(g<a)
{
printf("Your guess is too low ");
c=c+1;
  
}
else if(g==a)
{
printf("Congrats your guess is correct ");
ch=0;
exit(0);
}
  
if(c==5)
{
printf("The value is %d ",a);
exit(0);
}
  
}
  
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