C# Sharp Stack: Exercises, Practice, Solution
C# Stack [27 exercises with solution]
[An editor is available at the bottom of the page to write and execute the scripts. Go to the editor]
1. Write a C# program to implement a stack with push and pop operations. Find the top element of the stack and check if the stack is empty or not.
Click me to see the sample solution
2. Write a C# program to sort the elements of a given stack in descending order.
Click me to see the sample solution
3. Write a C# program to sort the elements of a given stack in ascending order.
Click me to see the sample solution
4. Write a C# program to reverse the elements of a given stack.
Click me to see the sample solution
5. Write a C# program to find the maximum element in a stack.
Click me to see the sample solution
6. Write a C# program to find the minimum element in a stack.
Click me to see the sample solution
7. Write a C# program to remove all the elements from a given stack.
Click me to see the sample solution
8. Write a C# program to remove specified element from a given stack.
Click me to see the sample solution
9. Write a C# program to count all the elements in a given stack.
Click me to see the sample solution
10. Write a C# program to count specified element in a given stack.
Click me to see the sample solution
11. Write a C# program to implement a stack that checks if a given element is present or not in the stack.
Click me to see the sample solution
12. Write a C# program to remove duplicates from a given stack.
Click me to see the sample solution
13. Write a C# program to find the top and bottom elements of a given stack.
Click me to see the sample solution
14. Write a C# program to rotate the stack elements to the left direction.
Click me to see the sample solution
15. Write a C# program to swap the top two elements of a given stack.
Click me to see the sample solution
16. Write a C# program to get the nth element from the top of the stack.
Click me to see the sample solution
17. Write a C# program to merge two stacks into one.
Click me to see the sample solution
18. Write a C# program that implements a stack and checks if a stack is a subset of another stack.
Click me to see the sample solution
19. Write a C# program that implements a stack and checks if two stacks are equal.
Click me to see the sample solution
20. Write a C# program that implements a stack and finds common elements between two stacks.
Click me to see the sample solution
21. Write a C# program that implements a stack and find elements that are in the first stack but not in the second stack.
Click me to see the sample solution
22. Write a C# program that implements a stack and creates a new stack that contains all elements from both stacks without duplicates.
Click me to see the sample solution
23. Write a C# program that implements a stack and creates a new stack that contains only elements that are in either the first or the second stack, but not in both.
Click me to see the sample solution
24. Write a C# program that implements a stack and creates a new stack from a portion of the original stack.
Click me to see the sample solution
25. Write a C# program that implements a stack and checks if all elements of the stack satisfy a condition.
Click me to see the sample solution
26. Write a C# program that implements a stack and checks if at least one element of the stack satisfies a condition.
Click me to see the sample solution
27. Write a C# program that implements a stack and create a new stack by removing elements that do not satisfy a condition.
Click me to see the sample solution
C# Sharp Code Editor:
More to Come !
Do not submit any solution of the above exercises at here, if you want to contribute go to the appropriate exercise page.
It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.
https://www.w3resource.com/csharp-exercises/stack/index.php
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics