Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Stack Program in Java #42

Open
muhtalhakhan opened this issue Oct 18, 2023 · 6 comments
Open

Add Stack Program in Java #42

muhtalhakhan opened this issue Oct 18, 2023 · 6 comments
Assignees
Labels
good first issue Good for newcomers hacktoberfest Helps to differentiate Hacktoberfest PRs hacktoberfest-accepted Helps to achieve Hacktoberfest PRs

Comments

@muhtalhakhan
Copy link
Owner

No description provided.

@muhtalhakhan muhtalhakhan added good first issue Good for newcomers hacktoberfest Helps to differentiate Hacktoberfest PRs hacktoberfest-accepted Helps to achieve Hacktoberfest PRs labels Oct 18, 2023
@MuneebNazir
Copy link
Contributor

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

@Mani1881
Copy link
Contributor

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 <stdio.h>
#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
Copy link

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

@imdaxsh
Copy link

imdaxsh commented Oct 28, 2023

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

@mdsahilnoob
Copy link
Contributor

@muhtalhakhan can you assign this issue to me?

@muhtalhakhan
Copy link
Owner Author

multiple programs are welcomed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers hacktoberfest Helps to differentiate Hacktoberfest PRs hacktoberfest-accepted Helps to achieve Hacktoberfest PRs
Projects
None yet
Development

No branches or pull requests

6 participants