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

I am having trouble with this question to program, we are to program in the C pr

ID: 3806531 • Letter: I

Question

I am having trouble with this question to program, we are to program in the C programming language. Please help me.

3. 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 TWELVEPLUSONE. Print this revised list. Hint -your second print loop would start at data[10] if you encoded the original message in location 0..12 of the data array. Letter *data [13]

Explanation / Answer

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

int main(void)
{
   Letter *data[13];
   int i;
   for(i=0;i<13;i++)
   {
       data[i] = (Letter *)malloc(sizeof(char));
   }

   data[0]->ch = 'E';
   data[1]->ch = 'L';
   data[2]->ch = 'E';
   data[3]->ch = 'V';
   data[4]->ch = 'E';
   data[5]->ch = 'N';
   data[6]->ch = 'P';
   data[7]->ch = 'L';
   data[8]->ch = 'U';
   data[9]->ch = 'S';
   data[10]->ch = 'T';
   data[11]->ch = 'W';
   data[12]->ch = 'O';

   data[0]->next = data[1];
   data[1]->next = data[2];
   data[2]->next = data[3];
   data[3]->next = data[4];
   data[4]->next = data[5];
   data[5]->next = data[6];
   data[6]->next = data[7];
   data[7]->next = data[8];
   data[8]->next = data[9];
   data[9]->next = data[10];
   data[10]->next = data[11];
   data[11]->next = data[12];
   data[12]->next = NULL;

  
   Letter *ab =data[0];
   while(ab!=NULL)
   {
       printf("%c",ab->ch);
       ab = ab->next;
   }
   printf(" ");

   data[10]->next = data[11];
data[11]->next = data[0];
data[0]->next = data[1];
data[1]->next = data[3];
data[3]->next = data[2];
data[2]->next = data[6];
data[6]->next = data[7];
data[7]->next = data[8];
data[8]->next = data[9];
data[9]->next = data[12];
data[12]->next = data[5];
data[5]->next = data[4];
data[4]->next = NULL;

   ab =data[10];
   while(ab!=NULL)
   {
       printf("%c",ab->ch);
       ab = ab->next;
   }
   printf(" ");
}