Slip No 8 Que1 Que2
Slip No 8 Que1 Que2
pos = linear_serach(a,n,x);
if(pos == -1){
printf("%d not found in array",x);
}else{
printf("%d found at position %d",x,pos);
}
}
/*Output
i. Create()
ii. Display()
iii. Insert()
iv. Delete()
*/
#include <stdio.h>
#include <stdlib.h>
if (temp == NULL)
{
/* code */
printf("Position is out of Range");
return;
}
newnode = (NODE *)malloc(sizeof(NODE));
newnode->info = num;
newnode->next = temp->next;
temp->next=newnode;
}
void main()
{
NODE *head;
int choice,n,pos;
head=(NODE *)malloc(sizeof(NODE));
head->next=NULL;
do
{
printf("\n\n-------------------Singly Linked List Program-------------------
");
printf("\n1:Create");
printf("\n2:Diplay");
printf("\n3:Insert");
printf("\n4:Delete");
printf("\n0:To Exit");
printf("\nEnter Your Choice: ");
scanf("%d",&choice);
switch(choice)
{
case 1:
create(head);
break;
case 2:
printf("\nElement has been display:\n");
display(head);
break;
case 3:
printf("\nEnter the element and position:\n");
scanf("%d%d",&n,&pos);
insert(head,n,pos);
display(head);
break;
case 4:
printf("\nEnter Value to Delete:\n");
scanf("%d",&n);
delete(head,n);
display(head);
break;
}
}while(choice!=5);
}
/*Output
2
3
6
3
3
4
*/