From b7a182392109e908c35c7f6cfe9943c4134c0b3a Mon Sep 17 00:00:00 2001 From: GauravSingh9356 <55052983+GauravSingh9356@users.noreply.github.com> Date: Fri, 25 Oct 2019 19:13:04 +0530 Subject: [PATCH 1/3] Created linkedlist Linked list for display --- linked.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 linked.c diff --git a/linked.c b/linked.c new file mode 100644 index 0000000..8907c91 --- /dev/null +++ b/linked.c @@ -0,0 +1,49 @@ +#include +#include + + + struct node{ //structure declared + int data; + struct node *ptr; +}; + + int main() +{ + struct node *first=NULL;//Assings null initially + + struct node *second=NULL;//Assings null initially + + struct node *third=NULL;//Assings null initially + + first=malloc(sizeof(struct node)); + + second=malloc(sizeof(struct node)); + + third=malloc(sizeof(struct node)); + + first->data=22;//filling 22 into data + + first->ptr=second; + + second->data=23;//filling 23 into data + + second->ptr=third; + + third->data=24;//filling 24 into data + + third->ptr=NULL; + + printlist(first); + +return 0; +} + int printlist(struct node *n) + +{ + while(n!=NULL) +{ + printf("\t%d",n->data);//printing of data +n=n->ptr; +} +return 0; +} From d4ccda0e01903a2e7975ec0c8d910e7670ff71c0 Mon Sep 17 00:00:00 2001 From: GauravSingh9356 <55052983+GauravSingh9356@users.noreply.github.com> Date: Fri, 25 Oct 2019 19:20:04 +0530 Subject: [PATCH 2/3] Bubble Sorting --- bst.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 bst.c diff --git a/bst.c b/bst.c new file mode 100644 index 0000000..2e546a4 --- /dev/null +++ b/bst.c @@ -0,0 +1,50 @@ +#include +#include//for malloc memory declaration + int bs(int *ptr1); + + int main() +{ + int *ptr,n,i; + + ptr=malloc(n*sizeof(int));//makes an array of n blocks; + + printf("Enter the size of an array\n"); + + scanf("%d",&n); + printf("Enter the array\n");//message for array entry + + for(i=0;i*(ptr1+i+1))//comparision for sorting +{ + temp=*(ptr1+i); //swapping + + *(ptr1+i)=*(ptr1+i+1); + *(ptr1+i+1)=temp; +} +} + +} + for(i=0;i Date: Sat, 26 Oct 2019 01:37:52 +0530 Subject: [PATCH 3/3] GCD function using simple function --- GCD.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 GCD.c diff --git a/GCD.c b/GCD.c new file mode 100644 index 0000000..61a23d5 --- /dev/null +++ b/GCD.c @@ -0,0 +1,20 @@ +#include +int main() +{ + int n1, n2, i, gcd; + + printf("Enter two integers: "); + + scanf("%d %d", &n1, &n2); + + for(i=1; i <= n1 && i <= n2; ++i) + { + // Checks if i is factor of both integers + + if(n1%i==0 && n2%i==0) //here if i on division gives 0 as remainder in both cases that means it is definetely GCD + gcd = i; + } + printf("G.C.D of %d and %d is %d", n1, n2, gcd); //prints the GCD value + + return 0; +} \ No newline at end of file