C Program to Implement Stack using Two Queues

This is a C Program to implement stack using queue. The idea is pretty simple. We start with an empty queue. For the push operation we simply insert the value to be pushed into the queue. The pop operation needs some manipulation. When we need to pop from the stack (simulated with a queue), first … Read more

advertisement

C Program to Implement Stack

Problem Description Write a C program to implement the stack data structure and display the stack. Stack Data Structure: Stack is a linear data structure to store the data item in LIFO (Last In First Out) principle. That means the item inserted at the end comes first out of the stack. It has only one … Read more

advertisement

C Program to Implement Two Stacks in a Single Array

This C Program Implements two Stacks using a Single Array & Check for Overflow & Underflow. A Stack is a linear data structure in which a data item is inserted and deleted at one record. A stack is called a Last In First Out (LIFO) structure. Because the data item inserted last is the data … Read more

advertisement

C Program to Check String is Palindrome using Stack

This is a C Program to identify whether the string is palindrome or not using stack. Problem Description This program takes a string and checks whether the string is palindrome or not using stack. Problem Solution 1. Take a string as input. 2. Store the string in the stack array. 3. Check whether the string … Read more

advertisement

C Program to Illustrate Stack Operations using MACROS

This is a C Program to Illustrate Stack Operations using MACROS. Problem Description This program illustrates the stack operations using MACROS. Problem Solution 1. Use #define function to define the macros. 2. Define separate functions for the operations like push, pop, display etc. 3. Use switch statement to access these functions. Program/Source Code Here is … Read more

advertisement

C Program to Implement Stack Operations using Dynamic Memory Allocation

This is a C Program to Implement Stack Operations using Dynamic Memory Allocation. Problem Description This program implements stack operations using dynamic memory allocation. Problem Solution 1. Use malloc function to allocate memory. 2. Define separate functions for the operations like push, pop and display. 3. Use switch statement to access these functions. Program/Source Code … Read more

advertisement

C Program to Check Expression is Correctly Parenthesized

This is a C Program to check if expression is correctly parenthesized. Problem Description This program takes a expression as input and checks if the expression is correctly parenthesized. Problem Solution 1. Take a expression as input and store it in the array. 2. Check for the “(” and “)” in the expression. 3. If … Read more

advertisement

C Program to Reverse a Stack without Recursion

This C program, using iteration, reverses a stack content. Stack here is represented using a linked list. A linked list is an ordered set of data elements, each containing a link to its successor. Here is the source code of the C program to display a linked list in reverse. The C program is successfully … Read more

advertisement

C Program for Tower of Hanoi

Problem Description Write a C program to solve the Tower of Hanoi Problem. What is the Tower of Hanoi? The Tower of Hanoi is a mathematical game or puzzle consisting of 3 rods or pegs and ‘n’ disks of varying diameters. It starts with all disks stacked on one rod in decreasing order. The objective … Read more

advertisement

C Program to Reverse a Stack using Recursion

This C program, using recursion, reverses a stack content. Stack here is represented using a linked list. A linked list is an ordered set of data elements, each containing a link to its successor. Here is the source code of the C program to display a linked list in reverse. The C program is successfully … Read more

advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.