Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions C++/Program_26/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Program to implement Stack DataStructure Using Linked Lists
73 changes: 73 additions & 0 deletions C++/Program_26/StacksUsingLL.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
//Stacks Using Linked_Lists
#include<iostream>
using namespace std;
class node{
public:
int data;
node *link;
}*top=NULL;

void push(int x){
node *t;
t = new node;
if(t==NULL){
cout<<"Stack is full[Satck overflow]"<<endl;
}
else{
t->data = x;
t->link = top;
top = t;
}
}

void display(node *p){
while(p){
cout<<p->data<<" ";
p = p->link;
}
cout<<endl;
}

int pop(){
node *p = top;
int x;
if(top==NULL)
cout<<"Stack is empty![Stack Underflow]"<<endl;
else{
top = p->link;
x = p->data;
delete p;
}
return x;

}

int main(){

int x;
char c;
while(1){
cout<<"Choose an Operation : \n1.Push\n2.Pop\n3.Display\n4.Exit"<<endl;
cin>>c;
switch (c)
{
case '1':
cout<<"Enter the element : ";
cin>>x;
push(x);
break;
case '2':
x=pop();
cout<<"Poped element is "<<x<<endl;
break;
case '3':
display(top);
break;
case '4':
return 0;
break;
}
}

return 0;
}
50 changes: 50 additions & 0 deletions C++/Program_27/Polynomial_Expression.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
//Polynomial Expressions
#include<bits/stdc++.h>
using namespace std;
class node{
public:
int c;
int e;
node *link;
}*P=NULL;

void create(){
node *last,*t;
int n;
cout<<"Enter the NUmber of Terms : ";
cin>>n;
cout<<"Enter all the Terms in coeffient and exponent form : "<<endl;
for(int i=0;i<n;i++){
t = new node;
cin >> t->c >> t->e;
t->link = NULL;
if(P==NULL)
last = P = t;
else{
last->link = t;
last = t;
}
}

}

double evalute(int x){
node *t = P;
double sum = 0.0;
while(t){
sum += t->c*pow(x,t->e);
t = t->link;
}
return sum;
}

int main(){
int n;
create();
cout<<"Enter the Value of x : ";
cin>>n;
double r = evalute(n);
cout<<"The value of the polynomial expression when x = "<<n<<" is "<<r;

return 0;
}
1 change: 1 addition & 0 deletions C++/Program_27/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Program to evaluate polynomial expression Using Linked Lists
2 changes: 2 additions & 0 deletions C++/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
| Program No.| Question |
| ------- | ------ |



| [Program-01](https://github.com/swaaz/basicprograms/blob/814a1e60ae23d81158d8174666f23c9b7419e15e/C++/Program-01/Program.cpp) | Program to find the maximum and minimum element in an array. |
| [Program-02](https://github.com/swaaz/basicprograms/blob/814a1e60ae23d81158d8174666f23c9b7419e15e/C++/Program-2/number_of_occurrence.cpp) | Program to find the number of occurrence of X element present in sorted array. |
| [Program-03](https://github.com/swaaz/basicprograms/blob/814a1e60ae23d81158d8174666f23c9b7419e15e/C++/Program-3/program.cpp) | Program to Swap the Kth Elements of a series. |
Expand Down