Cpds Lab Manual
Cpds Lab Manual
LIST OF EXPERIMENTS
AIM
To implement c programming using statements
ALGORITHM
STEP1: Start the program
STEP2: Declare the variables
STEP3: Put the x and y value
STEP4: Check the condition, if the condition true print true statements
STEP5: Otherwise print false statements
STEP6: Stop the program
PROGRAM
#include <stdio.h>
void main( )
{
int x, y;
x = 15;
y = 18;
if (x > y )
{
printf("x is greater than y");
}
else
{
printf("y is greater than x");
}
}
2
Y is greater than x
RESULT
Thus the c program using statement was executed successfully.
ALGORITHM
STEP1: Start the program
STEP2: Declare the variables
STEP3: Enter the variable value
STEP4: Perform the arithmetic operations
STEP5: Print the values
STEP6: Stop the program
PROGRAM
#include <stdio.h>
int main()
{
int a,b,result;
printf("Enter 2 numbers for Arithmetic operation \n");
scanf("%d\n%d",&a,&b);
printf("=======ARITHMETIC EXPRESSIONS=======\n");
result = a+b;
printf("Addition of %d and %d is = %d \n",a,b,result);
result = a-b;
printf("Subtraction of %d and %d is = %d \n",a,b,result);
result = a*b;
printf("Multiplication of %d and %d is = %d \n",a,b,result);
result = a/b;
printf("Division of %d and %d is = %d \n",a,b,result);
result = a%b;
printf("Modulus(Remainder) when %d divided by %d = %d \n",a,b,result);
int c=a;
4
OUTPUT
Enter 2 numbers for arithmetic operation
10
5
======ARITHMETIC EXPRESSIONS=======
Addition of 10 and 5 is = 15
Subtraction of 10 and 5 is = 5
Multiplication of 10 and 5 is = 50
Division of 10 and 5 is = 2
Modulus(Remainder) when 10 divided by 5 = 0
Post Increment of 10 is = 10
Pre Increment of 10 is = 12
Post decrement of 10 is = 12
Pre decrement of 10 is = 10
===========================
5
AIM
To implement c programming using decision making and iterative statements
ALGORITHM
STEP1: Start the program
STEP2: Declare the variables
STEP3: Enter the variable value
STEP4: Check the condition, if it is true print palindrome
STEP5: Otherwise print not palindrome
STEP6: Stop the program
PROGRAM
#include<stdio.h>
#include<conio.h>
void main()
{
int a, b, c, s = 0;
clrscr();
printf("Enter a number:\t");
scanf("%d", &a);
c = a;
while(a > 0)
{
b = a%10;
s = (s*10)+b;
a = a/10;
7
OUTPUT
RESULT
Thus the c program using decision making and iterative statements was executed
successfully.
8
AIM
To implement c programming using functions and arrays
ALGORITHM
STEP1: Start the program
STEP2: Declare the function with variables
STEP3: Enter the variable value
STEP4: Calculate the formula to sum the given values
STEP5: Print the result value
STEP6: Stop the program
PROGRAM
// Program to calculate the sum of array elements by passing to a function
#include <stdio.h>
float calculateSum(float num[]);
int main()
{
float result, num[] = {23.4, 55, 22.6, 3, 40.5, 18};
result = calculateSum(num);
printf("Result = %.2f", result);
return 0;
}
float calculateSum(float num[])
{
float sum = 0.0;
OUTPUT
Result = 162.50
RESULT
Thus the c program using functions and arrays was executed successfully.
10
AIM
To implement c programming using pointers and structures
ALGORITHM
STEP1: Start the program
STEP2: Declare the structure
STEP3: Enter the variable values
STEP4: Print the result
STEP5: Stop the program
PROGRAM
#include <stdio.h>
#include <stdlib.h>
struct person
{
int age;
float weight;
char name[30];
};
int main()
{
struct person *ptr;
int i, n;
printf("Enter the number of persons: ");
scanf("%d", &n);
OUTPUT
Enter the number of persons: 2
Enter first name and age respectively: Harry 24
Enter first name and age respectively: Gary 32
Displaying Information:
Name: Harry Age: 24
Name: Gary Age: 32
RESULT
Thus the c program using pointers and structures was executed successfully.
12
ALGORITHM
STEP1: Start the program
STEP2: Open the file using file name with read mode
STEP3: Read the content of file
STEP4: Print the content of file
STEP5: After reading the content of file close the opening file
STEP6: Stop the program
PROGRAM
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{
FILE* ptr;
char ch;
// Opening file in reading mode
ptr = fopen("test.txt", "r");
if (NULL = = ptr)
{
printf("file can't be opened \n");
}
printf("content of this file are \n");
INPUT FILE
ECE | C programming and Data Structure
OUTPUT
C: \Users\Desktop>gcc fgetcexp.c –o fgetcexp
C: \Users\Desktop>fgetcexp
Content of this file are
ECE | C programming and Data Structure
RESULT
Thus the c program using files was executed successfully.
EX.NO:5 DEVELOPMENT OF REAL TIME C APPLICATIONS
CASE STUDY
What is the C Language?
14
The C programming language has been highly influential, and many other languages have
been derived from it. For example, C++ and Java are two popular modern dialects of C.
And C is an excellent choice for system programming, for example, developing operating
systems, compilers, and network drivers. Despite its popularity, C is not without its criticisms.
Some have argued that its syntax could be more complex and easier to learn, while others have
noted its lack of standardization as a significant issue. Nevertheless, C remains a widely used and
influential language and will probably continue for many years.
History of C language
The C programming language was created at Bell Laboratories in the early 1970s, mainly
by Ken Thompson and Dennis Ritchie. For the UNIX operating system, which at the time
required applications to be written in assembly language, programmers needed a more user-
friendly set of instructions. Assembly programmes, which communicate directly with a
computer's hardware, are lengthy and complex to debug, and adding new functionality requires a
lot of time and effort.
Thompson's first high-level language was named B after the BCPL system programming
language on which it was built. Thompson rewrote B to better match the demands of the modern
time, better system hardware after Bell Labs purchased a Digital Equipment Corporation (DEC)
UNIX system model PDP-11. As a result C, the B's successor, was created. By 1973, C had
matured to the point that it could be used to rewrite the UNIX operating system.
15
Downloaded by Amala Yesupatham
Key Features of C Programming Language
o C program syntax is easy to learn and read; this makes debugging code more
accessible and faster.
o C programs are relatively short compared to other languages, which reduces the time
needed to complete them.
o C is a powerful programming language that enables developers to create sophisticated
software systems.
o The language is fast, efficient, and easy to learn, making it a popular choice for many
applications.
o C is also portable, meaning that programs written in C can be easily ported to other
platforms.
o C has been around for many years (it was first released in 1979), so many libraries
and tools are available that facilitate its use.
REAL-WORLD APPLICATIONS OF C
Use of the C programming language is not limited to the development of operating systems
and applications. It is also used in GUI development, IDE development, etc.
1. Operating Systems
2. Assemblers
3. Text Editors
4. Print Spoolers
5. Modern Programs
6. Databases
7. Utilities
16
1. Operating Systems:-
What is better than writing your own operating system? And yes, with the help of the C
programming language, you can write your own operating system. Windows Kernel, Linux Kernel
and Apple’s OS X kernel are mostly written in C.
2. GUI:-
It stands for Graphical User Interface. The C programming language also helps in
developing popular adobe softwares like Photoshop, Premier Pro, Illustrator etc.
3. Embedded Systems:-
In daily life, we use different embedded systems like coffee machines, microwaves, climate
control systems etc. These all are mostly programmed in C.
4. Database:-
5. Ease of Computation:-
6. Gaming:-
C programming is relatively faster than Java or Python. It has been used in various gaming
applications and graphics. C programming language also helps in creating many popular
childhood games like Tic-Tac-Toe, The Snake game etc.
17
Due to the fast execution and simplicity, many languages like Java, C++, Python, PHP,
PERL, JavaScript, etc were influenced by the development of C. In Python, C is used for building
standard libraries. The syntax and control structures of PERL, PHP and C++ are based upon the C
programming language.
8. Google:-
In the Google open source community, the projects are being handled by C/C++. And C/C+
+ also helped in developing google file system and chromium browser.
9. Assemblers:-
C also helped in creating various text editors like Vim, Gedit etc.
11. Drivers:-
Another application of C is to write driver softwares like Keyboard driver, Network driver,
mouse driver etc.
12. Interpreters:-
With the help of C programming language, you can create language interpreters. C helped
in developing different programming language interpreters like Python and MATLAB
interpreters etc.
18
C also helped in designing several popular compilers like Clang C, MINGW, Apple C etc.
This is one of the most popular uses of C language.
RESULT
Thus the case study was studied successfully.
19
ALGORITHM
STEP1: Start the program
STEP2: Initialize and declare variables using structure and arrays. Define the required size
of header files
STEP3: Enter the operations to perform in list as
a)Create list
b)Insert
c)Delete
d)View
STEP4: Based on the operations choosing, the list elements are structured.
STEP5: Stop the program
PROGRAM
#include<stdlib.h>
void main()
{
LIST L=NULL;
POSITION P;
int a,choice,ch,element;
clrscr();
printf("\n\n1.Create\n2.Insert\n3.Delete\n4.Display\n5.MakeEmpty\n6.Find\n 7.IsEmpty\n8.IsFull\
n9.Deletelist\n10.Exit\n");
A:
printf("\n Enter Ur Option:\t");
scanf("%d",&choice);
20
else
MakeEmpty(L);
break;
case 6:
if(L==NULL)
printf("\n Not yet created");
else
if(Isempty(L))
printf("\n List is empty");
else
{
printf("\n which element is to find:\t");
scanf("%d",&a);
P=Find(a,L);
printf("\n Element is at %d\t[0 to 4 means present]\t[5 means not present]",P);
}
break;
23
OUTPUT
1.Create
2.Insert
3.Delete
4.Display
5.MakeEmpty
6.Find
7.IsEmpty
8.IsFull
9.Deletelist
10.Exit
Enter Ur Option: 1
List is created successfully
Enter Ur Option: 2
Enter the element to insert: 300
25
Enter Ur Option: 2
Enter the element to insert: 200
Where U want to insert? 1.Front 2.Back 3.Middle ::::: 3
Enter Ur Option: 2
Enter the element to insert: 400
Where U want to insert? 1.Front 2.Back 3.Middle ::::: 2
Enter Ur Option: 2
Enter the element to insert: 500
Where U want to insert? 1.Front 2.Back 3.Middle ::::: 2
Enter Ur Option: 2
Enter the element to insert: 600
Where U want to insert? 1.Front 2.Back 3.Middle ::::: 1
List is Full
Enter Ur Option: 4
Elements present in the list are
100
200
300
400
500
26
Enter Ur Option: 6
Which element is to find: 500
Element at 4 [0 to 4 – present] [5 – not present]
Enter Ur Option: 3
Enter the element to delete: 300
Enter Ur Option: 4
Elements present in the list are:
100
200
400
500
Enter Ur Option: 8
List is not Full
Enter Ur Option: 5
Now List becomes Empty
Enter Ur Option: 9
List is Deleted
Enter Ur Option: 2
List is not yet created
27
Enter Ur Option: 10
RESULT
Thus operations on list was demonstrated using arrays successfully.
EX.NO:7(a) ARRAY IMPLEMENTATION OF STACK ADT
AIM
To write a C program to implement stack operations using array.
ALGORITHM
STEP 1: Start the program
STEP2: Define an array stack of size max = 5
STEP 3: Initialize top = -1
STEP 4: Display a menu listing stack operation
28
PROGRAM
#include <stdio.h>
#include <conio.h>
#define max 5
static int stack[max];
int top = -1;
void push(int x)
{
stack[++top] = x;
}
29
OUTPUT
STACK OPERATION
1.PUSH 2.POP 3.VIEW 4.QUIT
Enter Choice : 1
Enter Stack element : 12
STACK OPERATION
1.PUSH 2.POP 3.VIEW 4.QUIT
Enter Choice : 1
Enter Stack element : 23
STACK OPERATION
1.PUSH 2.POP 3.VIEW 4.QUIT
Enter Choice : 1
Enter Stack element : 34
STACK OPERATION
1.PUSH 2.POP 3.VIEW 4.QUIT
Enter Choice : 1
Enter Stack element : 45
32
STACK OPERATION
1.PUSH 2.POP 3.VIEW 4.QUIT
Enter Choice : 2
Popped element is 45
STACK OPERATION
1.PUSH 2.POP 3.VIEW 4.QUIT
Enter Choice : 3
Top--> 34 23
12
STACK OPERATION
1.PUSH 2.POP 3.VIEW 4.QUIT
Enter Choice : 4
ALGORITHM
STEP1: Start the program
STEP2: Define an array queue of size max = 5
STEP3: Initialize front = rear = –1
STEP4: Display a menu listing queue operation
STEP 5: Accept choice
STEP 6: If choice = 1 then
If rear < max -1
Increment rear
Store element at current position of rear
Else
34
PROGRAM
#include <stdio.h>
#include <conio.h>
#define max 5
static int queue[max];
int front = -1;
int rear = -1;
void insert(int x)
{
queue[++rear] = x;
if (front == -1)
front = 0;
}
int remove()
{
int val;
35
OUTPUT
QUEUE OPERATION
1.INSERT 2.DELETE 3.VIEW 4.QUIT
Enter Choice : 1
Enter element to be inserted : 12
QUEUE OPERATION
1.INSERT 2.DELETE 3.VIEW 4.QUIT
Enter Choice : 1
Enter element to be inserted : 23
QUEUE OPERATION
1.INSERT 2.DELETE 3.VIEW 4.QUIT
Enter Choice : 1
Enter element to be inserted : 34
QUEUE OPERATION
1.INSERT 2.DELETE 3.VIEW 4.QUIT
38
QUEUE OPERATION
1.INSERT 2.DELETE 3.VIEW 4.QUIT
Enter Choice : 1
Enter element to be inserted : 56
QUEUE OPERATION
1.INSERT 2.DELETE 3.VIEW 4.QUIT
Enter Choice : 1
Queue Full
QUEUE OPERATION
1.INSERT 2.DELETE 3.VIEW 4.QUIT
Enter Choice : 3
Front--> 12 23 34 45 56 <--Rear
39
AIM
To implement stack operations using linked list.
ALGORITHM
STEP 1: Start the program
STEP 2: Define a singly linked list node for stack
STEP 3: Create Head node
STEP 4: Display a menu listing stack operation
STEP 5: Accept choice
STEP 6: If choice = 1 then
Create a new node with data
Make new node point to first node
Make head node point to new node
Else If choice = 2 then
Make temp node point to first node
Make head node point to next of temp node
Release memory
Else If choice = 3 then
Display stack elements starting from head node till null
40
PROGRAM
#include <stdio.h>
#include <conio.h>
#include <process.h>
#include <alloc.h>
struct node
{
int label;
struct node *next;
};
main()
{
int ch = 0;
int k;
struct node *h, *temp, *head;
/* Head node construction */
head = (struct node*) malloc(sizeof(struct node));
head->next = NULL;
while(1)
{
printf("\n Stack using Linked List \n");
printf("1->Push ");
printf("2->Pop ");
printf("3->View ");
printf("4->Exit \n");
printf("Enter your choice : ");
scanf("%d", &ch);
41
OUTPUT
Stack using Linked List
1->Push 2->Pop 3->View 4->Exit
Enter your choice : 1
Enter label for new node : 23
New node added
43
AIM
To implement queue operations using linked list.
ALGORITHM
STEP 1: Start the program
STEP 2: Define a singly linked list node for stack
STEP 3: Create Head node
STEP 4: Display a menu listing stack operation
STEP 5: Accept choice
STEP 6: If choice = 1 then
Create a new node with data
Make new node point to first node
Make head node point to new node
Else If choice = 2 then
Make temp node point to first node
Make head node point to next of temp node
Release memory
Else If choice = 3 then
Display stack elements starting from head node till null
STEP 7: Stop the program
PROGRAM
#include <conio.h>
44
46
RESULT
Thus insert and delete operations of a queue was demonstrated using linked list.
47
AIM
To add any two given polynomial using linked lists.
ALGORITHM
STEP 1: Start the program
STEP 2: Create a structure for polynomial with exp and coeff terms.
STEP 3: Read the coefficient and exponent of given two polynomials p and q.
STEP 4: While p and q are not null, repeat step 4.
If powers of the two terms are equal then
Insert the sum of the terms into the sum Polynomial
Advance p and q
Else if the power of the first polynomial> power of second then
Insert the term from first polynomial into sum polynomial
Advance p
Else
Insert the term from second polynomial into sum polynomial
Advance q
STEP 5: Copy the remaining terms from the non-empty polynomial into the
Sum polynomial
STEP 6: Stop the program.
PROGRAM
#include <stdio.h>
#include <malloc.h>
#include <conio.h>
struct link
{
48
OUTPUT
Enter 1st Polynomial:
Enter coefficient: 5
Enter exponent: 2
continue(y/n): y
Enter coefficient: 4
Enter exponent: 1
continue(y/n): y
Enter coefficient: 2
Enter exponent: 0
continue(y/n): n
RESULT
Thus the polynomial operations using linked list was executed successfully and the output
was verified successfully.
ALGORITHM
53
PROGRAM
#include <stdio.h>
#include <conio.h>
#include <string.h>
#define MAX 20
int top = -1;
char stack[MAX];
char pop();
void push(char item);
int prcd(char symbol)
{
switch(symbol)
54
OUTPUT
Enter the valid infix string: (a+b*c)/(d$e)
The corresponding postfix string is: abc*+de$/
Enter the valid infix string: a*b+c*d/e
The corresponding postfix string is: ab*cd*e/+
58
RESULT
Thus the given infix expression was converted into postfix form using stack.
EX.NO:10 IMPLEMENTATION OF BINARY TREES
AIM
To insert and delete nodes in a binary tree.
ALGORITHM
STEP1: Start the program
STEP2: Create a structure with key and 2 pointer variable left and right.
STEP3: Read the node to be inserted.
If (root==NULL)
root=node
59
PROGRAM
#include <stdio.h>
#include <stdlib.h>
struct node
{
int item;
struct node* left;
struct node* right;
};
// Inorder traversal
void inorderTraversal(struct node* root)
60
OUTPUT
Traversal of the inserted binary tree
Inorder traversal
42 4 3 1 2 6 33
Preorder traversal
1 4 42 3 6 2 33
Postorder traversal
42 3 4 2 33 6 1
RESULT
Thus the implementation of binary tree was executed and the output was verified
successfully.
63
AIM
To insert and delete nodes in a binary search tree.
ALGORITHM
STEP1: Start the program
STEP2: Create a structure with key and 2 pointer variable left and right.
STEP3: Read the node to be inserted.
If (root==NULL)
root=node
else if (root->key<node->key)
root->right=NULL
else
Root->left=node
STEP4: For Deletion
if it is a leaf node
Remove immediately
Remove pointer between del node & child
if it is having one child
Remove link between del node&child
Link delnode is child with delnodes parent
If it is a node with two children
Find min value in right subtree
Copy min value to delnode place
Delete the duplicate
STEP5: Stop the program
64
OUTPUT
------- Binary Search Tree ------
1. Insert
2. Delete
3. Search
4. Get Larger Node Data
5. Get smaller Node data
-- Traversals --
6. In Order
7. Post Order
8. Pre Order
9. Exit
74
83
AIM
To perform linear search of an element on the given array.
ALGORITHM
STEP1: Start the program
STEP2: Read number of array elements n
STEP3: Read array elements Ai, i = 0,1,2,…n–1
STEP4: Read search value
STEP5: Assign 0 to found
STEP6: Check each array element against search
If Ai = search then
found = 1
Print "Element found"
Print position i
Stop
STEP7: If found = 0 then
print "Element not found"
84
PROGRAM
#include <stdio.h>
#include <conio.h>
main()
{
int a[50],i, n, val, found;
clrscr();
printf("Enter number of elements : ");
scanf("%d", &n);
printf("Enter Array Elements : \n");
for(i=0; i<n; i++)
scanf("%d", &a[i]);
printf("Enter element to locate : ");
scanf("%d", &val);
found = 0;
for(i=0; i<n; i++)
{
if (a[i] == val)
{
printf("Element found at position %d", i);
found = 1;
break;
}
}
if (found == 0)
printf("\n Element not found");
getch();
85
OUTPUT
Enter number of elements : 7
Enter Array Elements :
23 6 12 5 0 32 10
Enter element to locate : 5
Element found at position 3
86
AIM
To locate an element in a sorted array using Binary search method
ALGORITHM
STEP1: Start the program
STEP2: Read number of array elements, say n
STEP3: Create an array arr consisting n sorted elements
STEP4: Get element, say key to be located
STEP5: Assign 0 to lower and n to upper
STEP6: While (lower < upper)
Determine middle element mid = (upper+lower)/2
If key = arr[mid] then
Print mid
Stop
Else if key > arr[mid] then
lower = mid + 1
else
upper = mid – 1
STEP7: Print "Element not found"
STEP8: Stop the program
87
OUTPUT
Enter array size : 9
Elements in Sorted Order
0 2 4 6 8 10 12 14 16
Enter element to locate : 12
Located at position 6
Enter array size : 10
Elements in Sorted Order
0 2 4 6 8 10 12 14 16 18
Enter element to locate : 13
Element not found
89
ALGORITHM
STEP1: Start the program
STEP2: Read number of array elements n
STEP3: Read array elements Ai
STEP4: Sort the elements using insertion sort
In pass p, move the element in position p left until its correct place is found among the first
p + 1 elements.
Element at position p is saved in temp, and all larger elements (prior to
position p) are moved one spot to the right. Then temp is placed in the
correct spot.
STEP5: Stop the program
PROGRAM
main()
{
int i, j, k, n, temp, a[20], p=0;
printf("Enter total elements: ");
scanf("%d",&n);
printf("Enter array elements: ");
for(i=0; i<n; i++)
scanf("%d", &a[i]);
90
OUTPUT
Enter total elements: 6
Enter array elements: 34 8 64 51 32 21
After Pass 1: 8 34 64 51 32 21
After Pass 2: 8 34 64 51 32 21
After Pass 3: 8 34 51 64 32 21
After Pass 4: 8 32 34 51 64 21
After Pass 5: 8 21 32 34 51 64
Sorted List: 8 21 32 34 51 64
91
AIM
To sort an array of N numbers using Quick sort
ALGORITHM
STEP1: Start the program
STEP2: Read number of array elements n
STEP 3: Read array elements Ai
STEP 4: Select an pivot element x from Ai
STEP 5: Divide the array into 3 sequences: elements < x, x, elements > x
STEP 6: Recursively quick sort both sets (Ai < x and Ai > x)
STEP 7: Stop the program
PROGRAM
#include <stdio.h>
#include <conio.h>
void qsort(int arr[20], int fst, int last);
main()
{
int arr[30];
int i, size;
printf("Enter total no. of the elements : ");
scanf("%d", &size);
printf("Enter total %d elements : \n", size);
for(i=0; i<size; i++)
92
OUTPUT
Enter total no. of the elements : 8
Enter total 8 elements :
1
2
7
-1
0
4
-2
3
Quick sorted elements
-2 -1 0 1 2 3 4 7
RESULT
Thus an array was sorted using quick sort's divide and conquer method.
94
AIM
To sort an array of N numbers using Merge sort (Divide and Conquer method).
ALGORITHM
STEP1: Start the program
STEP2: Read number of array elements n
STEP3: Read array elements Ai
STEP4: Divide the array into sub-arrays with a set of elements
STEP5: Recursively sort the sub-arrays
STEP6: Merge the sorted sub-arrays onto a single sorted array.
STEP7: Stop the program
PROGRAM
#include<stdio.h>
void mergesort(int a[],int i,int j);
void merge(int a[],int i1,int j1,int i2,int j2);
void main()
{
int a[30],n,i;
printf("Enter no of elements:");
scanf("%d",&n);
printf("Enter array elements:");
for(i=0;i<n;i++)
scanf("%d",&a[i]);
mergesort(a,0,n-1); printf("\
nSorted array is :");
for(i=0;i<n;i++)
95
temp[k++]=a[j++];
}
while(i<=j1)
temp[k++]=a[i++];
96
OUTPUT
Enter no of elements: 5
Enter array elements: 10 7 3 6 2
RESULT
Thus array elements was sorted using merge sort's divide and conquer method.
97
ALGORITHM
Algorithm to insert a value in linear probing
Hash table is an array of size = TABLE_SIZE
Step 1: Read the value to be inserted, key
Step 2: let i = 0
Step 3: hkey = key% TABLE_SIZE
Step 4: compute the index at which the key has to be inserted in hash table
index = (hkey + i) % TABLE_SIZE
Step 5: if there is no element at that index then insert the value at index and
STOP
Step 6: If there is already an element at that index i = i+1
step 7: if i < TABLE_SIZE then go to step 4
PROGRAM
98
OUTPUT
Press 1. Insert 2. Display 3. Search 4.Exit
1
enter a value to insert into hash table 12
102
AIM
To perform the implementation of hashing using Quadratic probing method.
ALGORITHM
Algorithm to insert a value in quadratic probing
103
PROGRAM
#include <stdio.h>
#include<stdlib.h>
#define TABLE_SIZE 10
int h[TABLE_SIZE]={NULL};
void insert()
104
OUTPUT
Press 1. Insert 2. Display 3. Search 4.Exit
1
enter a value to insert into hash table 12
108
109