NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

#include<stdio.h>
#include<stdlib.h>
void push();
void pop();
void transverse();
int peek(void);
int p;
struct node
{
int data;
struct node *link;
};
struct node *top=NULL;
void main()
{
int ch;
while(1)
{
printf("stack operations using linked list :n");
printf("1.push n");
printf("2.pop n");
printf("3.transverse n");
printf("4.peek n");
printf("5.exit n");
printf("enter your choice");
scanf("%d",&ch);
switch (ch)
{
case 1:push();
break;
case 2:pop();
break;
case 3:transverse();
break;
case 4:p=peek();
printf("the value of read %d n ",p);
break;
case 5:exit(1);
default:printf("invalid choice");
}
}
}
void push()
{
struct node *temp;
temp=(struct node*)malloc(sizeof(struct node));
printf("enter the data");
scanf("%d",&temp->data);
temp->link=top;
top=temp;
}
void pop()
{
struct node* temp;
if(top==NULL)
{
printf("no elements or nodes in the stack to delete n");
}
else
{
temp=top;
printf("element %d",temp->data);
top=top->link;
temp->link=NULL;
free(temp);
}
}
void transverse()
{
struct node* temp;
if(top==NULL)
{
printf("stack is empty");
}
else
{
temp=top;
while(temp!=NULL)
{
printf("%d n",temp->data);
temp=temp->link;
}
}
}
int peek()
{
if(top==NULL)
{
printf("no nodes or elements to display");
}
else
{
p=top->data;
return(p);
}
}

     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.