BZU PAGES: Find Presentations, Reports, Student's Assignments and Daily Discussion; Bahauddin Zakariya University Multan Right Header

Register FAQ Community Calendar New Posts Navbar Right Corner
HOME BZU Mail Box Online Games Radio and TV Cricket All Albums
Go Back   BZU PAGES: Find Presentations, Reports, Student's Assignments and Daily Discussion; Bahauddin Zakariya University Multan > Institute of Computing > Bachelor of Science in Information Technology > BsIT 3rd Semester > Data Structure

Data Structure Lectures by Sir Ahsan..


 
 
Thread Tools Search this Thread Rating: Thread Rating: 1 votes, 5.00 average. Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 16-09-2008, 11:14 PM
shmsa's Avatar
Grown up punk

 
Join Date: Oct 2007
Location: Muslim Town Multan
Posts: 195
Contact Number: 0322-6196713
Program / Discipline: BSIT
Class Roll Number: 07-22
shmsa is a jewel in the roughshmsa is a jewel in the roughshmsa is a jewel in the roughshmsa is a jewel in the rough
lectures Program of STACK

Code:
#include<iostream.h>
void push(int stack[], int &top)
{
 int element;
if (top==4)
cout<<""<<endl;
else
{
 cout<<"enter element to puch in stack===="<<endl;
 cin>>element;
top++;
stack[top]=element;
}
}
void pop(int stack[],int &top)
{
 if (top==-1)
  cout<<"stack is empty"<<endl;
 else
 {
 cout<<"poped element of stack is===="<<stack[top]<<endl;
 top--;
 }
}
void show(int stack[], int &top)
{
 for (int i=top;i>=0;i--)
  cout<<stack[i]<<endl;
}
void main()
{
 char opt='y';
 int stack[5];
 int top=-1;
 while (opt=='y')
 {
  cout<<"enter 'P' for PUSH"<<endl<<"enter 'O' for POP"<<endl<<"enter 'S' for SHOW"<<endl;
  cin>>opt;
  if (opt=='p')
   push(stack,top);
  else
   if (opt=='o')
    pop(stack,top);
   else
   if (opt=='s')
    show(stack,top);
   else
    cout<<"you have entered werong character"<<endl;
   cout<<"DO you want more y/n"<<endl;
   cin>>opt;
 }//end of while
}// end of main

Reply With Quote
 

Tags
c++, lectures, program, stack


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
SS7 + Stack bonfire ATM Systems in Telecommunications 0 26-03-2011 01:26 AM
SS7 Protocol Stack bonfire Digital Telephony 0 10-12-2010 04:45 PM

Best view in Firefox
Almuslimeen.info | BZU Multan | Dedicated server hosting
Note: All trademarks and copyrights held by respective owners. We will take action against any copyright violation if it is proved to us.

All times are GMT +5. The time now is 03:45 AM.
Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.