diff --git a/Factorial/factorial.c b/Factorial/factorial.c new file mode 100644 index 0000000..e7d70d7 --- /dev/null +++ b/Factorial/factorial.c @@ -0,0 +1,59 @@ +#include +#include +struct node{ + int place; + struct node *Llink; + struct node *link; +}*ptr,*now,*header,*pre; +void main() +{ + int i=1,n,carry=0,product; + printf("INPUT : "); + scanf("%d",&n); + now=(struct node*)malloc(sizeof(struct node)); + now->place=1; + now->link=now->Llink=NULL; + header=now; + while(i<=n) + { + ptr=header; + while(ptr->link!=NULL) + ptr=ptr->link; + while(ptr!=NULL) + { + pre=ptr; + ptr=ptr->Llink; + product=pre->place*i+carry; + carry=product/10; + pre->place=product%10; + } + while(carry>0) + { + now=(struct node*)malloc(sizeof(struct node)); + now->place=carry%10; + now->link=pre; + pre->Llink=now; + now->Llink=NULL; + header=now; + carry/=10; + pre=now; + } + i++; + } + ptr=header; + printf("%d! : ",n); + while(ptr!=NULL) + { + printf("%d",ptr->place); + ptr=ptr->link; + } + printf("\n"); + ptr=header; + while(ptr!=header) + { + pre=ptr; + ptr=ptr->link; + free(pre); + } + free(pre); +} diff --git a/Sorting/Selection_Sort/select.c b/Sorting/Selection_Sort/select.c new file mode 100644 index 0000000..366af2b --- /dev/null +++ b/Sorting/Selection_Sort/select.c @@ -0,0 +1,28 @@ +/* Selection Sort */ +#include +void ssort(int a[],int n) +{ + int i,j,temp; + for(i=0;ia[j]) + { + temp=a[i]; + a[i]=a[j]; + a[j]=temp; + } +} +void main() +{ + int a[100],i,n; + printf("No of Elements : "); + scanf("%d",&n); + printf("Enter the Elements : \n"); + for(i=0;i