Question

In C Write a function that asks for the user's first, middle, and last names. The...

In C

  1. Write a function that asks for the user's first, middle, and last names. The names will be entered by the user on a single line and will be stored in three different C-strings. The program should then store, in a fourth array, the name arranged in the following manner: the last name followed by a comma and a space, followed by the first name and a space, followed by the middle name. For example, if the user entered Carol Lynn Smith, it should store Smith, Carol Lynn in the fourth array. Display the contents of the fourth array on the screen. You can assume that each individual name will be no more than 20 characters. (remember to have space for the null terminator as well)
  2. Write a function that asks for a password and then verifies that it meets the criteria below. If it doesn't meet the specifications, the program should display a specific error message telling the user why the password is invalid.

    Criteria:
  • between 6 and 14 characters long
  • at least one uppercase and one lowercase character
  • at least 1 digit
  • at least one punctuation symbol

3. Combine the functions in a single driver program that checks that both functions work properly.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

1)

#include <stdio.h>
#include<string.h>
void fun(char first[],char middle[],char last[],char format[])
{
int i,ct=0;
for(i=0;i<strlen(last);i++)
{
format[ct++]=last[i];
}
format[ct++]=',';
format[ct++]=' ';
for(i=0;i<strlen(first);i++)
{
format[ct++]=first[i];
}
format[ct++]=' ';
for(i=0;i<strlen(middle);i++)
{
format[ct++]=middle[i];
}
format[ct++]='\0';
  
}
int main()
{
char first[20];
char middle[20];
char last[20];
char format[65];
printf("Enter first name: ");
scanf("%s",first);
printf("Enter middle name: ");
scanf("%s",middle);
printf("Enter last name: ");
scanf("%s",last);
fun(first,middle,last,format);
printf("%s",format);

return 0;
}

Add a comment
Know the answer?
Add Answer to:
In C Write a function that asks for the user's first, middle, and last names. The...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • C++ Do not use "cin" to get the names from the user. Use "getline()". Name Arranger...

    C++ Do not use "cin" to get the names from the user. Use "getline()". Name Arranger Write a program that asks for the user’s first, middle, and last names. The names should be stored in three different character arrays. The program should then store, in a fourth array, the name arranged in the following manner: the last name followed by a comma and a space, followed by the first name and a space, followed by the middle name. For example,...

  • Python code. No use of def() or return. 7a)Create a program that asks the user for...

    Python code. No use of def() or return. 7a)Create a program that asks the user for their full name (first, middle, and last). You can assume that compound names, such as Jamie-Lynn are joined by a hyphen, that names are separated by a space and that the user enters their data in the correct format. The program should then separate the first name, middle name, and last name from the single string entered by the user and save each piece...

  • C++: Imagine you are developing a software package that requires users to enter their own passwords....

    C++: Imagine you are developing a software package that requires users to enter their own passwords. Your software requires that users’ passwords meet the following criteria: -The password should be at least six characters long. You can set the maximum size and let the user know -The password should contain at least one uppercase and at least one lowercase letter. -The password should have at least one digit. Write a program that asks for a password into a c-string and...

  • write a ContactBook in C++ ContactBook that holds 10 names with that names corresponding contact (last...

    write a ContactBook in C++ ContactBook that holds 10 names with that names corresponding contact (last name and first name of the owner). Ask the user to input up to 10 Contacts (It may be less. The user should have the ability to stop inputting Contacts whenever he wishes). 3.This class will store a list of Contacts in a stack allocated array of default capacity 10. 4.You must be able to add new contacts to a list, delete old contacts,...

  • Write C++ program (studentsGpa.cpp) uses dynamic allocation to create an array of strings. It asks the...

    Write C++ program (studentsGpa.cpp) uses dynamic allocation to create an array of strings. It asks the user to enter a number and based on the entered number it allocates the array size. Then based on that number it asks the user that many times to enter student’s names. What you need to do:  Add another array of doubles to store the gpa of each student as you enter them  You need to display both the student’s name and...

  • Create a Java program which asks the user how many names they want to enter. The...

    Create a Java program which asks the user how many names they want to enter. The program should then instantiate an array that will hold this many names. The main method should call a method, getNames() to allow the user to enter the names. A for loop should be used in this method. Once the names are entered, the main method should call another method displayNames() which will use a while loop to display the names entered.

  • How do I format this into C++? This the prompt: Design a class named Password that...

    How do I format this into C++? This the prompt: Design a class named Password that stores a password in a c-string and has member functions to test if the password complies with certain requirements as follows: The password should be between 6 and 20 characters long. The password should contain at least one uppercase and at least one lowercase letter. The password should have at least one digit. The password should have at least one punctuation character. Define a...

  • Write a program that processes a data file of names in which each name is on...

    Write a program that processes a data file of names in which each name is on a separate line of at most 80 characters. Here are two sample names: Hartman-Montgomery, Jane R. Doe, J. D. Strings On each line the surname is followed by a comma and a space. Next comes the first name or initial, then a space and the middle initial. Your program should scan the names into three arrays— surname , first , and middle_init . If...

  • Write a C++ program that asks user number of students in a class and their names....

    Write a C++ program that asks user number of students in a class and their names. Number of students are limited to 100 maximum. Then, it will ask for 3 test scores of each student. The program will calculate the average of test scores for each student and display with their names. Then, it will sort the averages in descending order and display the sorted list with students’ names and ranking. Follow the Steps Below Save the project as A4_StudentRanking_yourname....

  • Using C Programming, Write a program that prompts for the user's first and last names. Declare a third array that will hold the user's last name and first name, separated by a comma and space....

    Using C Programming, Write a program that prompts for the user's first and last names. Declare a third array that will hold the user's last name and first name, separated by a comma and space. Use loops to inter through the names one character at a time, storing them into the full name array. Don't forget about the terminating character. Sample run: Enter your first name: john Enter your last name: matthews First name: John Last name: Matthews Full name:...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT