Question

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: Matthews, John

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

If you have any doubts, please give me comment...

#include<stdio.h>

#include<stdlib.h>

#include<ctype.h>

int main(){

char fname[50], lname[50], fullname[100];

printf("Enter your first name: ");

scanf_s("%s", fname, (unsigned)_countof(fname));

printf("Enter your last name: ");

scanf_s("%s", lname, , (unsigned)_countof(lname));

fname[0] = toupper(fname[0]);

lname[0] = toupper(lname[0]);

printf("First name: %s\n", fname);

printf("Last name: %s\n", lname);

int i=0, k=0;

while(lname[i]!='\0'){

fullname[k] = lname[i];

k++;

i++;

}

fullname[k++] = ',';

fullname[k++] = ' ';

i=0;

while(fname[i]!='\0'){

fullname[k] = fname[i];

k++;

i++;

}

fullname[k] = '\0';

printf("Full name: %s\n", fullname);

return 0;

}

Add a comment
Know the answer?
Add Answer to:
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....
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
  • In C Write a function that asks for the user's first, middle, and last names. The...

    In C 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...

  • Write a program that prompts the user to enter a list of names. Each person's name...

    Write a program that prompts the user to enter a list of names. Each person's name is separated from the next by a semi-colon and a space (: and the names are entered lastName, firstName (i.e. separated by ',). Your program should then print out the names, one per line, with the first names first followed by the last names. A sample run of your program should look like Please enter your list of names: Epstein, Susan; St. John, Katherine;...

  • Write a program that reads a person's first and last names, separated by a space. Then...

    Write a program that reads a person's first and last names, separated by a space. Then the program outputs last name, comma, first name. End with newline. Example output if the input is: Maya Jones Jones, Maya import java.util.Scanner; public class SpaceReplace {    public static void main (String [] args) {       Scanner scnr = new Scanner(System.in);       String firstName;       String lastName; //answer goes here//    } }

  • Write a program that reads a person's first and last names, separated by a space. Then...

    Write a program that reads a person's first and last names, separated by a space. Then the program outputs last name, comma, first name. End with newline. Example output if the input is Maya Jones Tones, Maya import java . util·Scanner; public class SpaceReplace 4 public static void main (String [1 ares) f( Scanner scnr-new Scanner(System.in); String firstName; String lastName; Your solution goes here */ 10 12

  • Lab 2: (one task for Program 5): Declare an array of C-strings to hold course names,...

    Lab 2: (one task for Program 5): Declare an array of C-strings to hold course names, and read in course names from an input file. Then do the output to show each course name that was read in. See Chapter 8 section on "C-Strings", and the section "Arrays of Strings and C-strings", which gives an example related to this lab. Declare the array for course names as a 2-D char array: char courseNames[10] [ 50]; -each row will be a...

  • Write a C++ program that produces the following output: /* OUTPUT Enter your age: 21 Enter...

    Write a C++ program that produces the following output: /* OUTPUT Enter your age: 21 Enter the last name: Lee Hello Tom Lee. You are 21 years old. Press any key */   Declare an array named: firstName The array is a c_string, i.e., it is a null-terminated character array. The size of the array is 10. Assign a first name to it when it is declared.   Declare an array named: lastName The array is a c_string, The size of the...

  • C- PROGRAMMING PROJECT #4 Design and Write a C program to calculate an average of an...

    C- PROGRAMMING PROJECT #4 Design and Write a C program to calculate an average of an array of numbers and produce the following output: 1. Your first and last name 2. Course Number 3. C Project Number 4. All the numbers in the array 5. The sum of all the numbers in the array 6. The count of all the numbers in the array 7. The average of all the numbers in the array Double-space after lines 3, 4, 5,...

  • Write a C++ program that prompts the user with the following menu options: [E]rase–ArrayContent [C]ount–Words [R]ev–Words...

    Write a C++ program that prompts the user with the following menu options: [E]rase–ArrayContent [C]ount–Words [R]ev–Words [Q]uit 1. For Erase–ArrayContent option, write complete code for the C++ function Erase described below. The prototype for Erase is as follows: void Erase( int a[ ], int * N, int * Search-Element ) The function Erase should remove all occurrences of Search-Element from the array    a[ ]. Note that array a[ ] is loaded with integer numbers entered by the user through the...

  • Write in C Spring 2016 Lab Assignment 11 ET2100 In computer programming in general a "string"...

    Write in C Spring 2016 Lab Assignment 11 ET2100 In computer programming in general a "string" is a sequence of characters. In the C language anything within double quotes is a "string constant" so you have been seeing strings all semester. But we can also have string variables. In the C language these are implemented as an array of char, e.g. char name (10]: In order to make these variables easier to work with, it has been universally agreed that...

  • Write a C++ program that prompts the user with the following menu options: Erase-ArrayContent Count-Words Quit...

    Write a C++ program that prompts the user with the following menu options: Erase-ArrayContent Count-Words Quit 1. For Erase-ArrayContent option, write complete code for the C++ function Erase described below. The prototype for Erase function is as follow: void Erase( int a[ ], int * N, int * Search-Element) The function Erase should remove all occurrences of Search-Element from the array al). Note that array a[ ] is loaded with integer numbers entered by the user through the keyboard. N...

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