use only
#include<stdio.h>
#include <stdlib.h>
In C Program.
Using at least 3 different types/pieces of information, define an appropriate self-referential structure and manage the selected data using a linked list. A data item should have a unique identifier. Use a (case selection structure) to control the user selection from the following menu: 1) Store / Insert a data item in order 2) Remove a specific data item from the list 3) View a specific data item 4) Print a list of all the data items 5) Exit Application My topic is about Members of a local gym.
, thanks.
`Hey,
Note: Brother in case of any queries, just comment in box I would be very happy to assist all your queries
#include <stdio.h>
#include <stdlib.h>
struct Node //A linked list node
{
int data;
struct Node *next;
};
void insert(struct Node** head_ref, int new_data)
{
struct Node* new_node = (struct Node*) malloc(sizeof(struct Node)); //allocate node
struct Node *last = *head_ref; /* used in step 5*/
new_node->data = new_data; //put in the data
new_node->next = NULL; //This new node is going to be the last node, so make next of it as NULL
if (*head_ref == NULL) //If the Linked List is empty, then make the new node as head
{
*head_ref = new_node;
return;
}
while (last->next != NULL) //Else traverse till the last node
last = last->next;
last->next = new_node; //Change the next of last node
return;
}
void deleteNode(struct Node **head_ref, int key)
{
struct Node* temp = *head_ref, *prev; // Store head node
if (temp != NULL && temp->data == key) // If head node itself holds the key to be deleted
{
*head_ref = temp->next; // Changed head
free(temp); // free old head
return;
}
while (temp != NULL && temp->data != key) // Search for the key to be deleted, keep track of the previous node as we need to change 'prev->next'
{
prev = temp;
temp = temp->next;
}
if (temp == NULL) return; // If key was not present in linked list
prev->next = temp->next; // Unlink the node from linked list
free(temp); // Free memory
}
int search(struct Node* head, int x)
{
struct Node* current = head; // Initialize current
while (current != NULL)
{
if (current->data == x)
return 1;
current = current->next;
}
return 0;
}
void printList(struct Node *node)
{
while (node != NULL)
{
printf(" %d ", node->data);
node = node->next;
}
printf("\n");
}
int main()
{
struct Node* head = NULL; //Start with the empty list
while(1)
{
printf("1.Insert\n2.Delete\n3.View\n4.Print\n5.Exit\nchoose your option... ");
int n;
scanf("%d",&n);
switch(n)
{
case 1:
printf("Enter no.: ");
int x;
scanf("%d",&x);
insert(&head, x);
break;
case 2:
printf("Enter no.: ");
scanf("%d",&x);
deleteNode(&head, x);
break;
case 3:
printf("Enter no.: ");
scanf("%d",&x);
if(search(head, x))
printf("Matched\n");
else
printf("Not Matched\n");
break;
case 4:
printf("Created Linked List: ");
printList(head);
break;
case 5:
goto EndWhile;
default:
printf("ERROR: %d: Incorrect menu option\n", n);
}
}
EndWhile: ;
return 0;
}

Kindly revert for any queries
Thanks.
use only #include<stdio.h> #include <stdlib.h> In C Program. Using at least 3 different types/pieces of information,...
Question 1 Consider the following program fragment that defines a self-referential class: #include <stdlib.h> #include <stdio.h> struct node_int; typedef struct node int *node; struct node_int void *data; node next; typedef struct list_int (node first;} *list; void main(int argc, char *argv[]) list shopping, t; node n; int x=25; shopping=(list) malloc(sizeof(struct list_int)); n= (node) malloc(sizeof(struct node_int)); n->data=shopping; n->next=NULL; shopping->first=n; t=(list) (shopping->first->data); // ***** t->first=NULL; // ***** n->data=&x; printf("%d\n", *((int *) (shopping->first->data))); a What will be displayed on the screen if the above...
Please fill in the code to reverse a linked list. IN C++ #include <stdio.h> #include <stdlib.h> #include <iostream> using namespace std; /* Link list node */ struct Node { int data; // your code here }; /* Function to reverse the linked list */ static void reverse(struct Node** head_ref) { // your code here } /* Function to push a node */ void push(struct Node** head_ref, int new_data) { // your code here } /* Function to print linked list...
in C porgraming . use #include〈stdio.h〉
#include〈stdlib.h〉
Assignment 12 The program to write in this assignment is a program that calculates score statistics and manages the grades of the students. First, the student list and scores are given in a file named "student.dat" as in the following: 이성우 77 홍길동 88 2011710086 2012700091 This program reads the input file "student.dat" and keeps this data in a linear linked list. Each node must be a struct which contains the following: student_id,...
IN C Programming #include<stdio.h> #include<stdlib.h> typedef struct nodestruct { int item; struct nodestruct *next; } Node; typedef struct { int size; // Number of items on user’s list Node *head, *tail; } List; //In addition to creating an empty list, this function will also create two dummy nodes; one for the head, and the other for the tail. List* createList(); //This function creates a node containing the provided item, then inserts it into the list pointed by the provided list...
Use the C programming language to complete
#include <stdio.h>
#include <stdlib.h>
#include <float.h>
// Declare Global variables here.
void array_stats() {
// Insert your solution here.
}
#include <stdlib.h>
#include <time.h>
int main() {
// Simulate the test setup process.
srand( time( NULL ) );
for ( int i = 0; i < 32; i++ ) {
val[i] = rand();
}
val_count = rand();
val_mean = rand();
val_min = rand();
val_max = rand();
// Call submitted code.
array_stats();
// Display...
Programming in C: I am trying to modify this linked list to be doubly linked list. I’m also trying to add a print in reverse function. I’m really struggling with how to change the insert function to doubly link the nodes without effecting the alphabetical sorting mechanism. Example of desired output: Enter your choice: 1 to insert an element into the list. 2 to delete an element from the list. 3 to end. ? 1 Enter a character: a The...
Code an application program that keeps track of student information at your college. Include their names, identification numbers, and grade point averages in a fully encapsulated, homogeneous, linked-based binary search tree. When launched, the user will be presented with the following menu: Enter: 1 to insert a new student's information, 2 to fetch and output a student's information, 3 to delete a student's information, 4 to update a student's information, 5 to output all the student information in descending order,...
Fix the errors in C code #include <stdio.h> #include <stdlib.h> void insertAt(int *, int); void Delete(int *); void replaceAt(int *, int, int); int isEmpty(int *, int); int isFull(int *, int); void removeAt(int *, int); void printList(int *, int); int main() { int *a; int arraySize=0,l=0,loc=0; int choice; while(1) { printf("\n Main Menu"); printf("\n 1.Create list\n 2.Insert element at particular position\n 3.Delete list.\n4. Remove an element at given position \n 5.Replace an element at given position\n 6. Check the size of...
Project Lists and Object-oriented Programming Note: using c++ This project is an individual assignment that focuses on object-oriented programming and lists. The list will be a doubly-linked list and it will be implemented using nodes and pointers. The data contained in the list will be objects from a class. Project data: You will choose one of the following classes to define: Boat, Earthquake, Game, Sport, State, Website, House, Phone, Activist, Plant, Fish, Parrot, and Course. Your class code will include...
***In C Programming*** TASK 1: Complete itinerary.h Create a struct Destination that represents a node in a liked list. It contains the three letter airport code and a pointer to the next node int the linked list. You will need to write this struct. This file also includes the prototypes. They have all been written for you. There is no need to add the function comments for the prototypes. TASK 2: Write all functions in itinerary.c Write the following functions, which...