muhtalhakhan / Hacktoberfest2023

Hacktoberfest 2023 🧑🏻‍💻 OPEN FIRST Pull Request 🎉
https://www.hacktoberfest.com
GNU General Public License v3.0
13 stars 90 forks source link

Add Stack Program in Java #42

Open muhtalhakhan opened 9 months ago

MuneebNazir commented 9 months ago

Hey, I'm working on this program. Please assign this issue to me!

Mani1881 commented 9 months ago

hey @muhtalhakhan can u assign this issue to me .This is my code in c and I can write this code in java also.

include

define n 5

int top=-1; int stack[n]; void push(); void pop(); void peek(); void display(); int main() { int c,k; while(1){ printf(" 1:push\n 2:pop\n 3: peek\n 4: display\n Enter your choice: "); scanf("%d",&c); switch(c){ case 1: push(); break; case 2: pop(); break;
case 3: peek(); break; case 4:display(); break; default: printf("Invalid input");
} printf("Enter 1 to continue:"); scanf("%d",&k); if(k==0){ break; }

} } void push() { int x; printf("enter data:"); scanf("%d",&x); if(top==n-1) printf("stack overflow\n"); else { top++; stack[top]=x; } } void pop(){ // int k; if(top==-1) printf("stack underflow\n"); else {

    printf(" popped out element is: %d\n ",stack[top]);

//stack[top]=k; top--;

}

} void peek(){ if(top==-1) printf("stack is empty\n"); else{ printf(" peek element is : %d\n",stack[top]); top--; } } void display(){ if(top==-1) printf("stack is empty\n"); else{ for(int i=top;i>=0;i--) printf(" display elements are: %d\n",stack[i]); } }

Shrilatha-Bhandarkar commented 9 months ago

Hey, I've worked on this. Can you assign this to me!

imdarshansingh commented 9 months ago

is anyone working or can you assign this to me , i can provide you some good java problems

mdsahilnoob commented 9 months ago

@muhtalhakhan can you assign this issue to me?

muhtalhakhan commented 9 months ago

multiple programs are welcomed