From f000817f7ed256e6c6c909a9c6a322a79353053e Mon Sep 17 00:00:00 2001 From: Astrodevil <73425223+Astrodevil@users.noreply.github.com> Date: Wed, 13 Jan 2021 18:52:17 +0530 Subject: [PATCH 1/2] Create sortalist.c --- sortalist.c | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 sortalist.c diff --git a/sortalist.c b/sortalist.c new file mode 100644 index 0000000..e46fd26 --- /dev/null +++ b/sortalist.c @@ -0,0 +1,61 @@ +#include +#include + +struct node { + int data; + struct node *next; +}; + +int push(struct node **h, int x) +{ + struct node *temp = (struct node*)malloc(sizeof(struct node)); + temp->data = x; + temp->next = *h; +*h = temp; + return 0; +} + +void print(struct node *head) +{ + struct node *temp = head; + while(temp != NULL) + { + printf("%d ",temp->data); + temp = temp->next; + } + printf("\n"); +} + +void sort(struct node **h) +{ + int i,j,a; + + struct node *temp1; + struct node *temp2; + + for(temp1=*h;temp1!=NULL;temp1=temp1->next) + { + for(temp2=temp1->next;temp2!=NULL;temp2=temp2->next) + { + a = temp1->data; + temp1->data = temp2->data; + temp2->data = a; + } + } +} + +int main() +{ + struct node * head = NULL; + push(&head,5); + push(&head,4); + push(&head,6); + push(&head,2); + push(&head,9); + printf("List is : "); + print(head); + sort(&head); + printf("after sorting list is : "); + print(head); + return 0; +} From 43c0b266c8948d72c6c07b73b3213d38d52fcabd Mon Sep 17 00:00:00 2001 From: Astrodevil <73425223+Astrodevil@users.noreply.github.com> Date: Sat, 23 Jan 2021 20:56:33 +0530 Subject: [PATCH 2/2] Update string.c --- string.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/string.c b/string.c index 4aaf9b4..54d8a2c 100644 --- a/string.c +++ b/string.c @@ -1,9 +1,9 @@ #include -int main() +void main() { char name[20]; printf("Enter name "); scanf("%s",name); printf("Your name is %s",name); - return 0; -} \ No newline at end of file + +}