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 0000000..599bfaa Binary files /dev/null and b/Addition of 2 Large Numbers using Circular Linked List/add-defintion.o differ 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 0000000..c0f894c Binary files /dev/null and b/Addition of 2 Large Numbers using Circular Linked List/add-main.o differ diff --git a/Addition of 2 Large Numbers using Circular Linked List/add.h b/Addition of 2 Large Numbers using Circular Linked List/add.h index 12c6fad..9e260ce 100644 --- a/Addition of 2 Large Numbers using Circular Linked List/add.h +++ b/Addition of 2 Large Numbers using Circular Linked List/add.h @@ -6,6 +6,7 @@ struct node { struct node *next; + int data; }; struct node *getnode(); diff --git a/Addition of 2 Large Numbers using Circular Linked List/program b/Addition of 2 Large Numbers using Circular Linked List/program new file mode 100644 index 0000000..432606a Binary files /dev/null and b/Addition of 2 Large Numbers using Circular Linked List/program differ