0% found this document useful (0 votes)
5 views2 pages

57 Assignment 3

The document outlines an assignment for implementing a stack in C programming, authored by Shreeya Pravin Joshi. It includes code for stack operations such as push, pop, and display, along with a main function to initialize the stack size. The code contains some errors and requires corrections for proper functionality.

Uploaded by

anishwarushe0725
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views2 pages

57 Assignment 3

The document outlines an assignment for implementing a stack in C programming, authored by Shreeya Pravin Joshi. It includes code for stack operations such as push, pop, and display, along with a main function to initialize the stack size. The code contains some errors and requires corrections for proper functionality.

Uploaded by

anishwarushe0725
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

ASSIGNMENT 3

stack implementaton
name -SHREEYA PRAVIN JOSHI
roll no:-57
prn-2122000723

#include <stdio.h>
int stack [100],coice , n , top , x,i;
void push (void );
void pop(void);
void dispaly(void);
do
{
printf("enter choice of operation :");
scanf ("%d",&choice);
switch (choice ){
case 1:
pop();
break;
case 2:
push ();
break;
case 3:
display();
case 4:
printf("exit from stack ");
break;
default :
print("enter valid choice");
}
}while (choice!=4);
void push(){
if(top>=n-1){
printf("stack is full");
}else{
printf("enter element to be push:");
scanf ("%d",&n);
top++;
stack[top]=x;
}
}
void pop(){
if (top<=-1){
printf ("stack is empty");
}else{
printf("enter element to be push:");
scanf ("%d",&n);
top--;
stack[top]=x;
}
}
void display(){
if (top>=0){
printf("elements in stack are:");
for (i=top;i>=0;i--){
printf ("%d\n",stack[i]);

}
}else{
printf("stack is empty");
}
}
int main(){
top=-1;
printf("enter the size of stack[max=100:]");
scanf("%d" ,&n);

You might also like