Question: I need this in c programming assignment is given and also code is given you just have to code the lines where it says TODO

I need this in c programming

assignment is given and also code is given you just have to

code the lines where it says TODO here

please edit the code that i have given and please send me screenshot of the output as well

please only edit this below code shown. any other form will not work

I need this in c programming assignment is given and also code

is given you just have to code the lines where it says

TODO here please edit the code that i have given and please

//In this assignment, we practice call by reference.

//Below description of call by reference is from the following link //https://www.tutorialspoint.com/cprogramming/c_function_call_by_reference.htm

//The call by reference method of passing arguments to a function copies //the address of an argument into the formal parameter. Inside the function, //the address is used to access the actual argument used in the call. //It means the changes made to the parameter affect the passed argument.

//We use an example of linked list for this purpose. //In the example, an implementation of how to add a node to the head of the list //is given. We need to implement how to remove a node from the head of the list. //Both of the functions should keep track of the length of the list. //If we successuflly added a node to the list, the length should be incremented by one. //Also, if we successfully rmoeved a node from the list, the length should be decrementd //by one.

#include #include #include

typedef struct node_tag { int v; // data struct node_tag * next; // A pointer to this type of struct } node; // Define a type. Easier to use.

node * create_node(int v) { node * p = malloc(sizeof(node)); // Allocate memory assert(p != NULL); // you can be nicer

// Set the value in the node. p->v = v; p->next = NULL; return p; // return }

//This function show us how to add a new node to the font of a linked list, //at the same time, how to update the length of the list. //Note the ** in front of head //Note the * in front of length //Think why this is call by reference for a point and an integer void add_first(node **head, node *newnode, int *length) { if(*head == NULL) { *head = newnode; newnode->next = NULL; } else { newnode->next = *head; *head = newnode; } (*length) ++; }

//Now we need to implement the remove_first function node * remove_first(node **head, int *length) { //Add your code below

}

void print_list(node *head) { while(head!=NULL) { printf("%d ", head->v); head = head->next; } printf(" "); }

//Do not change the code in main function

int main(int argc, char *argv[]) { if(argc != 2) { printf("Usage: %s n ", argv[0]); return -1; } int n = atoi(argv[1]); assert(n>=1 && n

for(int i=1; i /In this assignment, we practice call by reference 2 3 //Below description of call by reference is from the following link 4 I/https://www.tutorialspoint.com/cprogramming/c_function_call_by_reference htm 5 6 //The call by reference method of passing arguments to a function copies 7 //the address of an argument into the formal parameter. Inside the function, 8 //the address is used to access the actual argument used in the call. 9 //It means the changes made to the parameter affect the passed argument. 11 //we use an example of linked list for this purpose. 12 //In the example, an implementation of how to add a node to the head of the list 13 //is given. We need to implement how to remove a node from the head of the list. 14 //Both of the functions should keep track of the length of the list. 15 //If we successuflly added a node to the list, the length should be incremented by one. 16 //Also, if we successfully rmoeved a node from the list, the length should be decrementd 17 //by one 18 19 #include 29 #include 21 #include 23 typedef struct node_tag 24 25 nt v 26 struct node_tag next; 11 A pointer to this type of struct 27 node; 28 29 30 nodecreate_node (int v) 31 32 node p malloc(sizeof (node)); // Allocate memory 33 assert(p != NULL); 34 35 36 // data // Define a type. Easier to use. // you can be nicer // Set the value in the node p->next NULL; return C reference-c x 37 38 39 p->next return P; NULL; // return 41 I/This function show us how to add a new node to the font of a linked list, 42 //at the same time, how to update the length of the List. 43 //Note the ** in front of head 44 //Note the in front of Length 45 //Think why this is call by reference for a point and an integer 46 void add_first (node **head, node *newnode, int length) 47 48 if(*head := NULL) 49 *head newnode; newnode->next = NULL; 51 52 53 54 else newnode->nexthead; * head newnode ; 56 57 58*length) ++ 59 60 61 //Now we need to implement the remove first function 62 noderemove_first(node **head, int length) 63 64 65 //Add your code below 67 68 69 70 void print_list (node *head) 71 72 while(head !=NULL) 73 74 75 76 printf("%d ", head->v); head head->next; printf("n") 78 79 C reference.c x hea ad->next: printf("n") 78 79 80 //Do not change the code in main function 81 82 int main(int argc, char *argv[]) 83 84 85 86 87 if(argc - 2) printf("Usage: return-1 %s n ", argv[0]); int n- atoi (argv[i]) assert(n>-l && n

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!