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

Write the following functions in a source code file named palO. c: Write a funct

ID: 3556224 • Letter: W

Question

Write the following functions in a source code file named palO. c: Write a function that accepts a C-string as its argument The function should verify that the string meets the following criteria for a valid password: The password length should be at least eight characters long. b. The password should contain at least one uppercase and at least one lowercase letter. c. The password should have at least one digit. The function should return 1 if the password is valid, or 0 otherwise. Write a function that accepts a C-string as its argument The function should reverse the string in place (i.e., do not use another array). Write a function that accepts a C-string as its argument The function should convert the string to all lowercase. Write a function that accepts a C-string as its argument The function should convert the string to start case, where all words start with a capital letter. All other characters should be converted to lowrercase. Write a function that accepts a C-string as its argument The function should return the character that appears most frequently in the string. Document how your function responds if multiple characters share the same frequency. For example, given the string "zzaapp", which character will your function return as having the highest frequency? Write a program to test each function using a menu-driven interface: The user should be able to select a test, provide input, and view the result Remember to consider boundary conditions (e.g. empty strings, etc.) in your functions. Write helper functions as necessary for your implementation.

Explanation / Answer

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int verify(char *pass)
{
int low=0,upp=0,dig=0;
int l=strlen(pass);
int i;
for(i=0;i<l;i++)
{
if(isupper(pass[i]))
upp=1;
if(islower(pass[i]))
{
low=1;
}
if(isdigit(pass[i]))
dig=1;
}
if(dig && upp && low && l>=8)
return 1;
else
return 0;

}
void reverse(char *str)
{
int i=0;
int j=strlen(str)-1;
while(i<j)
{
char temp=str[i];
str[i]=str[j];
str[j]=temp;
i++;
j--;
}
}
void lowercase(char *str)
{
int i;
for(i=0;i<strlen(str);i++)
{
str[i]=tolower(str[i]);
}
}
void startcase(char *str)
{
int l=strlen(str),i;
if(l!=0)
str[0]=toupper(str[0]);
for(i=1;i<l-1;i++)
{
if(str[i]==' ')
str[i+1]=toupper(str[i+1]);
}
}
char most_frequent(char *str)
{
int count[26]={0};
int i;
for(i=0;i<strlen(str);i++)
count[str[i]-'a']++;
int maxi=0;
for(i=1;i<26;i++)
{
if(count[maxi]<count[i])
maxi=i;
}
return (maxi+97);
}
main()
{
int ch;
char password[100];
int c1;
char string[100];
printf("String function Tester. ");
printf("1 pass verifier ");
printf("2 Reverse string ");
printf("3 Lowercase ");
printf("4 Startcase ");
printf("5 Most freqquent letter ");
printf("0 quit ");
printf("Enter ur choice: ");
scanf("%d",&ch);
switch(ch)
{
case 1:
printf("enter password to verify ");
scanf("%s",&password);

c1=verify(password);
if(c1==1)
printf("Vlaid password ");
else
printf("Invalid Password ");
break;
case 2:
{
printf("enter string to reverse ");
scanf("%s",&password);
reverse(password);
printf("reverse string is %s ",password );
break;
}
case 3:
{
printf("enter string to convert to lowercase ");
scanf("%s",&password);
lowercase(password);
printf("reverse string is %s ",password );
break;
}
case 4:
{
printf("enter string to convert to startcase ");
gets(password);
gets(password);
startcase(password);
printf("startcase string is %s ",password );
break;
}
case 5:
{

printf("enter the string ");
scanf("%s",&string);//my most frequent will print in alphabetic order if there are more than one maximum occuring letter
printf("Most frequent letter is %c ",most_frequent(string));
break;
}
}
}