From a9a37e705bf883c0915d566ba60b3e41ad049882 Mon Sep 17 00:00:00 2001 From: Mohit Singh Date: Mon, 8 Oct 2018 18:34:11 +0530 Subject: [PATCH] Fix errors and final code working --- .../add-defintion.c | 8 +++++--- .../add-defintion.o | Bin 0 -> 2880 bytes .../add-main.c | 14 +++++++++----- .../add-main.o | Bin 0 -> 2968 bytes .../add.h | 1 + .../program | Bin 0 -> 12848 bytes 6 files changed, 15 insertions(+), 8 deletions(-) create mode 100644 Addition of 2 Large Numbers using Circular Linked List/add-defintion.o create mode 100644 Addition of 2 Large Numbers using Circular Linked List/add-main.o create mode 100644 Addition of 2 Large Numbers using Circular Linked List/program diff --git a/Addition of 2 Large Numbers using Circular Linked List/add-defintion.c b/Addition of 2 Large Numbers using Circular Linked List/add-defintion.c index a862491..48b154a 100644 --- a/Addition of 2 Large Numbers using Circular Linked List/add-defintion.c +++ b/Addition of 2 Large Numbers using Circular Linked List/add-defintion.c @@ -73,16 +73,18 @@ struct node *addToList(struct node *first, struct node *second) if(carry > 0) { res = insert(res, carry); - return res; } + return res; } void printlist(struct node *head) { struct node *temp = head; - while(temp != NULL) + temp = temp -> next; + while(temp != head) { - print("%d", temp -> data); + printf("%d", temp -> data); temp = temp -> next; } + printf("\n"); } diff --git a/Addition of 2 Large Numbers using Circular Linked List/add-defintion.o b/Addition of 2 Large Numbers using Circular Linked List/add-defintion.o new file mode 100644 index 0000000000000000000000000000000000000000..599bfaab794a0c7449ea824385db8f7bd81f5bd3 GIT binary patch literal 2880 zcmchY?`s@I7{_NXZF8|{a*9Gq1y7-B(5#7yZEclH!Y2D7+E{Z~LAh-1_L|W9QSNpj zN>hcPxLt(etGx4t;Ga;6Z?b8@T;IhvaxWs>iwdXbi}=bzg!p}CXD-{x9SEWi%+Ac` z`MEQ*v!57qGciqLQZ)7^JD5p|K7KGx@nMRcV1q1edOw@%za=&kfK5`Ep3ydaYU#G= zC1`m6o-j+A-dfXhAKW3shphed18+VKWXma-dta+ zvl~xf%TUVU1#WZ>R+7#zY;YLmL8lYZZk+~fV~f4-%`e|jju`(QxEUE?;hXLcn~%VV zZ{n@{_fF>+o1LD1J^6fk$t^i<@{In9K0fyH8JABdZcLoj$6p-{G5j8<1Q6}xOH5l$ zXr~7IBBluLS+U9p`~IcKxX?A*nv$+^tMnVENuh0Ma_)SQuFMXOLKXW2@r zYF8ZcT`143R2_D$f&hiiD9^6BPIlR>(Y~%3g&5x!KE^e8no-BJIEKl88WCrhYLgFcMSwgvIuTN<2@Y(VC~wqGF1G zdjis3Nxt%n9TEIl!Id=Z3l#`^HUEnurfU9A{U=2J=oz3?(qE0M=07L=$H^%ozHodY z!e}V{Wj_^RQPbOMVxg3N()K;!uhxG@_-{x<(aZIh_!0))_U~+eXt5{^Y5&Mq`pf;J wdeq$HGEYGv8=_#kQ|SIs{fTvZ)u#9rEJ7a@_5JBy@8-WD>bIiK7_0t&0~gFXga7~l literal 0 HcmV?d00001 diff --git a/Addition of 2 Large Numbers using Circular Linked List/add-main.c b/Addition of 2 Large Numbers using Circular Linked List/add-main.c index 1535fe9..a180dac 100644 --- a/Addition of 2 Large Numbers using Circular Linked List/add-main.c +++ b/Addition of 2 Large Numbers using Circular Linked List/add-main.c @@ -15,21 +15,25 @@ int main() second -> next = second; printf("Enter number 1: "); scanf("%s", str1); + getchar(); printf("Enter number 2: "); scanf("%s", str2); for(i = 0; str1[i] != '\0'; i++) { - num = str[i] - 48; + num = str1[i] - 48; first = insert(first, num); } - printlist(first); - for(i = 0; str2 != '\0'; i++) + printf("1st Number: "); + puts(str1); + for(i = 0; str2[i] != '\0'; i++) { num = str2[i] - 48; second = insert(second, num); } - printlist(second); - res = addtolist(first, second); + printf("Second Number: "); + puts(str2); + res = addToList(first, second); + printf("Result: "); printlist(res); return 0; } diff --git a/Addition of 2 Large Numbers using Circular Linked List/add-main.o b/Addition of 2 Large Numbers using Circular Linked List/add-main.o new file mode 100644 index 0000000000000000000000000000000000000000..c0f894ce697881ca0af9a85cd3313a0b12a099d2 G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