Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Complete the lab 10. c program shown below (you must write the two functions who

ID: 3815684 • Letter: C

Question

Complete the lab 10. c program shown below (you must write the two functions whose signatures are shown in red). The program reads a file of integers (the filename is specified on the command line) and builds a linked list of the unique integer values and a count of how many times that integer value has been seen. Add Ordered - adds the new integer to the existing list in numerical order (smallest to largest). If this is the first time the number has been added to the list, create a new node and set the count for that node to one (1). If the number already exists in the list, then increment the count for that number (do not create a second node for that number). printList - prints the ordered list of numbers (and their counts) #include #include typedef struct node {int value; int count; struct node *next;} Node; Node *addOrdered(Node *, int); void printList(Node *); int main(int argc, char *argv []) {Node *head = NULL; if (argc ! = 2) {printf(

Explanation / Answer

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

#include <string.h>

struct node{
int value;
//int count=0
struct node *next;

}*head;

int main(void){

struct node *temp;
temp = malloc(sizeof(struct node));
temp->next = NULL;
head = temp;

FILE *ifp;
ifp = fopen("example.txt", "r");

int c = 0,c1=0,c2=0,c3=0,c4=0,c5=0,c6=0,c7=0,c8=0,c9=0,c10=0;
while(EOF != (c = fgetc(ifp))){
fscanf(ifp, "%d",&temp->value);
printf("%d ",temp->value);
switch(temp->value)
{
case 1:c1++;
break;
case 2:c2++;
break;
case 3:c3++;
break;
case 4:c4++;
break;
case 5:c5++;
break;
case 6:c6++;
break;
case 7:c7++;
break;
case 8:c8++;
break;
case 9:c9++;
break;
case 10:c10++;
break;

}temp->next = malloc(sizeof(struct node));
temp = temp->next;
temp->next = NULL;
c++;
}
printf(" [1-%d]",c1);
printf(" [2-%d]",c2);
printf(" [3-%d]",c3);
printf(" [4-%d]",c4);
printf(" [5-%d]",c5);
printf(" [6-%d]",c6);
printf(" [7-%d]",c7);
printf(" [8-%d]",c8);
printf(" [9-%d]",c9);
printf(" [10-%d]",c10);
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote