Question
About this Assignment
C is a general-purpose structured programming language. The best way to understand programming is to learn about flow, syntax, and debugging through practice. In this assignment, you will create a C program that incorporates elements you studied in this course.
Program Specifications
• Your program will implement a user-defined (defined by you) linked list.
• The minimum requirements of the linked list are:
o Add or delete items at the beginning of the list (push and pop)
o Remove items from the end of the list
o Remove a specific item by index or by value
• The program will be interactive. At a minimum, the end-user will be able to print the list to the screen and add and delete values using the methods above.
• The user will be able to search the list for a particular value.
• The user will be able to input values using a text file and output the list to a text file.
• Functions are to be used where appropriate to produce readable, reusable code. Library functions and user-defined functions should be used where appropriate.
Readability
• Use indentation and spacing consistently. (e.g., every line in a loop is indented to align)
• Add whitespace to help separate parts of the code. (e.g., empty line after a loop, space after a semicolon in a loop, etc.)
• Give meaningful names to variables. Variables named x, y, and z are not descriptive and give the reader no information about their purpose; instead use names like primary, max, and counter. Loop condition variables are an exception because they are contained to a single area of the code and have a universally known function, so naming with a single letter (i, j, etc.) is acceptable.
• Code should be organized into functions to reduce duplicate lines of code. Function definitions should be contained in a single section at the beginning of the program. Functions, like variables, should have meaningful names.
Documentation
• Add a comment block at the beginning to indicate the purpose of the program
• Add comments before each structure, function definition, loop and update statement: A programmer taking over your work should be able to pick up the project without additional research
• Use either /* and */, or // for comments (the style chosen is up to you)
Coding Practice/Efficiency
In addition to the items listed above, you should follow good coding practice. This includes:
• Keep lines of code to a reasonable length
• Use a non-proportional front (Courier, Consolas), so characters are evenly spaced
• Functions should perform a single operation; don't cram all code into a single function
• Do not use global variables
• Eliminate warnings from the compiler, as well as errors
Solution Preview

These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction of bibliographies out of text citations and references.
Students may use these solutions for personal skill-building and practice.
Unethical use is strictly forbidden.

#include <stdio.h>
#include <stdlib.h>

struct Node {
int data;
struct Node *next;
}*head;


/**
* It creates and returns a new node.
*/
struct Node* getNode(int data) {
struct Node* node = (struct Node *) malloc(sizeof(struct Node));
node->data = data;
node->next = NULL;
return node;
}

/**
* It inserts the data at the front
* of the linked list.
*/
void push(int data) {
if(head == NULL) {
head = getNode(data);
} else {
struct Node* node = getNode(data);
node->next = head;
head = node;
}

printf("%s: %d\n", "Added", data);
}

/**
* It returns 1 if list is empty,
* otherwise, it returns 0.
*/
int isEmpty() {
if (head == NULL) {
return 1;
} else {
return 0;
}
}

/**
* It removes the node from the front
* of linked list.
*/
void pop() {
if(!isEmpty()) {
struct Node *tmp = head;
int data = head->data;
head = head->next;
free(tmp);
printf("Deleted : %d\n", data);
} else{
printf("%s\n", "List is empty.");
}
}

/**
* It prints the item present in the linked list.
*/
void printList() {
printf("%s", "Printing items: ");
struct Node *tmp = head;
while(tmp != NULL) {
printf("%d ", tmp->data);
tmp = tmp->next;
}
printf("\n\n");
}
This is only a preview of the solution.
Please use the purchase button to see the entire solution.
By purchasing this solution you'll be able to access the following files:
Solution.c
SolutionInput.txt
Purchase Solution
$25.00
Google Pay
Amazon
Paypal
Mastercard
Visacard
Discover
Amex
View Available Computer Science Tutors 645 tutors matched
Ionut
(ionut)
Master of Computer Science
Hi! MSc Applied Informatics & Computer Science Engineer. Practical experience in many CS & IT branches.Research work & homework
5/5 (6,808+ sessions)
1 hour avg response
$15-$50 hourly rate
Pranay
(math1983)
Doctor of Philosophy (PhD)
Ph.D. in mathematics and working as an Assistant Professor in University. I can provide help in mathematics, statistics and allied areas.
4.6/5 (6,702+ sessions)
1 hour avg response
$40-$50 hourly rate
Leo
(Leo)
Doctor of Philosophy (PhD)
Hi! I have been a professor in New York and taught in a math department and in an applied math department.
4.9/5 (6,469+ sessions)
2 hours avg response

Similar Homework Solutions