This website uses cookies to ensure you have the best experience. Learn more

Stacks In C++ (This Stack Is Using Linked Structure)

1095 words - 4 pages

/********************************************************************* file: stack.cpp ** desc: C++ assignment ** Author: Syed R Fayyaz ** Date: 03-30-2004 ** ** Comment: To introduce with the concept of PUSH, pop and display **with stacks. Stack is implemented using linked structure**which is little difficult from array ADT's but good for **polishing programming skills. *********************************************************************///preprocessor Directives#include#include#include// global declarations//STRUCTURE DEFINITION/* This ADT "stack_node" includes 2 parts one is data andother one is nodeptr (which sounds like pointer and itis), so data stores the value and nodeptr records theaddresses!*/struct stack_node // node for item on stack{int data;struct stack_node *nodeptr;};/*I delared the top ponter as a global one becauseI am having problem passing the pointer by reference!It is always being passed as a paremeter so the changesare not permanent. */// Start with top of stack set to NULL// pointer to top of stackstack_node *top_ptr;//SOMETHING ABOUT THE PROGRAM MENU/*Program menu which is always on line 20 can be done easily by usinggoto xy function ,which is not considered very good programming intoday's market, To prevent Goto xy in all these functions I ampassing a variable name "Line_break_info" this is the key variablefrom which i am keeping track of Line breaks used and then to printmenu always at line 20. Variable is passed by reference thats whyeach function adds +1 to the line_break_info variable to keep trackhow many line breaks it is using*///main screen mesagevoid greetings(int &line_break_info);//Top header is the heading at very top of the screenvoid top_header(int &line_break_info);//This function handles the choice entered by the uservoid handle_choice(int choice,int &line_break_info);//To push the value into the stackvoid push(int &line_break_info);//Displays the stackvoid display_stack(int &line_break_info);//Dsiplays menu at very bottom of screenvoid menu(int &line_break_info,int &exit);//Popping the value from stack in other words//deletes the value from stack (only top one)int pop(int &line_break_info);//this is a exit message after hitting option 4void exit_greetings(int &line_break_info);//I thought it would be a good excercise to delete the//stack and release the memory before exiting from the//program. this function deletes the dynamically created//stacks.void delete_stack(int &line_break_info);//*************************// main function starting *//*************************int main(){//local identifiersint line_break_info=0,exit=0;// no stack exists.top_ptr = NULL;//Prints greetings on the main screengreetings(line_break_info);//do while loop starts will keep going until user exitsdo{//display menu and ask for choicemenu(line_break_info,exit);}while(exit==0);//if user choose to exit display exit messageexit_greetings(line_break_info);if(top_ptr != NULL){// If stack isn't...

Find Another Essay On Stacks in C++ (this stack is using linked structure)

This essay is about thte link between type two diabetes and obesity. And how they are linked

1168 words - 5 pages , and other foodstuffs into essential energy. This condition is commonly referred to as insulin resistance. When this malfunction occurs, the result is a buildup of glucose in the blood that can pose serious health problems.The disease has three variations: gestational diabetes, occurring during pregnancy and usually disappearing afterward; type 1 diabetes, which occurs in young children and adolescents and is sometimes referred to as juvenile-onset

The Structure of Power in American Society by C. Wright Mills

967 words - 4 pages individuals and the social structures around them and also the functions that these social institutions perform in society. Anthropology: Anthropology is the study of humans through the ages. It aims to understand different cultures and practices that have existed from the origins of mankind as well. It differs from sociology in that it takes into account humans and cultures that no longer exist. The Structure of Power in American Society: C. Wright

"The Stonhenge" This is about the stone hege in England and how long it took to build this structure and different stagesit went through

856 words - 3 pages The Stonehenge is one of England's artifacts. There are very many different types of stories pertaining to this great structure. The most common reason is that it was used for religious purposes. It was said to be a place of worship of ancient earth structures. This sight has very many different reasons but its soul purpose in today's time has been its influence on today's generation. It has inspired countless generations to learn and try to

Parathormone Report (What it is, the role in the body, disorders linked to it)

