```
* Asuming the list is sorted in ascending order, inserts n in the list
* at the right position to maintain the ascending and returns the resulted list.
*/
struct node * insert (int n, struct node * list){
struct node * newnode = (struct node *) malloc (sizeof(struct node));
struct node * current = (struct node *) malloc (sizeof(struct node));
current = list;
//int start = current-> val;
newnode -> val = n;
newnode -> next = NULL;
if (newnode-> val < current->val || current == NULL)
{
newnode->next = current;
list = newnode;
}
else if (current -> next == NULL && newnode -> val > current -> val)
{
current ->next = newnode;
newnode -> next = NULL;
}
else
{
while (newnode -> val < current -> next -> val )
{
current = current -> next;
}
newnode -> next = current -> next;
current-> next= newnode;
}
list= current;
return list;
}
```

0

*Edited
by __avd*: Added [code] tags.