```
#include <stdlib.h>
#include<iostream>
#include<conio.h>
typedef struct kume1{
int data;
struct kume1 *next;
};
typedef kume1 *kume1ptr;
void insert(kume1ptr *x,int a);
void del(kume1ptr *x);
int main(){
int t=1;
kume1ptr first1=NULL;
kume1ptr first2=NULL;
int x;
int i;
for( i=10;i>=1;i--)//ikisi içinde 20 şer tane random sayı üretiyoruz
{
x=rand() % 100 + 1;
insert(&first1,x);
printf("burdayim");
}
for(i=1;i<=50;i++){//ekrana büyükten küçüğe yazdırdık
printf("%d\n",first1->data);
first1=first1->next;
}//ekrana büyükten küçüğe yazdırdık
system("pause");
}//Main sonu
void insert(kume1ptr *head,int datam)
{
int t=1;
kume1ptr current,yeni;
yeni=(kume1 *)malloc(sizeof(kume1));
if((*head)!=NULL){
current=*head;
if(datam>(*head)->data){
yeni->data=datam;
yeni->next=*head;
*head=yeni;
}
else{
while(datam < current->data){
t++;
printf("%d",t);
if((current->next)!=NULL){
current=current->next;
}
else{
break;
}
}
yeni=current;
current->data=datam;
current->next=yeni;
}
}
else{yeni->data=datam;
yeni->next=*head;
*head=yeni;
printf("%d",(*head)->data);
}
}
//first1 =( kume1 *) malloc(sizeof(kume1));
```

hi i want to create random 20 numbers and put it in a linked list when i put a number into the list i put it in the order.so the head will always be the biggest.It works well when the numbers comes in a increasing way,but when a number which is less than the head it doesn't work.It goes to an infinite loop.

What am i doing wrong?

Thanks for any help;