From b44c92a65b0d117d13705c8a516cc7b58a922574 Mon Sep 17 00:00:00 2001 From: Mohit Singh Date: Mon, 8 Oct 2018 18:04:56 +0530 Subject: [PATCH] Main function for Addition of 2 numbers through CLL --- .../add-main.c | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 Addition of 2 Large Numbers using Circular Linked List/add-main.c 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 new file mode 100644 index 0000000..1535fe9 --- /dev/null +++ b/Addition of 2 Large Numbers using Circular Linked List/add-main.c @@ -0,0 +1,35 @@ +#include "add.h" + +int main() +{ + char str1[100], str2[100]; + int i, num; + struct node *res = NULL; + struct node *first = NULL; + struct node *second = NULL; + first = getnode(); + first -> data = 0; + first -> next = first; + second = getnode(); + second -> data = 0; + second -> next = second; + printf("Enter number 1: "); + scanf("%s", str1); + printf("Enter number 2: "); + scanf("%s", str2); + for(i = 0; str1[i] != '\0'; i++) + { + num = str[i] - 48; + first = insert(first, num); + } + printlist(first); + for(i = 0; str2 != '\0'; i++) + { + num = str2[i] - 48; + second = insert(second, num); + } + printlist(second); + res = addtolist(first, second); + printlist(res); + return 0; +}