Skip to content

Commit

Permalink
Fix errors and final code working
Browse files Browse the repository at this point in the history
  • Loading branch information
msindev committed Oct 8, 2018
1 parent b44c92a commit a9a37e7
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
struct node
{
struct node *next;
int data;
};

struct node *getnode();
Expand Down
Binary file not shown.

0 comments on commit a9a37e7

Please sign in to comment.