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

Using string functions and all other programming features discussed in the class

ID: 3761122 • Letter: U

Question

Using string functions and all other programming features discussed in the class, write a program that will prompt a user to input their name (first and last). Ex: Please enter your first and last name: John Doe Then, output the string. Next, prompt the user to input their nickname. Ex: Enter your nickname: Rowdy Then modify the name string to consist of the person’s first name, nickname (in all caps, enclosed in double quotes) and last name. Then output the modified string. Ex: John “ROWDY” Doe NOTE: This program should loop, prompting the user to decide whether or not he or she wishes to enter another name. Ex: Do you wish to enter another name(y/n)?

Explanation / Answer

As you didn't specified your language requirement, I'm assuming it to be C. Here is the code for you. If this is not what you are looking for, please do get back to me with proper details.

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
int main()
{
char ch, first[50], last[50], nick[50], modified[100];
int i;
while(1)
{
printf("Please enter your first and last name: ");
scanf("%s%s", first, last);
printf("Hello %s %s ", first, last);
printf("Now enter your nick name: ");
scanf("%s", nick);
for(i = 0; i < strlen(nick); i++)
nick[i] = toupper(nick[i]);
strcpy(modified, first);
strcat(modified, """);
strcat(modified, nick);
strcat(modified, """);
strcat(modified, last);
printf("Now you are: %s ", modified);
printf("Do you wish to enter another name(y/n): ");
scanf(" %c", &ch);
if(ch != 'y')
exit(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