Programming?
11.4K subscribers
373 photos
645 videos
978 files
513 links
🏅Channel privileges

🎗Ninth year of operation
🎗Completely specialized members
🎗Transmitter in channel automation
🎗, ...

🎯 second channel Programming books 👇
@topbookit

🎯 third channel laptop👇
@sysline


👨🏻‍💻Admin channels : @coderme
Download Telegram
#include <iostream.h>
#include <conio.h>

long factorial(int);

int main()
{
long number;

cout « "Please type a number :" ;
cin » number;

getch();
return 0;
}

long factorial(int a)
{
if(a > 1)
return ( a*factorial(a-1) );
else
return (1);
}
#include <iostream.h>
#include <conio.h>

class CRectangle
{
int x,y;
public:
void set_Values(int, int);
int area() { return (x*y);}
} obj_1;

void CRectangle :: set_Values(int a, int b)
{
x = a;
y = b;
}

void main()
{
obj_1.set_Values(3,4);
CRectangle obj_2;
obj_2.set_Values(5,6);
cout « "area = " « obj_1.area() « "\n";
cout « "area = " « obj_2.area();
getch();
}
#include <iostream.h>
#include <conio.h>

class CRectangle
{
int *width, *heigth;
public:
CRectangle(int, int);
~CRectangle();
int area() { return (*width * *heigth);}
};

CRectangle :: CRectangle(int a, int b)
{
width = new int;
heigth = new int;
*width = a;
*heigth = b;
}

CRectangle :: ~CRectangle()
{
delete width;
delete heigth;
}

void main()
{
CRectangle rect1(3,4), rect2(5,6);
cout « "rect1 area = " « rect1.area() « "\n";
cout « "rect2 area = " « rect2.area();
getch();
}
#include <iostream.h>
#include <conio.h>

class CRectangle
{
int width,heigth;
public:
CRectangle();
CRectangle(int, int);
int area(void) { return (width*heigth);}
};

CRectangle :: CRectangle()
{
width = 5;
heigth = 5;
}

CRectangle :: CRectangle(int a, int b)
{
width = a;
heigth = b;
}

void main()
{
CRectangle rect1(3,4);
CRectangle rect2;
cout « "rect1 area = " « rect1.area() « "\n";
cout « "rect2 area = " « rect2.area();
getch();
}
#include <iostream.h>
#include <conio.h>

class CRectangle
{
int width, height;
public:
void set_values (int, int);
int area (void) {return (width * height);}
};

void CRectangle::set_values (int a, int b)
{
width = a;
height = b;
}

int main()
{
CRectangle a, *b, *c;
CRectangle * d = new CRectangle[2];
b= new CRectangle;
c= &a;
a.set_values (1,2);
b->set_values (3,4);
d->set_values (5,6);
d[1].set_values (7,8);
cout « "a area: " « a.area() « endl;
cout « "*b area: " « b->area() « endl;
cout « "*c area: " « c->area() « endl;
cout « "d[0] area: " « d[0].area() « endl;
cout « "d[1] area: " « d[1].area() « endl;
delete[] d;
delete b;
return 0;
}
#include <iostream.h>
#include <conio.h>

class base
{
int val1,val2;
public:
void get()
{
cout « "Enter two values:";
cin » val1 » val2;
}
friend float mean(base ob);
};

float mean(base ob)
{
return float(ob.val1+ob.val2)/2;
}

void main()
{
clrscr();
base obj;
obj.get();
cout « "\n Mean value is : " « mean(obj);
getch();
}
// friend class
#include <iostream>
#include <conio.h>
using namespace std;

class CSquare;

class CRectangle
{
int width, height;
public:
int area (){return (width * height);}
void convert (CSquare a);
};

class CSquare
{
private:
int side;
public:
void set_side (int a){side=a;}
friend class CRectangle;
};

void CRectangle::convert (CSquare a)
{
width = a.side;
height = a.side;
}

int main ()
{
CSquare sqr;
CRectangle rect;
sqr.set_side(4);
rect.convert(sqr);
cout « rect.area();
getch();
return 0;
}
#include <iostream>

using namespace std;

// Base class
class Shape
{
public:
void setWidth(int w)
{
width = w;
}
void setHeight(int h)
{
height = h;
}
protected:
int width;
int height;
};

// Derived class
class Rectangle: public Shape
{
public:
int getArea()
{
return (width * height);
}
};

int main(void)
{
Rectangle Rect;

Rect.setWidth(5);
Rect.setHeight(7);

// Print the area of the object.
cout « "Total area: " « Rect.getArea() « endl;

return 0;
}
#include <iostream>
using namespace std;

class Shape {
protected:
int width, height;
public:
Shape( int a=0, int b=0)
{
width = a;
height = b;
}
int area()
{
cout « "Parent class area :" «endl;
return 0;
}
};
class Rectangle: public Shape{
public:
int area ()
{
cout « "Rectangle class area :" «endl;
return (width * height);
}
};
class Triangle: public Shape{
public:
int area ()
{
cout « "Triangle class area :" «endl;
return (width * height / 2);
}
};
// Main function for the program
int main( )
{
Shape *shape;
Rectangle rec(10,7);
Triangle tri(10,5);

// store the address of Rectangle
shape = &rec;
// call rectangle area.
shape->area();

// store the address of Triangle
shape = &tri;
// call triangle area.
shape->area();

return 0;
}
#include <iostream>


using namespace std;

struct pointform
{
int top;
int bottom;
int left;
int right;
};


int main() {

pointform sa = { 0, 0, 0, 0};
cout « sa.bottom « endl;
cout « sa.left « endl;
cout « sa.right « endl;
cout « sa.left « endl;

return 0;
}