* C PROGRAMMING*
Outcomes:
Program Specifications:
Create the following menu system:
When the user selects (1) you will prompt them for a name, age, and weight. You will insert the record into the linked list which will be alphabetically ordered by name (first letter of full name).
When the user selects (2) you will display all records currently in the list.
This program will not use an array, but it will use a linked list of structs. The program will allow for an unlimited number of records. The only limit will the amount of available RAM.
DO NOT USE:
Note: The language used is C.
Code:
#include<stdio.h>
#include<string.h>
#include<malloc.h>
struct record{
char name[100];
int age;
float weight;
};
//Linked List Node
struct Node{
struct record rec;
struct Node *next;
};
//This function adds a record in the linked list
//according to alphabetical order of name.
void addRecord(struct Node **head, struct record newRecord){
//Create a new node
struct Node *newNode = (struct Node*)malloc(sizeof(struct
Node));
newNode->rec = newRecord;
//When linked list is empty
if(*head == NULL){
newNode->next = NULL;
*head = newNode; //Set head pointer to newNode.
return;
}
//If linked list has only one node.
if((*head)->next == NULL){
//Compare names of newNode and head.
if(strcmp((*head)->rec.name, newRecord.name) > 0){
newNode->next = *head;
*head = newNode;
return;
}
(*head)->next = newNode;
newNode->next = NULL;
}
//Maintain current and previous pointers and traverse the linked
list.
struct Node *curr = (*head)->next;
struct Node *prev = *head;
while(curr){
if(strcmp(curr->rec.name, newRecord.name) > 0){
newNode->next = curr;
prev->next = newNode;
return;
}
prev = curr;
curr = curr->next;
}
//If newNode is added to the last.
prev->next = newNode;
newNode->next = NULL;
}
//This function displays all the records.
void displayRecords(struct Node *head){
int i = 1;
struct Node *curr = head;
//Traverse the linked list and print the data.
while(curr){
printf("%d.\n", i);
printf("Name: %s\n", curr->rec.name);
printf("Age: %d\n", curr->rec.age);
printf("Weight: %.2f\n\n", curr->rec.weight);
i++;
curr = curr->next;
}
}
//Main function
int main(){
//head node is initialized to null.
struct Node *head = NULL;
int option = 1;
printf("Select appropriate option.\n");
while(option != 3){
struct record newRecord;
//Menu
printf("1. Add a record\n");
printf("2. Display all records\n");
printf("3. Quit\n");
scanf("%d", &option);
switch(option){
case 1:
printf("Enter name(beginning with capital letter and rest
small):\n");
scanf("%s", newRecord.name);
printf("Enter age:\n");
scanf("%d", &newRecord.age);
printf("Enter weight:\n");
scanf("%f", &newRecord.weight);
addRecord(&head, newRecord); //We pass the address of head so
that it can be modified by the function.
break;
case 2:
displayRecords(head);
break;
case 3:
break;
default:
printf("Select correct option\n");
break;
}
}
return 0;
}
Code Snippets:






Sample Output:

* C PROGRAMMING* Outcomes: Demonstrate the ability to create and use linked lists in dynamic memory...
The following needs to be in C programming ! Outcomes: Demonstrate the ability to design a menu driven program. Demonstrate the ability to reuse previous code to create a new assignment. Demonstrate the ability to use appropriate program logic. Program Specifications: DESIGN and IMPLEMENT a menu driven program that uses the following menu and can perform all menu items: Enter a payroll record for one person Display all paycheck stubs Display total gross payroll from all pay records. Quit program...
Methods and File Output and Exceptions Outcome: Student will demonstrate the ability to write, use and call methods Student will demonstrate the ability to pass values to and from methods Student will demonstrate the ability to catch exceptions Student will demonstrate the ability to create a text file Student will demonstrate the ability to validate input data Program Specifications: You to write a menu driven program. The program will use a switch statement. The cases will be as follows: Get...
***************C PROGRAMMING ONLY************* Demonstrate the ability to create an array on the stack Demonstrate the ability to create an array on the heap allowing user to choose the number of values to store. Demonstrate the ability to store an array of Struct values on both the stack and the heap. Program Specifications: 1. Create a struct with at least 3 fields - any struct you want but explain it in your comments in the code. Populate at least 10 elements...
Please use C++
CS3358 Insert and delete a node Programming Project 2: The linked list - Reference: chapter 18: Create an array of 15 student records that should not be sorted Create a liked list of 15 student record nodes. Each node is a node of one student record from the above unsorted array. The list of student records should be sorted by student ID. (Insert function without sort function to create a linked list.) (If you insert correctly, the...
Java Programing Code only Ragged Array Assignment Outcome: Student will demonstrate the ability to create and use a 2D array Student will demonstrate the ability to create and use a jagged array Student will demonstrate the ability to design a menu system Student will demonstrate the ability to think Program Specifications: Write a program that does the following: Uses a menu system Creates an array with less than 25 rows and greater than 5 rows and an unknown number of...
*MUST BE IN C PROGRAMMING* Demonstrate the ability to think critically Demonstrate the ability to work with strings and chars Demonstrate the ability to design a menu system Write a simple program that allows the user to enter a number between 1 and 1000. The program will then display the Roman numeral equivalent. Allow the user to keep entering numbers for conversion to Roman numerals, or to quit, using a menu system of your own design. Submission Requirements: You are to write...
Write a MIPS assembly language program that uses dynamic memory allocation to create and manage a linked list data structure. Gives the user the following options: 1. To create and add the first node to a linked list. 2. To add a single node to the pre-existing linked list. The list must already exist before a new node can be added. The nodes should be maintained in ascending order based on the data value within the nodes...
C++. Please note the BOLDED ITEMS. You will create a simple linked structure. You will use a simple node that has a pointer to a Node. The data for the Node will be a single data member of type char. You will build a structure where the last node you add will point to the first node created, i.e. it will be a circular linked structure. You will create a program that stores characters provided by the user, stored in...
Programing C Just with #include <stdio.h> We will create a singly linked list of 7 nodes. Then, the user will tell us whether to print the “odd-placed” nodes or the “even-placed” nodes. For example, if I had a list of 5 nodes like below, and the user specifies for the odd nodes to be printed, my program would print the values in nodes nl and n3. If the user instead indicated for the even nodes to be printed, my program...
Note: Do it Using CPP Language. Thanks.
Implement a program that uses dynamic memory and uses an insertion sort to add items to a singly-linked list. Modify the sorted listed by deleting elements as specified below. Create a sorted list (by state) of nodes containing all the state information (state name, capital, population). Display your list. Remove states whose population is less than four (4) million. Display the resulting list after the states have been removed from the list. Create...