You must use C Language.
The Main Objective: Make the first and last name ALL CAPITALS even if the user types in lower case letters. Lastly, flip the first name and last name around. So: HEIDI, HATFIELD to HATFIELD, HEIDI. (PLEASE uppercase all the letters)
End Goal:
HATFIELD, HEIDI
KAISER, RUSSELL
LIPSHUTZ, HOWARD
PENKERT, DAWN
WRIGHT, ELIZABETH
Please use this reference below, to fix the code given. Code given is below, I want the user to be able to enter the first name and last name lowercased, be able to have them capitalized, and have the last name first and the first name last if that makes sense. So not: heidi, hatfield but HATFIELD, HEIDI. I'm aware you can type it in capitalized, but that's more work on the users end and not what is required of the program.
This is what the code prints now:
heidi, hatfield
russel, kaiser
howard, lipshutz
dawn, penkert
elizabeth, wright
CODE:
#include
#include
#include
void stsrt(char *strings[], int num);
char * s_gets(char * st, int n);
#define LIMIT 20
#define FIRST_SIZE 25
#define LAST_SIZE 25
void rollsheet(void);
char * s_gets(char * st, int n);
void stsrt(char *strings[], int num);
int roll(void) {
printf("Enter up to %d student names, and I will sort them!\n",
LIMIT);
printf("To stop, press the Enter key at a line's
start.\n\n");
rollsheet();
}
void rollsheet(void) {
int ct = 0;
char *ptstr[LIMIT];
char firstName[LIMIT][FIRST_SIZE];
char lastName[LIMIT][LAST_SIZE];
int k;
while (ct < LIMIT)
{
printf("\nEnter the First name: ");
if (s_gets(firstName[ct], FIRST_SIZE) != NULL &&
firstName[ct][0] != '\0')
{
printf("Enter the Last name: ");
if (s_gets(lastName[ct], LAST_SIZE) != NULL &&
lastName[ct][0] != '\0')
{
strcat(firstName[ct], ", ");
strcat(firstName[ct], lastName[ct]);
ptstr[ct] = firstName[ct];
}
else
break;
}
else
break;
ct++;
}
stsrt(ptstr,ct);
puts("\nHere's the sorted list:\n");
for (k = 0; k < ct; k++)
puts(ptstr[k]);
}
void stsrt(char *strings[], int num)
{
char *temp;
int top, seek;
for (top = 0; top < num-1; top++)
for (seek = top + 1; seek < num; seek++)
if (strcmp(strings[top],strings[seek]) > 0)
{
temp = strings[top];
strings[top] = strings[seek];
strings[seek] = temp;
}
}
char * s_gets(char * st, int n)
{
char * ret_val;
int i = 0;
ret_val = fgets(st, n, stdin);
if (ret_val)
{
while (st[i] != '\n' && st[i] != '\0')
i++;
if (st[i] == '\n') {
st[i] = '\0';
}
else {
while (getchar() != '\n')
continue;
}
}
return ret_val;
}
#include <stdio.h>
#include <string.h>
#include <conio.h>
int main()
{
roll();
}
void stsrt(char *strings[], int num);
char * s_gets(char * st, int n);
#define LIMIT 20
#define FIRST_SIZE 25
#define LAST_SIZE 25
void rollsheet(void);
char * s_gets(char * st, int n);
void stsrt(char *strings[], int num);
int roll(void) {
printf("Enter up to %d student names, and I will sort them!\n",
LIMIT);
printf("To stop, press the Enter key at a line's
start.\n\n");
rollsheet();
}
void rollsheet(void) {
int ct = 0;
char *ptstr[LIMIT];
char firstName[LIMIT][FIRST_SIZE];
char lastName[LIMIT][LAST_SIZE];
char tenp[LIMIT][LAST_SIZE];
int k;
while (ct < LIMIT)
{
printf("\nEnter the First name: ");
if (s_gets(firstName[ct], FIRST_SIZE) != NULL &&
firstName[ct][0] != '\0')
{
printf("Enter the Last name: ");
if (s_gets(lastName[ct], LAST_SIZE) != NULL &&
lastName[ct][0] != '\0')
{
strcat(toupper(lastName[ct]), ", ");
strcat(toupper(lastName[ct]), toupper(firstName[ct]));
ptstr[ct] = lastName[ct];
}
else
break;
}
else
break;
ct++;
}
stsrt(ptstr,ct);
puts("\nHere's the sorted list:\n");
for (k = 0; k < ct; k++)
puts(ptstr[k]);
}
void stsrt(char *strings[], int num)
{
char *temp;
int top, seek;
for (top = 0; top < num-1; top++)
for (seek = top + 1; seek < num; seek++)
if (strcmp(strings[top],strings[seek]) > 0)
{
temp = strings[top];
strings[top] = strings[seek];
strings[seek] = temp;
}
}
char * s_gets(char * st, int n)
{
char * ret_val;
int i = 0;
ret_val = fgets(st, n, stdin);
if (ret_val)
{
while (st[i] != '\n' && st[i] != '\0')
i++;
if (st[i] == '\n') {
st[i] = '\0';
}
else {
while (getchar() != '\n')
continue;
}
}
return ret_val;
}
You must use C Language. The Main Objective: Make the first and last name ALL CAPITALS...
C program help #include #include #include void PrintName(char firstname[16], char lastname[16]); int main () { char firstname[16]; char lastname[16]; printf("please enter your first name:"); scanf("%s",firstname); printf("please enter your last name:"); scanf("%s",lastname); PrintName(firstname,lastname); return 0; } void PrintName(char firstname[16], char lastname[16]){ char fullname[34]; *fullname=*firstname+*lastname; (char*) malloc (sizeof (*fullname)); if (strlen(firstname) > 16||strlen(lastname)>16||strlen(fullname)>16) fflush(stdin); else printf(" the full name is %s %s \n",firstname,lastname); printf(" the full name is-> %s",fullname);/*why is one not run*/ return 0; }
Convert this C program to Js (Java script) from Visual Studio Code #include<stdio.h> int main(){ char firstName[100]; char lastName[100]; printf("Enter Your Full Name: \n"); scanf("%s %s", firstName, lastName); printf("First Name: %s\n", firstName); printf("Last Name: %s\n", lastName); return 0; }
-I need to write a program in C to store a list of names (the last name first) and age in parallel arrays , and then later to sort them into alphabetical order, keeping the age with the correct names. - Could you please fix this program for me! #include <stdio.h> #include <stdlib.h> #include <string.h> void data_sort(char name[100],int age[100],int size){ int i = 0; while (i < size){ int j = i+1; while (j < size){...
For C++ Create a student structure that has fields for first name, last name, hometown, state, year in college and major. Keep the number of students to a reasonabe level. Place each structure into an array sorted by last name and within last name, by first name. Read the student information from a file and print the sorted array to the screen and then to an output file. I was using the code below to guide me but it keeps...
I'm having trouble getting my program to output What is your first name? damion what is your last name? anderson damion, Your first name is 6 characters Your last name, anderson, is 8 characters Your name in reverse is: noimad nosredna This is my code so far: #include <stdlib.h> #include <stdio.h> void sizeOfName(char** name); void printSizeOfName(int *first, int *last, char** name); void reverseString(int *first, int *last, char** name); int main() { char** name; name = (char**)malloc(2*sizeof(char*)); name[0] = (char*)malloc(100*sizeof(char)); name[1]...
c/c++
Last name: First name: ID: Sec: The name, ID and section number that appear at the beginning of the output of the program should be your own, not the ones used in the sample Note: results printed must show the data entered at run time, not the data shown in the sample run below! Sample run: 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24...
Need help, i can't get a infinite loop to work, that terminates when a blank line is inputted for the firstName. note: C programing langauge and using microsoft visual studios . #define _CRT_SECURE_NO_WARNINGS #include <stdio.h> #include <string.h> #include <stdlib.h> #include <ctype.h> #include <math.h> #include <stdbool.h> int main() { //int arraySalaries[50]; int calculate_avg = 0; //int calculate_max; //int calculate_min; int salary[50]; //int length; //int average_salary; char firstName[50][50]; char lastName[50][50]; int i...
C LANGUAGE I just need the void push() function, which inserts new node to the front of the list #include<stdio.h> #include<stdlib.h> typedef struct node { int data; struct node *next; } Node; //Creating head a as a global Node* Node *head; /* Given a node prev_node, insert a new node after the given prev_node */ void insertAfter (Node * prev_node, int new_data) { /*1. check if the given prev_node is NULL */ if (prev_node == NULL) { printf ("the given...
JAVA Can you make this return the first letter of first and last name capitalized? import java.io.File; import java.io.IOException; import java.util.*; public class M1 { public static void main(String[] args) { //scanner input from user Scanner scanner = new Scanner(System.in); // System.out.print("Please enter your full name: "); String fullname = scanner.nextLine(); //creating a for loop to call first and last name separately int i,k=0; String first="",last=""; for(i=0;i<fullname.length();i++) { char j=fullname.charAt(i); if(j==' ') { k=i; break; } first=first+j;...
C Programming - RSA Encryption I've tried to write a program that can encrypt and decrypt strings using RSA and want to be able to integrate it into a header file which contains codes for compression, linked list etc.. However, the use of global variables and fixed size of encryption is making it hard to do so Can someone please help me modify the following the code? I want to be able to just pass it in a string to...