Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

instead of

image text in transcribed

#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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

=+a tadpole into a frog.

Answered: 1 week ago

Question

Perform an Internet search. Discuss a company that uses EPLI.

Answered: 1 week ago

Question

How do you feel about employment-at-will policies? Are they fair?

Answered: 1 week ago