Академический Документы
Профессиональный Документы
Культура Документы
#include<stdio.h>
#include<conio.h>
#define MAX 20 //maximum no of elements in the list
//user defined datatypes
struct
{
}l;
int
int
int
int
list[MAX];
element;//new element to be inserted
pos; //position of the element to be inserted or deleted
length; //total no of elements
case 2:
l.length = 0;
create();
break;
if (islistfull() != true)
{
printf("\tEnter the New element : ");
scanf("%d", &element);
printf("\tEnter the Position : ");
scanf("%d", &pos);
insert(element, pos);
}
else
{
printf("\tList if Full. Cannot
insert");
continue...");
case 3:
}
break;
getch();
if (islistempty() != true)
{
printf("Enter the position of element
");
scanf("%d", &pos);
delet(pos);
}
else
{
printf("List is Empty.");
printf("\nPress any key to
to be deleted :
continue...");
case 4:
}
break;
getch();
l.length);
case 5:
case 6:
case 7:
display();
break;
exit(0);
break;
default:
printf("Invalid Choice");
printf("\nPress any key to continue...");
getch();
}
}
//function to display the list of elements
int menu()
{
int ch;
clrscr();
printf("\n\t\t********************************************\n");
}
//function to check whether the list is full or not
boolean islistfull(void)
{
if (l.length == MAX)
return true;
else
return false;
}
//function to check whether the list is empty or not
boolean islistempty(void)
{
if (l.length == 0)
return true;
else
return false;
}
Sample Output:
1. Create
2. Insert
3. Delete
4. Count
5. Find
6. Display
7. Exit
Enter your Choice: 1
Enter an element: 25
To insert another element press 1: 1
Enter an element: 50
To insert another element press 1: 0
Enter your Choice: 6
Element in the List are
1. 25
2. 50
Enter your Choice: 2
Enter an element: 5
Enter the position: 1
Element in the List are
1. 25
2. 50
Enter your Choice: 3
Enter the position: 3
Enter your Choice: 6
Element in the List are
1. 5
2. 25
Enter your Choice: 4
Number of Elements: 2
Enter your Choice: 7