571 words - 2 pages Parathormone (PTH) is a polypeptide of 84 amino acids that is produced and secreted by parathyroid chief cells. PTH regulates the concentration of calcium ions (Ca2+) in the blood, this is important because Ca2+ is need for proper muscle and nerve function. Low calcium blood levels (hypocalcemia) cause muscle spasms, tetany and cardiac problems. PTH also regulates blood phosphate and magnesium levels. High blood calcium levels (hypercalcemia

This is a report on the importance of using a saftey belt. I handed this in for my health class and rceived a 100

601 words - 2 pages Safety Belt ReportSeat belts and child safety seats help prevent injury five different ways. By: Preventing ejection, shifting crash forces to the strongest parts of the body's structure, spreading forces over a wide area of the body, allowing the body to slow down gradually, and Protecting the head and spinal cord. Safety belts are the most effective means of saving lives and reducing serious injuries in traffic crashes. They're also the law

Using animals in research is BAD!!

681 words - 3 pages highest dosage groups experience severe abdominal pain, diarrhea, convulsions, seizures, paralysis, and/or bleeding from the nose, mouth, and genitals before they ultimately die. Another type of test performed is the eye-and-skin irritation/ corrosion test. This test is called the Draize and dates back to the 1940’s. The test subject is usually a rabbit. The rabbit is immobilized in full body restraints while the substance is dripped or smeared in

(Shakespeare's Othello) How important do you think Venice is, in the play Othello? The last paprgraph certainly needs work. I wrote this last year, and received a C for it, which is mediocre

519 words - 2 pages How important do you think Venice is in the play Othello?The first three scenes of Othello by William Shakespeare take place in Venice. These first few scenes set the pace of the whole play; therefore they hold the key to the importance of Venice in the play Othello.The play opens in mid conversation, under the cover of nightfall. This indicates that in Venice there is some underhanded work taking place. It is in fact two officers of the

Pyramid of Links: This is a C&D Essay about Friends and the different categories of relationships that exist

936 words - 4 pages close bond back in the years. Another example is the love that I had with a person that is not in my family. She was my girlfriend whom I had a special feeling for. The feeling was different from other friendships. I missed my girlfriend when she was not around, and she liked to spend a lot of time talking on the phone with me whenever I was not around. This was a very special kind of relationship.In conclusion, most of the friends that I have made

"Psychology and Religion" How is psychology present in religion? How might some dangerous behavior be linked with religious beliefs? Is religion useful or detrimental to society?

1110 words - 4 pages I find religion to be a fascinating subject. I think that there are many psychological aspects to all religions. This research paper is about relationships between religion and psychology and some of religion's therefore-potential dangers.William James, former President of the American Psychological Association was interested in religious phenomena and attempted to understand religious phenomena experienced on the individual level. He wrote a

Oral Interpretation: This is an interpretation using the book "On the road" by Jack kerouac

742 words - 3 pages That voice in the back of your head, does it drive you insane or have you come to control and silence it? Jack Kerouac didn't believe in silence of the mind. He stayed true to his own opinions, and didn't buy into all of the bull crap everyone else gets sucked into. He knew what reality meant to him, and that all that really mattered. On The Road is not considered the novel of the century only by critics, but also anyone who comes across his

This essay discusses the changes in the Irish Family structure in the last decade

3046 words - 12 pages productive and educational responsibilities. The family became an emotional and developmental centre, rather than an economic entity. Pre-industrial families were very close in that they provided the home, the workplace and the love and care within themselves to provide for every member of that family.The greatest challenge families face is change and, if anything the pace of change has accelerated over the past 10 years. This is particularly true

Similar Essays

What Is Capitalism?, This Essay Defines Capitalism By Using Examples Written In Essay Form

1058 words - 4 pages who produce less receive less and those who produced more, receive more. Someone can neither demand more than he deserves because he is full of "greed", or demand less than he deserves, because he feels need. All he can demand is what the market will offer him. The name of this principle is justice; the judge in all such cases being the marketplace. What about those who demand production for use as opposed to production for profit? Mean is the

The Essay Tittle Is 'leadership'. Question Given Is: Describe A Organisational Process In A Company, Using A Example And A Structure

2086 words - 8 pages readiness to follow will improve performance and retain employees.1. IntroductionThe traditional directive style of a leader on "a rearing white horse crying - Follow me!"(Manz & Henry) has diminished in recent years in McDonald's. Even though this directive style of leadership has made McDonald's one of the most successful companies, it is tired and old fashioned. With both theories being quite similar, the report will look into Situation

“The Competitive Position Of A Company Is Determined By The Industry Structure In Which It Competes.” Critically Evaluate This Statement.

4509 words - 18 pages this disease and generic companies in Greece may try to produce a similar vaccine to minimize the profit of Novartis and Sanofi-Aventis and to increase competition (Business Monitor International, 2009).Part 2: Industry structure and competitive position of a companyCompetition is one of the most important issues that companies within an industry have to face. The competitive position of a company indicates the position that this company has in

This Essay Is About Hopper, And How His Works Are Linked With Psychology, Particularly With The Theories Of Freud

618 words - 2 pages repressed memory that violently breaches the tranqulity of the present. She states that any image can be related to an ominous and distorted memory, hence allowing it to surface.The first example is "House by the Railroad" by Hopper. It was commonly described as a nostolgic look back to simpler times. In opposition to this view, Iverson states that in our rootless society, an image such as this is a catalyst for repressed memory. She explains that