OLiSwEll

Sharing is My Style

Search This Blog

Showing posts with label mca2. Show all posts
Showing posts with label mca2. Show all posts

STAKLINK

/*  Write a Program to perform the following operation stack using linklist. */
/* PUSH, POP, ISEMPTY, ISFULL, PEEP */
struct list
{
int info;
struct list *next;
}*start,*q,*node,*p;
#define max 4
void push();
void pop();
int isempty();
int isfull();
void peep();
void disp();
int top=-1,stack[max];
void main()
{

int ret,s1,choice;
clrscr();

start = '\0';

do
{
printf("\n\n1 : Push element in Stack.\n");
printf("2 : Pop an element from stack.\n");
printf("3 : Peep an element into stack.\n");
printf("4 : Exit from Program.\n");
printf("Enter your choice : ");
scanf("%d",&choice);

switch(choice)
{
case 1:
ret = isfull();
if(ret!=1)
push();
disp();
break;
case 2:
ret = isempty();
if(ret != 1)
pop();
disp();
break;
case 3:
ret = isempty();
if(ret != 1)
peep();
disp();
break;
case 4:
exit();
default :
printf("\n\n\t\t######## INVALID CHOICE ##########\n\n");
}

}while(s1);

}



int isfull()
{
if(top == max)
{
printf("\n\n\t\t####### STCK IS OVERFLOW #########\n\n");
return 1;
}
else
return 0;
}


int isempty()
{
if(top == -1)
{
printf("\n\n\t\t####### STCK IS UNDERFLOW #########\n\n");
return 1;
}
else
return 0;
}

void push()
{
int item;
printf("\nEnter an Integer value : ");
scanf("%d",&item);
top = top + 1;

node = (struct list *)malloc(sizeof(struct list));
node->info = item;
node->next = '\0';
p = start;

if (start == '\0')
start = node;
else
{
while(p->next != '\0')
p = p->next;
p->next = node;
}

}

void pop()
{
int item;
q = start;
p = start->next;
while(p->next!='\0')
{
p = p->next;
q = q->next;
}
item = p->info;

if(p==start)
start = '\0';

q->next='\0';
top = top -1;
printf("\n\n\t\t%d is deleted\n",item);
}


void peep()
{
int item,q;
printf("\n\nEnter position : ");
scanf("%d",&q);
p = start;

while(q<=top)
{
p = p->next;
q++;
}

printf("\n\nYour selected Element is %d ",p->info);
}

void disp()
{

p = start;
printf("\n\nStack Contains : ");

while(p!='\0')
{
printf("%d ",p->info);
p = p->next;
}
}


recursive

void main(int n)
{
printf("%d ",n);
n++;
if(n>100)
exit(getch());
main(n);
}

STAARRAY

/*  Write a Program to perform the following operation stack using array. */
/* PUSH, POP, ISEMPTY, ISFULL, PEEP */
#define max 4
void push();
void pop();
int isempty();
int isfull();
void peep();
void disp();
int top=-1,stack[max];
void main()
{
int ret,s1,choice;
clrscr();
do
{
printf("\n\n1 : Push element in Stack.\n");
printf("2 : Pop an element from stack.\n");
printf("3 : Peep an element into stack.\n");
printf("4 : Exit from Program.\n");
printf("Enter your choice : ");
scanf("%d",&choice);

switch(choice)
{
case 1:
ret = isfull();
if(ret!=1)
push();
disp();
break;
case 2:
ret = isempty();
if(ret != 1)
pop();
disp();
break;
case 3:
ret = isempty();
if(ret != 1)
peep();
disp();
break;
case 4:
exit();
default :
printf("\n\n\t\t######## INVALID CHOICE ##########\n\n");
}

}while(s1);

}



int isfull()
{
if(top == max)
{
printf("\n\n\t\t####### STCK IS OVERFLOW #########\n\n");
return 1;
}
else
return 0;
}


int isempty()
{
if(top == -1)
{
printf("\n\n\t\t####### STCK IS UNDERFLOW #########\n\n");
return 1;
}
else
return 0;
}

void push()
{
int item;
printf("\nEnter an Integer value : ");
scanf("%d",&item);
top = top + 1;
stack[top] = item;
}

void pop()
{
int item;
item = stack[top];
top = top -1;
printf("\n\n\t\t%d is deleted\n",item);
}


void peep()
{
int item,p;
printf("\n\nEnter position : ");
scanf("%d",&p);
printf("\n\nYour selected Element is %d ",stack[top-p+1]);
}

void disp()
{
int i;
printf("\n\nStack Contains : ");
for(i=0;i<=top;i++)
printf("%d ",stack[i]);
}



620001 Data Structures (DS)


Full DS by keval.rar
Shared By:Keval Nagaria(JVIMS MCA Jamnagar)


Data Structure By Hiren Vyas.rar
shared by : Hiren Vyas

Objective Questions With Key.pdf
shared by : Vipul Joshi (SVICS - KADI)

ds question bank.rar
shared by : Sandip Patel (ldrp)

mca Sem 2

GUJARAT TECHNOLOGICAL UNIVERSITY
MASTER OF COMPUTER APPLICATION
Proposed Subjects and Teaching SchemeSemester-II
SubjectCode
Subject
620001Data Structures (DS)
620002Programming Skills – II (DS)
620003Object Oriented Concepts & Programming (OOCP)
620004Programming Skills – III (OOCP)
620005Computer Oriented Numerical Methods
620006Database Management Systems – II
620007Theory of Computation
620008620008 - Communication Skills (CS)

Cool exam papers collection...

Syllabuss E-books Collection Free Download
Related Posts Plugin for WordPress, Blogger...

Subscribe via email

Enter your email address:

Delivered by FeedBurner

Followers

Infolinks In Text Ads


Bloggers - Meet Millions of Bloggers

Traker

eXTReMe Tracker

online

PageRank Entertainment
Mobilt Bredband Guiden Submit Blog & RSS Feeds