OOP Lab3
OOP Lab3
#include <iostream>
using namespace std;
void stack::init()
{
tos = 0;
}
void stack::push(int i)
{
if(tos==SIZE)
{
cout << "Stack is full.\n";
return;
}
stck[tos] = i;
tos++;
}
int stack::pop()
{
if(tos==0) {
cout << "Stack underflow.\n";
return 0;
}
tos--;
return stck[tos];
}
int main()
{
stack stack1, stack2; // create two stack objects
stack1.init();
stack2.init();
stack1.push(10);
stack2.push(20);
stack1.push(30);
stack2.push(40);
return 0;
}
#include <iostream>
using namespace std;
int main()
{
cout << abs_vit(-10) << "\n";
return 0;
}
int abs_vit(int i)
{
cout << "Using integer abs()\n";
return i<0 ? -i : i;
}
double abs_vit(double d)
{
cout << "Using double abs()\n";
return d<0.0 ? -d : d;
}
long abs_vit(long l)
{
cout << "Using long abs()\n";
return l<0 ? -l : l;
}
///////////////////////
circle-> radius
triangle -> a,b,c
rectangle -> b,h
#include <iostream>
using namespace std;
int main()
{
cout << Area123(10) << "\n";
return 0;
}
float Area123(int i)
{
//cout << "Using integer abs()\n";
return 3.14*i*i;
}
return 12344;
}
return 0.5*b*h;
}
/// References
1. Problem Solving with C++: The Object of Programming, second edition, Walter J.
Savitch, Addison Wesley Publishers, 1999.
2. Object-oriented programming with C++ by E.Balagurusamy, 2nd Edition, TMH.
3. Object Oriented Design by Rumbaugh (Pearson publication)
4. OOPS C++ Big C++ Cay Horstmann Wiley Publication
5. https://www.w3schools.com/
6. https://www.tutorialspoint.com/index.htm
7. https://www.javatpoint.com/
8. https://www.geeksforgeeks.org/
9. Bjarne Stroustrup, The Design and Evolution of C++, Addison-Wesley.