#include<stdio.h>
void main()
{
int ch,i,top=0,n=5,j,s[5];
cho:
clrscr();
printf("\n\n\n\n\t\t----------------stack--------------- \n");
printf("\t\tPress 1 for Adding value.\n\n");
printf("\t\tpress 2 for Delete the value.\n\n");
printf("\t\tPress 3 for Display the value.\n\n");
printf("\t\tPress 4 for Find the value.\n\n");
printf("\t\tPress 5 for Change the value.\n\n");
printf("\t\tPress 6 for exit .\n\n");
scanf("%d",&ch);
switch(ch)
{
case 1:
printf("\t\tYour choice is 1 for Entering the value.\n\n");
if(top>=5)
{
printf("Stack is over flow.\n");
}
else if(top<=n)
{
top=top+1;
printf("enter your value.");
scanf("%d",&s[top]);
}
getch();
goto cho;
case 2:
printf("\t\tYour choice is 2 for Delete the value.\n\n");
if(top==0)
{
printf("\t\tstack have no element.\n\n");
}
else
top=top-1;
goto cho;
case 3:
printf("\t\tYour choice is 3 for Display element in stack.\n \n");
if(top==0)
{
printf("Stack have no element.");
}
else
{
for(i=1;i<=top;i++)
{
printf("Element %d",s[i]);
printf("\n");
}
}
getch();
goto cho;
case 4:
printf("\t\tYour choice is 4 for Find the element.\n\n");
if(top==0)
{
printf("Stack have no element");
}
else
{
printf("Enter number of Element position.");
scanf("%d",&j);
printf("%d",s[j]);
j=0;
}
break;
case 5:
printf("\t\tYour choice is 5 for Change element value.\n\n");
break;
case 6:
printf("\t\tYour choise is 6 to exit programm \n\n");
break;
default:
printf("\t\tYour choice is invalid.\n\n");
printf("press any key to go back main menu.\n\n");
getch();
goto cho;
}
getch();
}
void main()
{
int ch,i,top=0,n=5,j,s[5];
cho:
clrscr();
printf("\n\n\n\n\t\t----------------stack--------------- \n");
printf("\t\tPress 1 for Adding value.\n\n");
printf("\t\tpress 2 for Delete the value.\n\n");
printf("\t\tPress 3 for Display the value.\n\n");
printf("\t\tPress 4 for Find the value.\n\n");
printf("\t\tPress 5 for Change the value.\n\n");
printf("\t\tPress 6 for exit .\n\n");
scanf("%d",&ch);
switch(ch)
{
case 1:
printf("\t\tYour choice is 1 for Entering the value.\n\n");
if(top>=5)
{
printf("Stack is over flow.\n");
}
else if(top<=n)
{
top=top+1;
printf("enter your value.");
scanf("%d",&s[top]);
}
getch();
goto cho;
case 2:
printf("\t\tYour choice is 2 for Delete the value.\n\n");
if(top==0)
{
printf("\t\tstack have no element.\n\n");
}
else
top=top-1;
goto cho;
case 3:
printf("\t\tYour choice is 3 for Display element in stack.\n \n");
if(top==0)
{
printf("Stack have no element.");
}
else
{
for(i=1;i<=top;i++)
{
printf("Element %d",s[i]);
printf("\n");
}
}
getch();
goto cho;
case 4:
printf("\t\tYour choice is 4 for Find the element.\n\n");
if(top==0)
{
printf("Stack have no element");
}
else
{
printf("Enter number of Element position.");
scanf("%d",&j);
printf("%d",s[j]);
j=0;
}
break;
case 5:
printf("\t\tYour choice is 5 for Change element value.\n\n");
break;
case 6:
printf("\t\tYour choise is 6 to exit programm \n\n");
break;
default:
printf("\t\tYour choice is invalid.\n\n");
printf("press any key to go back main menu.\n\n");
getch();
goto cho;
}
getch();
}
No comments:
Post a Comment