Question: Change the code for the console output so that it shows instead of #include #include #include #include #include using namespace std; struct Node { char

Change the code for the console output so that it shows

Change the code for the console output so that it shows instead

instead of

of #include #include #include #include #include using namespace std; struct Node {

#include #include #include #include #include

using namespace std;

struct Node { char data; struct Node *next; };

FILE *op = NULL;

struct Node* head1 = NULL; struct Node* head2 = NULL; struct Node* head3 = NULL;

//for inserting to linked list n gives number of the linked list

void insert(char new_data, int n) { struct Node* new_node = (struct Node*) malloc(sizeof(struct Node)); new_node->data = new_data;

if( n == 1 ) { new_node->next = head1; head1 = new_node; } else if(n == 2) { new_node->next = head2; head2 = new_node; } else { new_node->next = head3; head3 = new_node; } }

//for displaying linked list void display(struct Node *ptr) { while (ptr != NULL) { fputc(ptr->data, op); ptr = ptr->next; } }

void display_cout(struct Node *ptr) { while (ptr != NULL) { fputc(ptr->data, stdout); ptr = ptr->next; } }

int main( int argc, char *argv[] ) { char line[120]; char num1[51], num2[51]; FILE *f = fopen("input.txt", "r"); op = fopen("output.txt", "w"); while( fgets(line, 120, f) ) //getting the line { fputc(' ',op); fputc(' ',op); if( line[0] == '-' ) { break; } else { sscanf(line, "%s %s", num1, num2); //reading the two numbers as strings int len1 = strlen(num1); int len2 = strlen(num2); int i,maxlen=len1; if( len2 > len1 ) maxlen = len2; //creating two lists i = 0; while( i data - 48; p1 = p1->next; } if(p2) { s += p2 -> data - 48; p2 = p2->next; } s += c; c = s / 10; s = s % 10; insert( s+48 , 3 ); i++; } // displaying numbers and sum in correct format fputs("Large Integer 1: ", op); fputs(num1, op); fputc(' ',op); cout 0 ) { insert( c+48 , 3 ); maxlen++; } i = 0; while( i++ Large Integer 1: 957994954495949457454 Large Integer 2: 774874754744875847484 957994954495949457454 + 774874754744875847484 1732869709240825304938 Large Integer 1: 80485080443358 Large Integer 2: 4849850549686868696 80485080443358+ 4849850549686868696 4849931034767312054 Large Integer 1: 99999999 99999999+ Large Integer 1: 957994954495949457454 Large Integer 2: 774874754744875847484 + 1732869709240825304938 Large Integer 1: 80485080443358 Large Integer 2: 4849850549686868696 + 4849931034767312054 Large Integer 1: 99999999 Large Integer 2: 9999999999 -+ Large Integer 1: 5555555555 Large Integer 2: 44444444444444444465 +

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!