Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 6

JVIMS-MCA

Subject-620002(DS)
Enrolment No.:095370693035
Program:1
#include<stdio.h>

#include<conio.h>

#include<alloc.h>

struct node

int n;

struct node *link;

};

struct node *start=NULL;

void insert()

int *temp;

int ele;

temp=(struct node)malloc(sizeof(struct node));

printf("\n enter your elements:");

scanf("%d",&ele);

void dlt()

{
printf("\nEnter the element u want to delete:");

void sum()

void cnt()

void search()

void display()

void main()

int c;

clrscr();

do

printf("\n___Singly linked list___");

printf("\n\tEnter your choice:");

printf("\n\t1).Insert node...");
printf("\n\t2).Delete node...");

printf("\n\t3).Find the sum of elements...");

printf("\n\t4).Count the no. of elements...");

printf("\n\t5).Search element...");

printf("\n\t6).Display output...");

printf("\n\t7).Exit...");

switch(c)

case 1:

printf("Inserted node..");

insert();

break;

case 2:

printf("Deleted node...");

dlt();

break;

case 3:

printf("Sum of entered elements...");

sum();

break;
case 4:

printf("No. of nodes are...");

cnt();

break;

case 5:

printf("Search element..");

search();

break;

case 6:

printf("Display...");

display();

default:

printf("Invalid input");

}while(c!=6)

getch();

}
Program:2

#include<stdio.h>

#include<conio.h>

void main()

int i,n,element,k=0,size[30];

clrscr();

printf("Enter the no. of elements for linear search...:");

scanf("%d",&n);

for(i=1;i<=n;i++)

printf("\t\tEnter the elements...:",i);

scanf("%d",&size[i]);

printf("\t\tYour elements are..:");

for(i=1;i<=n;i++)

printf("\n\t\t%d",size[i]);

printf("\n\nnow enter the element which u want to find:");

scanf("%d",&element);
for(i=1;i<=n;i++)

if(element==size[i])

printf("\n\n\tElement found..");

k=1;

if(k==0)

printf("\n\n\tElement is not found..");

getch();

You might also like