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

Name this program one. c - Complete the program shown below. #include #include t

ID: 3806576 • Letter: N

Question

Name this program one. c - Complete the program shown below. #include #include typedef struct letter { char ch; struct letter *next; } Letter; int main(void) { Letter a, b, c, d, e, f, g, h, i; a.ch ='D'; a.next = &b; b.ch ='0'; b.next = &c; c.ch ='R' ; c.next = &d; d.ch = 'M' ; d.next= &e; e.ch = 'I' ; e.net = &f; f.ch = 'T' ; f.next = &g; g.ch = 'O'; g.next = &h; h.ch = 'R'; h.next = ei; i.ch = 'Y' ; i.next = NULL; Letter *ptr = &a; while (ptr != NULL ) { printf ("%c", ptr->ch); ptr = ptr->next; } printf(" "); // rearrange pointers so that it spells "DIRTYROOM" ptr = &a; while (ptr != NULL ) { printf("%c", ptr->ch); ptr = ptr->next; } printf(" "); return 0; } Name this program two. c - In your one. c program, replace the line shown in blue below with the line shown in red. Modify the rest of your program (including insertion of the necessary malloc statements) so that your program runs the same as your one. c program runs. Name this program three.c - Repeat program two.c using an array of thirteen "Letters" that initially contains the phrase ELEVENPLUSTWO (allocate space, assign values, print the list). Then modify pointers in the data array so that it says TWELVE PLUS ONE. Print this revised list. Letter *data[13]; For all problems, modify pointers to transform the word. Modifying character values is unacceptable.

Explanation / Answer

2)

#include <stdio.h>
#include <stdlib.h>
typedef struct letter{
   char ch;
   struct letter *next;
}Letter;

int main(void)
{
   Letter *a,*b,*c,*d,*e,*f,*g,*h,*i;
  
   a = (Letter*)malloc(sizeof(Letter));
   b = (Letter*)malloc(sizeof(Letter));
   c = (Letter*)malloc(sizeof(Letter));
   d = (Letter*)malloc(sizeof(Letter));
   e = (Letter*)malloc(sizeof(Letter));
   f = (Letter*)malloc(sizeof(Letter));
   g = (Letter*)malloc(sizeof(Letter));
   h = (Letter*)malloc(sizeof(Letter));
   i = (Letter*)malloc(sizeof(Letter));

   a->ch='D';a->next=b;
   b->ch = 'O'; b->next = c;
   c->ch = 'R'; c->next = d;
   d->ch = 'M'; d->next = e;
   e->ch = 'I'; e->next = f;
   f->ch = 'T'; f->next = g;
   g->ch = 'O'; g->next=h;
   h->ch = 'R'; h->next = i;
   i->ch = 'Y'; i->next = NULL;
   Letter *ptr = a;
   while (ptr!=NULL)
   {
       printf("%c",ptr->ch);
       ptr = ptr->next;
   }
   printf(" ");
   return 0;
}

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