bsc

Comprehensive codebase and cou...
Log | Files | Refs | Activity | README | LICENSE

commit 9badca50c6ed07c129b6a7f1cf99675a6c6ee445
parent 0d36f528407da0d13edab1304dc38e2c93fec7bb
Author: Amit Dutta <mail@amit.is-a.dev>
Date:   Fri,  7 Aug 2026 20:58:16 +0530

Merge pull request #29 from notamitgamer/edit-20260807-205726

some practice
Diffstat:
Mmd.py | 4++--
Asemester_2/eduincs/pgrm_016.cpp | 93+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 95 insertions(+), 2 deletions(-)

diff --git a/md.py b/md.py @@ -375,9 +375,9 @@ def build_md(filename, lang_label, fence_lang, author, date, repo, license_str, meta_parts = [] if author: - meta_parts.append(f"Author — {format_author_html(author)}") + meta_parts.append(f"● Author - {format_author_html(author)}") if date: - meta_parts.append(f"Updated {esc_html(date)}") + meta_parts.append(f"Updated - {esc_html(date)}") if meta_parts: body += [ diff --git a/semester_2/eduincs/pgrm_016.cpp b/semester_2/eduincs/pgrm_016.cpp @@ -0,0 +1,92 @@ +/* + * Author: Amit Dutta <amitdutta4255@gmail.com> | Date: 07 Aug 2026 + * Repo: https://github.com/notamitgamer/bsc + * License: MIT + */ + +/* Write a program in c++ to implement stack using a class stack with number variables, functions, constructor, destructor. */ + +#include<iostream> +using namespace std; + +class stack { +private: + int size; + int top; + int *st; + +public: + stack(int n); + ~stack(); + void push(int val); + int pop(); + int isFull(); + int isEmpty(); + void display(); +}; + +stack::stack(int n) { + size = n; + top = -1; + st = new int[size]; +} + +stack::~stack() { + delete[] st; +} + +void stack::push(int val) { + if(isFull()) + cout << "Stack is full, insertion not possible.\n"; + else { + st[++top] = val; + cout << val << " added to the stack.\n"; + } +} + +int stack::pop() { + if(isEmpty()) { + cout << "Stack is empty, deletion not possible.\n"; + return -1; + } + else + return st[top--]; +} + +int stack::isFull() { + if(top == size - 1) + return 1; + else + return 0; +} + +int stack::isEmpty() { + if(top == -1) + return 1; + else + return 0; +} + +void stack::display() { + cout << "\nStack elements are: "; + for(int i = top; i >= 0; i--) + cout << st[i] << " "; + cout << endl; +} + +int main() { + stack obj(3); + obj.push(10); + obj.push(15); + obj.push(19); + obj.push(20); // trying to overflow + cout << "\n== After pushing all element =="; + obj.display(); + cout << "\nPopped element is: " << obj.pop(); + cout << "\nPopped element is: " << obj.pop(); + cout << "\n\n == After poping two item =="; + obj.display(); + cout << "\nPopped element is: " << obj.pop(); + cout << "\nPopped element is: " << obj.pop(); // trying to underflow + return 0; +}+ \ No newline at end of file
© notamitgamer • Site Built: 2026-09-05 01:53:16 UTC • git-mirror commit: c170d72 [view raw info]
Originally created with stagit • modified by notamitgamer
Forked from github.com/notamitgamer/git-mirror