├── Practice ├── tempCodeRunnerFile.cpp ├── first.cpp ├── first1.cpp ├── foreachauto.cpp ├── foreachloop.cpp ├── variables.cpp ├── pattren1.cpp ├── pointer1.cpp ├── array2d.cpp ├── pattern3.cpp ├── second_if_else.cpp ├── forloop.cpp ├── arithematic.cpp ├── input_output.cpp ├── pattern2.cpp ├── functiontemeplate.cpp ├── whiledowhile.cpp ├── foreach2darray.cpp ├── operatoroverloading.cpp ├── pointerobject.cpp ├── array.cpp ├── objectheap.cpp ├── runtimepoly.cpp ├── pointer2.cpp ├── virtualpolymorphism.cpp ├── class.cpp ├── friendoperatoroverloading.cpp ├── constructorinheritance.cpp ├── dsa1findinganumber.cpp ├── sierpinskitrio.cpp ├── datahiding.cpp ├── insertionoperatoroveloading.cpp ├── variables2.cpp ├── calculator.cpp ├── inheritance1.cpp ├── filehandling.cpp ├── vectorfile.cpp └── storehandling.cpp ├── day-01 ├── program_2.cpp ├── program_1.cpp ├── program_3.cpp ├── program_4.cpp └── program_5.cpp ├── day-10 ├── program_0.cpp ├── program_1.cpp ├── program_3.cpp ├── program_5.cpp ├── program_4.cpp └── program_2.cpp ├── day-06 ├── program_1.cpp ├── program_0.cpp ├── program_2.cpp ├── Program_4.cpp ├── Program_5.cpp └── Program_3.cpp ├── day-05 ├── program_3.cpp ├── program_4.cpp ├── program_1.cpp ├── program_2.cpp ├── program_5.cpp └── program_0.cpp ├── day-11 ├── program_0.cpp ├── program_1.cpp ├── program_4.cpp ├── program_2.cpp ├── program_3.cpp └── program_5.cpp ├── day-03 ├── program_1.cpp ├── program_3.cpp ├── program_2.cpp ├── program_4.cpp └── program_5.cpp ├── day-13 ├── program_3.cpp ├── program_0.cpp ├── program_1.cpp ├── program_5.cpp ├── program_4.cpp └── program_2.cpp ├── day-02 ├── program_2.cpp ├── program_4.cpp ├── program_3.cpp ├── program_5.cpp └── program_1.cpp ├── day-04 ├── program_4.cpp ├── program_1.cpp ├── program_5.cpp ├── program_2.cpp └── program_3.cpp ├── day-14 ├── program_0.cpp ├── program_1.cpp ├── program_2.cpp ├── program_5.cpp ├── program_4.cpp └── program_3.cpp ├── day-09 ├── program_0.cpp ├── program_3.cpp ├── program_1.cpp ├── program_2.cpp ├── program_4.cpp └── program_5.cpp ├── day-08 ├── Program_4.cpp ├── program_1.cpp ├── program_5.cpp ├── program_3.cpp ├── program_0.cpp └── program_2.cpp ├── day-12 ├── program_0.cpp ├── program_1.cpp ├── program_5.cpp ├── program_2.cpp ├── program_4.cpp └── program_3.cpp ├── day-07 ├── PRogram_5.cpp ├── IntroductionOOPS.cpp ├── Program_2.cpp ├── Program_3.cpp ├── Program_1.cpp └── program_4.cpp ├── LICENSE └── README.md /Practice/tempCodeRunnerFile.cpp: -------------------------------------------------------------------------------- 1 | // { 2 | // length=l; 3 | // breath=b; 4 | // } -------------------------------------------------------------------------------- /Practice/first.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | std::cout<<"hello world"; 5 | return 0; 6 | } 7 | -------------------------------------------------------------------------------- /Practice/first1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | int main() 4 | { 5 | cout<<"hello world"; 6 | return 0; 7 | } -------------------------------------------------------------------------------- /day-01/program_2.cpp: -------------------------------------------------------------------------------- 1 | // program using namespace std 2 | #include 3 | using namespace std; 4 | int main() 5 | { 6 | cout<<"hello world \n"; 7 | return 0; 8 | } -------------------------------------------------------------------------------- /day-01/program_1.cpp: -------------------------------------------------------------------------------- 1 | //print hello world using c++ 2 | #include //package or library 3 | int main() //Entry point from where the main complilation starts 4 | { 5 | std::cout<<"hello world"; 6 | return 0; 7 | } 8 | -------------------------------------------------------------------------------- /Practice/foreachauto.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | int main() 4 | { 5 | float a[]={2.3,43,54,3.3,33,6}; 6 | 7 | for(auto x:a) 8 | cout< 3 | using namespace std; 4 | int main() 5 | { 6 | cout<<"hello there"< 2 | using namespace std; 3 | int main() 4 | { 5 | int a []={1,3,5,7,9,11,13}; 6 | 7 | for(int x:a) 8 | { 9 | cout< 2 | using namespace std; 3 | int main() 4 | { 5 | int a=10; 6 | cout< 3 | using namespace std; 4 | void display() 5 | { 6 | cout<<"the function ran successfully"; 7 | } 8 | int main() 9 | { 10 | display(); 11 | return 0; 12 | } -------------------------------------------------------------------------------- /day-05/program_3.cpp: -------------------------------------------------------------------------------- 1 | //refernce in pointers 2 | #include 3 | using namespace std; 4 | int main() 5 | { 6 | int x=10; 7 | int &y=x;//reference 8 | x++; 9 | y++; 10 | cout< 2 | using namespace std; 3 | int main() 4 | { 5 | for(int i=0;i<4;i++) 6 | { 7 | for(int j=0;j<=i;j++) 8 | { 9 | cout<<"*"; 10 | } 11 | cout< 3 | using namespace std; 4 | void display() 5 | { 6 | cout<<"hello world"; 7 | 8 | } 9 | int main() 10 | { 11 | void(*fp)(); 12 | fp=&display; 13 | (*fp)(); 14 | return 0; 15 | } 16 | -------------------------------------------------------------------------------- /Practice/pointer1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | int main() 4 | { 5 | int a=19; 6 | int*p=&a; 7 | 8 | cout< 2 | using namespace std; 3 | int main() 4 | { 5 | int a[2][3]={{1,2,3},{4,5,6}}; 6 | int i,j; 7 | for(i=0;i<2;i++) 8 | { 9 | for(j=0;j<3;j++) 10 | { 11 | cout< 2 | using namespace std; 3 | int main() 4 | { 5 | int i,j; 6 | for(i=0;i<4;i++) 7 | { 8 | for(j=0;j<4;j++) 9 | { 10 | if(i+j>4-1) 11 | cout<<"*"; 12 | else 13 | cout<<" "; 14 | } 15 | cout< 2 | using namespace std; 3 | int main() 4 | { 5 | int savings; 6 | cin>>savings; 7 | if(savings>5000) 8 | { 9 | cout<<"lets party"; 10 | } 11 | else 12 | { 13 | cout<<"you are broke"; 14 | } 15 | return 0; 16 | 17 | } -------------------------------------------------------------------------------- /day-03/program_1.cpp: -------------------------------------------------------------------------------- 1 | //Arrays using the for each loop 2 | #include 3 | using namespace std; 4 | int main() 5 | { 6 | int a[]={1,3,5,7,9,11}; 7 | for(int x:a)// for every x:a[x] 8 | { 9 | cout< 3 | using namespace std; 4 | int main() 5 | { 6 | int a=10; 7 | int *p=&a; 8 | 9 | cout<<&a< 3 | using namespace std; 4 | int main() 5 | { 6 | int *p=new int[5]; 7 | p[0]=12;//memory allocation 8 | p[1]=13; 9 | cout< 2 | using namespace std; 3 | 4 | #define MAX(x, y) (x > y ? x : y) 5 | #define msg(x) #x 6 | 7 | #define PI 3.1425 8 | 9 | int main() 10 | { 11 | cout << PI << endl; 12 | cout << MAX(10, 12) << endl; 13 | cout << msg(hello) << endl; 14 | 15 | return 0; 16 | } 17 | -------------------------------------------------------------------------------- /day-06/program_0.cpp: -------------------------------------------------------------------------------- 1 | //1.Function is a module which performs a specific task 2 | //2.Functions are called by name 3 | //3.Rules for giving name to the function is same as variables 4 | //4.Functions can take zero or more parameters 5 | //5.functions can return single value 6 | //6.void functions do not return values 7 | //7.default return type is int -------------------------------------------------------------------------------- /Practice/forloop.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | int main() 4 | { 5 | for(int i=0;i<5;i++) 6 | cout<<"array"< 2 | using namespace std; 3 | int main() 4 | { 5 | int a=10,b=15; 6 | cout< 3 | using namespace std; 4 | int main() 5 | { 6 | int a; 7 | cin>>a; 8 | cout<<"value of a="<>name; 12 | cout<<"welcome"< 3 | using namespace std; 4 | int min(int x,int y) 5 | { 6 | return(x 2 | using namespace std; 3 | int main() 4 | { 5 | int a; 6 | cout<<"enter the value of a "; 7 | cin>>a; 8 | cout<<"value of the variable a is ="<>name; 12 | cout<<"welcome home "< 3 | using namespace std; 4 | int main() 5 | { 6 | int A[2][3]={{1,2,3},{4,5,6}}; 7 | for(int i=0;i<2;i++) 8 | { 9 | for(int j=0;j<3;j++) 10 | { 11 | cout< 2 | using namespace std; 3 | int main() 4 | { 5 | int i,j; 6 | for(i=0;i<4;i++) 7 | { 8 | for(j=0;j<4;j++) 9 | { 10 | if(i>j) 11 | cout<<" "; 12 | else 13 | cout<<"*"; 14 | } 15 | cout< 2 | using namespace std; 3 | template 4 | T add(T x, T y) 5 | { 6 | if (x>y) 7 | return x; 8 | else 9 | return y; 10 | } 11 | int main() 12 | { 13 | int c=add(10,5); 14 | float d=add(10.5F,20.5f); 15 | cout< 3 | using namespace std; 4 | int main() 5 | { 6 | int a[]={4,8,6,9,5,2,7}; 7 | int sum=0; 8 | for(auto x:a) 9 | { 10 | sum=sum+x; 11 | //sums all the elemnts one by one 12 | } 13 | cout<<"sum of the array elemnts="< 8 | using namespace std; 9 | int main () 10 | { 11 | for(int i=0;i<5;i++) 12 | { 13 | for(int j=0;j<=i;j++) 14 | { 15 | cout<<"#"; 16 | } 17 | cout< 3 | using namespace std; 4 | int main() 5 | { 6 | for(int i=0;i<3;i++) 7 | cout<<"endl"< 4 | using namespace std; 5 | int main() 6 | { 7 | float a[]={2.3f,3.9f,6.2f,9.8f}; 8 | //values in the float data type 9 | for(auto x:a) 10 | //x does not need to know thw data type of array 11 | { 12 | cout< 3 | using namespace std; 4 | int main() 5 | { 6 | int a[]={4,8,6,9,5,2,7}; 7 | int max=a[0]; 8 | for(auto x:a) 9 | { 10 | if(max 3 | using namespace std; 4 | int main() 5 | { 6 | int savings; 7 | cout<<"enter the savings"<>savings; 9 | if(savings>50000) 10 | { 11 | cout<<"it's time to party"< 3 | using namespace std; 4 | int main() 5 | { 6 | int array[4]; 7 | array[0]=10; 8 | array[1]=20; 9 | array[2]=30; 10 | array[3]=40; 11 | 12 | cout<<"array[0]="< 3 | using namespace std; 4 | int main() 5 | { 6 | int a[2][3]; 7 | for(auto &x:a) 8 | { 9 | for(auto &y:x) 10 | { 11 | cin>>y; 12 | } 13 | cout< 3 | using namespace std; 4 | class Test 5 | { 6 | public: 7 | void func() 8 | { 9 | cout << "Inline" << endl; 10 | ; 11 | } 12 | void func2(); 13 | }; 14 | 15 | void Test::func2() 16 | { 17 | cout << "non-inline" << endl; 18 | ; 19 | } 20 | int main() 21 | { 22 | Test T; 23 | T.func(); 24 | T.func2(); 25 | 26 | return 0; 27 | } -------------------------------------------------------------------------------- /day-06/program_2.cpp: -------------------------------------------------------------------------------- 1 | // CPP program to implement Function Overloading 2 | #include 3 | using namespace std; 4 | int add(int x,int y)//function with same name 5 | { 6 | return x+y; 7 | } 8 | int add(int x,int y,int z)//function with same name 9 | { 10 | return x+y+z; 11 | } 12 | int main() 13 | { 14 | int a=10,b=5,c,d; 15 | c=add(a,b); 16 | d=add(a,b,c); 17 | cout< 3 | using namespace std; 4 | int main() 5 | { 6 | int i=0; 7 | while(i<0) 8 | { 9 | cout<<"hello"< 3 | using namespace std; 4 | 5 | class Test 6 | { 7 | public: 8 | int a; 9 | int *p; 10 | 11 | Test(int x) 12 | { 13 | a = x; 14 | p = new int[a]; 15 | } 16 | Test(Test &T) 17 | { 18 | a = T.a; 19 | p = new int[a]; 20 | } 21 | }; 22 | int main() 23 | { 24 | Test T(5); 25 | Test T2(T); 26 | return 0; 27 | } -------------------------------------------------------------------------------- /day-14/program_1.cpp: -------------------------------------------------------------------------------- 1 | //Vector 2 | #include 3 | #include 4 | 5 | int main() { 6 | std::vector v = {10, 20, 30, 90}; 7 | v.push_back(25); 8 | v.push_back(75); 9 | v.pop_back(); 10 | 11 | for (int x : v) { 12 | std::cout << x << " "; 13 | } 14 | 15 | std::vector::iterator itr = v.begin(); 16 | while (itr != v.end()) { 17 | std::cout << *itr << " "; 18 | ++itr; 19 | } 20 | 21 | return 0; 22 | } 23 | -------------------------------------------------------------------------------- /day-06/Program_4.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | template 5 | T add(T num1, T num2) { 6 | return (num1 + num2); 7 | } 8 | 9 | int main() { 10 | int result1; 11 | double result2; 12 | // calling with int parameters 13 | result1 = add(2, 3); 14 | cout << "2 + 3 = " << result1 << endl; 15 | 16 | // calling with double parameters 17 | result2 = add(2.2, 3.3); 18 | cout << "2.2 + 3.3 = " << result2 << endl; 19 | 20 | return 0; 21 | } -------------------------------------------------------------------------------- /Practice/operatoroverloading.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | class complex 4 | { 5 | public: 6 | int real; 7 | int img; 8 | complex operator+(complex x) 9 | { 10 | complex temp; 11 | temp.real=real+x.real; 12 | temp.img=img+x.img; 13 | return temp; 14 | } 15 | }; 16 | int main() 17 | { 18 | complex c1,c2,c3; 19 | c1.real=3;c1.img=4; 20 | c2.real=4;c2.img=3; 21 | c3=c1+c2; 22 | cout< 3 | using namespace std; 4 | int main() 5 | { 6 | int a=10,b=5; 7 | cout<< a+b < 6 | using namespace std; 7 | class base{ 8 | public: 9 | void fun() 10 | { 11 | cout<<"function of the base"< 2 | using namespace std; 3 | class rectangle{ 4 | public: 5 | int length; 6 | int breath; 7 | 8 | int area() 9 | { 10 | return length*breath; 11 | } 12 | int perimeter(){ 13 | return 2*(length+breath); 14 | } 15 | }; 16 | int main() 17 | { 18 | rectangle r1; 19 | rectangle *p; 20 | p=&r1; 21 | r1.length=10; 22 | r1.breath=20; 23 | p->length=5; 24 | p->breath=5; 25 | cout<area()< 3 | using namespace std; 4 | int main() 5 | { 6 | int a[]={6,8,13,17,20,22,25,28,30,35}; 7 | cout<<"enter the element to be searched="; 8 | int b; 9 | cin>>b; 10 | 11 | for(auto x:a) 12 | { 13 | if(b==x) 14 | { 15 | cout<<"the element is present"< 7 | using namespace std; 8 | int main() 9 | { 10 | for(int i=0;i<4;i++) 11 | { 12 | for(int j=0;j<4;j++) 13 | { 14 | if(i>j) 15 | { 16 | cout<<" "; 17 | } 18 | else{ 19 | cout<<"#"; 20 | } 21 | } 22 | cout< 3 | using namespace std; 4 | class base{ 5 | public: 6 | virtual void fun1()=0; 7 | virtual void fun2()=0; 8 | }; 9 | class derieved: public base 10 | { 11 | public: 12 | void fun1() 13 | { 14 | cout<<"func1 of derieved class"< 3 | using namespace std; 4 | class Base 5 | { 6 | private: 7 | int num; // by default private 8 | public: 9 | void getData(); 10 | void showData(); 11 | }; 12 | void Base ::getData() 13 | { 14 | cout << "Enter any Integer value" << endl; 15 | cin >> num; 16 | } 17 | void Base ::showData() 18 | { 19 | cout << "The value is " << num << endl; 20 | } 21 | 22 | int main() 23 | { 24 | Base obj; 25 | obj.getData(); 26 | obj.showData(); 27 | return 0; 28 | } -------------------------------------------------------------------------------- /Practice/array.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | int main() 4 | { 5 | int array[4]; 6 | 7 | array[0]=10; 8 | array[1]=20; 9 | array[2]=30; 10 | array[3]=40; 11 | 12 | cout<<"array[0]="< 3 | using namespace std; 4 | 5 | class enclosing { 6 | private: 7 | int x; 8 | 9 | public: 10 | class Nested { 11 | private: 12 | int y; 13 | 14 | public: 15 | void nestedfun(enclosing *e) { 16 | cout << e->x << endl; 17 | } 18 | }; 19 | 20 | enclosing(int val) : x(val) {} 21 | }; 22 | 23 | int main() { 24 | enclosing obj(10); 25 | enclosing::Nested nestedObj; 26 | 27 | nestedObj.nestedfun(&obj); 28 | 29 | return 0; 30 | } 31 | -------------------------------------------------------------------------------- /day-13/program_1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int division(int a, int b) 5 | { 6 | if (b == 0) 7 | { 8 | throw 1; 9 | } 10 | return a / b; 11 | } 12 | 13 | int main() 14 | { 15 | int x = 10, y = 0, z; // Setting y to 0 to trigger the division by zero exception 16 | try 17 | { 18 | z = division(x, y); 19 | cout << z << endl; 20 | } 21 | catch (int e) 22 | { 23 | cerr << "Exception: Division by zero" << endl; 24 | } 25 | cout << "Bye" << endl; 26 | return 0; 27 | } 28 | -------------------------------------------------------------------------------- /day-05/program_0.cpp: -------------------------------------------------------------------------------- 1 | //Basics of pointers 2 | 3 | 4 | /* 5 | data type variables int a=10; 6 | pointer typr variables int *p; 7 | p=&x;--200 8 | pointer p markers the x location 9 | cout< 3 | using namespace std; 4 | class Base 5 | { 6 | public: 7 | int x; 8 | 9 | void show() 10 | { 11 | cout << x << endl; 12 | } 13 | }; 14 | class Derieved : public Base 15 | { 16 | public: 17 | int y; 18 | void display() 19 | { 20 | cout << x << " " << y << endl; 21 | } 22 | }; 23 | int main() 24 | { 25 | Base b; 26 | b.x=25; 27 | b.show(); 28 | Derieved d; 29 | d.x = 10; 30 | d.y = 15; 31 | d.show(); 32 | d.display(); 33 | 34 | return 0; 35 | } -------------------------------------------------------------------------------- /day-07/Program_2.cpp: -------------------------------------------------------------------------------- 1 | // Pointer to class in CPP 2 | #include 3 | using namespace std; 4 | class Rectangle 5 | { 6 | public: 7 | int length; 8 | int breath; 9 | 10 | int area() 11 | { 12 | return length * breath; 13 | } 14 | 15 | int perimeter() 16 | { 17 | return 2 * (length + breath); 18 | } 19 | }; 20 | int main() 21 | { 22 | Rectangle r; 23 | Rectangle *p; 24 | p = &r; 25 | p->length = 10; 26 | p->breath = 20; 27 | cout << p->area() << endl; 28 | cout << p->perimeter() << endl; 29 | 30 | return 0; 31 | } -------------------------------------------------------------------------------- /day-07/Program_3.cpp: -------------------------------------------------------------------------------- 1 | // Object to Heap in CPP program 2 | #include 3 | using namespace std; 4 | 5 | class Rectangle 6 | { 7 | public: 8 | int length; 9 | int breath; 10 | 11 | int area() 12 | { 13 | return length * breath; 14 | } 15 | 16 | int perimeter() 17 | { 18 | return 2 * (length + breath); 19 | } 20 | }; 21 | int main() 22 | { 23 | Rectangle *p; 24 | p = new Rectangle; 25 | p->length = 10; 26 | p->breath = 20; 27 | cout << p->area() << endl; 28 | cout << p->perimeter() << endl; 29 | 30 | return 0; 31 | } -------------------------------------------------------------------------------- /day-13/program_5.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() 5 | { 6 | ofstream outfile("my.txt"); 7 | outfile << "hello" << endl; 8 | outfile << 25 << endl; 9 | outfile.close(); 10 | return 0; 11 | } 12 | 13 | 14 | #include 15 | #include 16 | using namespace std; 17 | 18 | int main() 19 | { 20 | ifstream ifs("test.txt"); 21 | string name; 22 | int roll; 23 | string branch; 24 | 25 | ifs >> name >> roll >> branch; 26 | cout << name << endl << branch << endl; 27 | ifs.close(); 28 | return 0; 29 | } 30 | -------------------------------------------------------------------------------- /Practice/objectheap.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | class rectangle{ 5 | public: 6 | int length; 7 | int breath; 8 | 9 | int area() 10 | { 11 | return length*breath; 12 | } 13 | int perimeter() 14 | { 15 | return 2*(length+breath); 16 | } 17 | }; 18 | int main() 19 | { 20 | rectangle *p; 21 | p=new rectangle; 22 | rectangle *q=new rectangle; 23 | p->length=10; 24 | p->breath=20; 25 | q->length=5; 26 | q->breath=5; 27 | cout<area()<area()< 7 | using namespace std; 8 | int main() 9 | { 10 | int i,j; 11 | for(i=0;i<4;i++) 12 | { 13 | for(j=0;j<4;j++) 14 | { 15 | if(i+j>4-1) 16 | { 17 | cout<<"#"; 18 | } 19 | else 20 | { 21 | cout<<" "; 22 | } 23 | } 24 | cout< 3 | using namespace std; 4 | 5 | class Rectangle 6 | { 7 | public: 8 | int length; 9 | int breath; 10 | 11 | int area() 12 | { 13 | return length * breath; 14 | } 15 | 16 | int perimeter() 17 | { 18 | return 2 * (length + breath); 19 | } 20 | }; 21 | int main() 22 | { 23 | Rectangle r1, r2; 24 | r1.length = 10; 25 | r1.breath = 20; 26 | cout << r1.area() << endl; 27 | r2.length = 21; 28 | r2.breath = 10; 29 | cout << r2.perimeter() << endl; 30 | 31 | return 0; 32 | } -------------------------------------------------------------------------------- /Practice/runtimepoly.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | class car 4 | { 5 | public: 6 | virtual void start()=0; 7 | 8 | }; 9 | class innova: public car 10 | { 11 | public: 12 | void start() 13 | { 14 | cout<<"start the innova"<start(); 30 | delete p; 31 | p=new swift(); 32 | p->start(); 33 | delete p; 34 | return 0; 35 | } -------------------------------------------------------------------------------- /day-08/program_5.cpp: -------------------------------------------------------------------------------- 1 | // Implementation of Operator Overloading 2 | #include 3 | using namespace std; 4 | class complex 5 | { 6 | public: 7 | int real; 8 | int img; 9 | 10 | complex operator+(complex x) 11 | { 12 | complex temp; 13 | temp.real = real + x.real; 14 | temp.img = img + x.img; 15 | return temp; 16 | } 17 | }; 18 | int main() 19 | { 20 | complex c1, c2, c3; 21 | c1.real = 4; 22 | c1.img = 3; 23 | c2.real = 3; 24 | c2.img = 4; 25 | c3 = c1 + c2; 26 | cout << c3.real << "+ i" << c3.img << endl; 27 | 28 | return 0; 29 | } -------------------------------------------------------------------------------- /day-11/program_4.cpp: -------------------------------------------------------------------------------- 1 | //Cpp program for runtime polymorphism 2 | #include 3 | using namespace std; 4 | class car{ 5 | public: 6 | virtual void start()=0; 7 | }; 8 | class innova:public car{ 9 | public: 10 | void start() 11 | { 12 | cout<<"innova started"<start(); 27 | p=new swift(); 28 | p->start(); 29 | return 0; 30 | } 31 | -------------------------------------------------------------------------------- /day-08/program_3.cpp: -------------------------------------------------------------------------------- 1 | // scope resolution operator 2 | #include 3 | using namespace std; 4 | class Rectangle 5 | { 6 | private: 7 | int length; 8 | int breath; 9 | 10 | public: 11 | Rectangle(int l, int b) 12 | { 13 | length = l; 14 | breath = b; 15 | } 16 | int area() 17 | { 18 | return length * breath; 19 | } 20 | int perimeter(); 21 | }; 22 | 23 | int Rectangle::perimeter() 24 | { 25 | return 2 * (length * breath); 26 | } 27 | int main() 28 | { 29 | Rectangle r(10, 5); 30 | cout << r.area() << endl; 31 | cout << r.perimeter() << endl; 32 | } -------------------------------------------------------------------------------- /day-11/program_2.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Virtual Functions: 3 | *virtual functions are used for achieveing polymorphism. 4 | *base class can have virtual functions. 5 | *virtual class can be overrided class. 6 | */ 7 | #include 8 | using namespace std; 9 | class BasicCar 10 | { 11 | public: 12 | virtual void start() 13 | { 14 | cout<<"Basic car Started"<start(); 28 | 29 | return 0; 30 | } -------------------------------------------------------------------------------- /Practice/pointer2.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | int main() 4 | { 5 | int var=5; 6 | cout<<&var< 2 | #include // Include necessary header for ifstream 3 | using namespace std; 4 | 5 | class Test 6 | { 7 | private: 8 | ifstream fis; 9 | int *p; 10 | 11 | public: 12 | Test() 13 | { 14 | p = new int[10]; 15 | fis.open("my_text.txt"); // Corrected the file name and added the file extension 16 | } 17 | 18 | ~Test() 19 | { 20 | delete[] p; 21 | fis.close(); 22 | } 23 | }; 24 | 25 | int main() 26 | { 27 | // Create an object of the Test class 28 | Test testObj; 29 | 30 | // Your code logic goes here... 31 | 32 | return 0; 33 | } 34 | -------------------------------------------------------------------------------- /day-06/Program_5.cpp: -------------------------------------------------------------------------------- 1 | //function template using the public and private template functions 2 | #include 3 | using namespace std; 4 | template 5 | class Test 6 | { 7 | private: 8 | T answer; 9 | 10 | public: 11 | Test(T n) : answer(n) 12 | { 13 | cout << "Inside constructor" << endl; 14 | } 15 | 16 | T getNumber() 17 | { 18 | return answer; 19 | } 20 | }; 21 | int main() 22 | { 23 | Test numberInt(60); 24 | Test numberDouble(17.27); 25 | cout << "Integer Number is: " << numberInt.getNumber() << endl; 26 | cout << "Double Number = " << numberDouble.getNumber() << endl; 27 | return 0; 28 | } 29 | -------------------------------------------------------------------------------- /day-06/Program_3.cpp: -------------------------------------------------------------------------------- 1 | //Implementation of function template 2 | #include 3 | // using namespace std; Cannot use it. 4 | 5 | template //declare the template 6 | T max(T x, T y)//defining a function template 7 | { 8 | if (x > y) 9 | { 10 | return x; 11 | } 12 | else 13 | { 14 | return y; 15 | } 16 | } 17 | 18 | int main() 19 | { 20 | //calling a function template. 21 | int c = std::max(10, 5); 22 | float d = std::max(10.5f, 15.6f); 23 | 24 | std::cout << "Max of 10 and 5: " << c << std::endl; 25 | std::cout << "Max of 10.5 and 15.6: " << d << std::endl; 26 | 27 | return 0; 28 | } 29 | -------------------------------------------------------------------------------- /day-12/program_2.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Friend Function and Classes 3 | *friend functions are global functions. 4 | *they can access member of a class upon their objects. 5 | *a class can be declared as friend on another class. 6 | *all the functions of friends class can access private and protected membersof other class. 7 | */ 8 | #include 9 | using namespace std; 10 | class your; 11 | class my 12 | { 13 | private:int a; 14 | protected:int b; 15 | public:int c; 16 | friend your; 17 | }; 18 | class your{ 19 | my m; 20 | void func() 21 | { 22 | m.a=10; 23 | m.b=10; 24 | m.c=10; 25 | } 26 | }; 27 | int main() 28 | { 29 | return 0; 30 | } -------------------------------------------------------------------------------- /Practice/virtualpolymorphism.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | class base{ 4 | public: 5 | virtual void print() 6 | { 7 | cout<<"print the base class\n"; 8 | } 9 | void show() 10 | { 11 | cout<<"show the base class"<print(); 33 | btpr ->show(); 34 | return 0; 35 | } -------------------------------------------------------------------------------- /Practice/class.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | class Rectangle { 5 | public: 6 | int length; 7 | int breath; 8 | 9 | int area() { 10 | return length * breath; 11 | } 12 | 13 | int perimeter() { 14 | return 2 * (length + breath); 15 | } 16 | }; 17 | 18 | int main() { 19 | Rectangle r1, r2; 20 | r1.length = 10; 21 | r1.breath = 5; 22 | cout << "Area of r1: " << r1.area() << endl; 23 | cout << "Perimeter of r1: " << r1.perimeter() << endl; 24 | 25 | r2.length = 20; 26 | r2.breath = 10; 27 | cout << "Area of r2: " << r2.area() << endl; 28 | cout << "Perimeter of r2: " << r2.perimeter() << endl; 29 | 30 | return 0; 31 | } -------------------------------------------------------------------------------- /Practice/friendoperatoroverloading.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | class complex 4 | { 5 | private: 6 | int real; 7 | int img; 8 | 9 | public: 10 | complex(int r=0,int i=0) 11 | { 12 | real=r; 13 | img=i; 14 | } 15 | void display() 16 | { 17 | cout< 3 | using namespace std; 4 | class A1 5 | { 6 | public: 7 | A1() 8 | { 9 | int a = 20, b = 35, c; 10 | c = a + b; 11 | cout << "Sum is:" << 12 | c << endl; 13 | } 14 | }; 15 | 16 | class A2 17 | { 18 | public: 19 | A2() 20 | { 21 | int x = 50, y = 42, z; 22 | z = x - y; 23 | cout << "Difference is:" << 24 | z << endl; 25 | } 26 | }; 27 | 3 28 | class S: public A1,virtual A2 29 | { 30 | public: 31 | S(): A1(), A2() 32 | { 33 | int r = 40, s = 8, t; 34 | t = r * s; 35 | cout << "Product is:" << 36 | t << endl; 37 | } 38 | }; 39 | 40 | // Driver code 41 | int main() 42 | { 43 | S obj; 44 | return 0; 45 | } 46 | -------------------------------------------------------------------------------- /day-02/program_1.cpp: -------------------------------------------------------------------------------- 1 | // data types in cpp 2 | #include 3 | using namespace std; 4 | int main() 5 | { 6 | int a=10,b=15; 7 | cout<<"values of a:"< 3 | #include 4 | 5 | int main() 6 | { 7 | std::map m; 8 | m.insert(std::pair(1, "Rahul")); 9 | m.insert(std::pair(2, "Yashoda")); 10 | m.insert(std::pair(3, "Yotsuba")); 11 | 12 | std::map::iterator itr; 13 | 14 | for(itr = m.begin(); itr != m.end(); ++itr) 15 | { 16 | std::cout << itr->first << " " << itr->second << std::endl; 17 | } 18 | 19 | std::map::iterator itr1; 20 | itr1 = m.find(2); 21 | 22 | std::cout << "value found is" << std::endl; 23 | std::cout << itr1->first << " " << itr1->second << std::endl; 24 | 25 | return 0; 26 | } 27 | -------------------------------------------------------------------------------- /Practice/dsa1findinganumber.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | int coutdigit1(long n) 5 | { 6 | int cout=0; 7 | while(n!=0) 8 | { 9 | n=n/10; 10 | ++cout; 11 | } 12 | return cout; 13 | } 14 | int coutdigit2(long n) 15 | { 16 | if(n==0) 17 | { 18 | return 0; 19 | } 20 | return 1+coutdigit1(n/10); 21 | } 22 | int coutdigitt3(long n) 23 | { 24 | return floor(log10(n)+1); 25 | } 26 | int main() 27 | { 28 | long n; 29 | cout<<"enter a number to find the number of digits"<>n; 31 | int a=coutdigit1(n); 32 | int b=coutdigit2(n); 33 | int c=coutdigitt3(n); 34 | cout< 2 | using namespace std; 3 | class student 4 | { 5 | public: 6 | int roll; 7 | string name; 8 | static int addno; 9 | 10 | student(string n) 11 | { 12 | addno++; 13 | roll=addno; 14 | name=n; 15 | } 16 | void display() 17 | { 18 | cout<<"name"< 3 | using namespace std; 4 | 5 | void printSierpinski(int n) 6 | { 7 | for (int y = n - 1; y >= 0; y--) { 8 | 9 | // printing space till 10 | // the value of y 11 | for (int i = 0; i < y; i++) { 12 | cout<<" "; 13 | } 14 | 15 | // printing '*' 16 | for (int x = 0; x + y < n; x++) { 17 | 18 | // printing '*' at the appropriate position 19 | // is done by the and value of x and y 20 | // wherever value is 0 we have printed '*' 21 | if(x & y) 22 | cout<<" "<<" "; 23 | else 24 | cout<<"* "; 25 | } 26 | 27 | cout< 3 | using namespace std; 4 | class base{ 5 | public: 6 | virtual void print() 7 | { 8 | cout<<"print the base class"<print(); 33 | //virtaul function , binded at compile time. 34 | p->show(); 35 | 36 | return 0; 37 | } -------------------------------------------------------------------------------- /day-09/program_1.cpp: -------------------------------------------------------------------------------- 1 | // Friend Operator Overloading 2 | #include 3 | using namespace std; 4 | 5 | class Complex 6 | { 7 | private: 8 | int real; 9 | int img; 10 | 11 | public: 12 | Complex(int r = 0, int i = 0) 13 | { 14 | real = r; 15 | img = i; 16 | } 17 | 18 | void display() 19 | { 20 | cout << real << "+i " << img << endl; 21 | } 22 | 23 | friend Complex operator+(Complex c1, Complex c2); 24 | }; 25 | 26 | Complex operator+(Complex c1, Complex c2) 27 | { 28 | Complex temp; 29 | temp.real = c1.real + c2.real; 30 | temp.img = c1.img + c2.img; 31 | return temp; 32 | } 33 | 34 | int main() 35 | { 36 | Complex c1(4, 3); 37 | Complex c2(3, 4); 38 | Complex c3; 39 | c3 = c1 + c2; 40 | 41 | c3.display(); 42 | 43 | return 0; 44 | } 45 | -------------------------------------------------------------------------------- /day-14/program_5.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | 6 | int main() 7 | { 8 | multimap m; 9 | m.insert(pair(1, "Rahul")); 10 | m.insert(pair(2, "Yashoda")); 11 | m.insert(pair(2, "Yotsuba")); 12 | m.insert(pair(3, "Yotsuba")); 13 | 14 | multimap::iterator itr; 15 | 16 | for(itr = m.begin(); itr != m.end(); ++itr) 17 | { 18 | cout << itr->first << " " << itr->second << endl; 19 | } 20 | 21 | multimap::iterator itr1; 22 | itr1 = m.find(2); 23 | 24 | cout << "Values found with key 2 are" << endl; 25 | 26 | while (itr1 != m.end() && itr1->first == 2) { 27 | cout << itr1->first << " " << itr1->second << endl; 28 | ++itr1; 29 | } 30 | 31 | return 0; 32 | } 33 | -------------------------------------------------------------------------------- /day-11/program_5.cpp: -------------------------------------------------------------------------------- 1 | //CPP program to implement runtime polymorphism 2 | #include 3 | using namespace std; 4 | 5 | class Shape 6 | { 7 | public: 8 | virtual void draw() = 0; 9 | }; 10 | 11 | class Circle : public Shape 12 | { 13 | public: 14 | void draw() 15 | { 16 | cout << "Drawing a circle" << endl; 17 | } 18 | }; 19 | 20 | class Rectangle : public Shape 21 | { 22 | public: 23 | void draw() 24 | { 25 | cout << "Drawing a rectangle" << endl; 26 | } 27 | }; 28 | 29 | int main() 30 | { 31 | // Using pointers to the base class to achieve runtime polymorphism 32 | Shape *shapePtr = new Circle(); 33 | shapePtr->draw(); 34 | 35 | shapePtr = new Rectangle(); 36 | shapePtr->draw(); 37 | 38 | delete shapePtr; // Don't forget to release the allocated memory 39 | 40 | return 0; 41 | } 42 | -------------------------------------------------------------------------------- /Practice/datahiding.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | class rectangle{ 4 | private: 5 | int length; 6 | int breath; 7 | public: 8 | int setLength(int l) 9 | { 10 | if(l>=0) 11 | length=l; 12 | else 13 | length=0; 14 | } 15 | int setBreath(int b) 16 | { 17 | if(b>=0) 18 | breath=b; 19 | else 20 | breath=0; 21 | } 22 | int getLength() 23 | { 24 | return length; 25 | } 26 | int getBreath() 27 | { 28 | return breath; 29 | } 30 | int area() 31 | { 32 | return length *breath; 33 | } 34 | }; 35 | int main() 36 | { 37 | rectangle r; 38 | r.setLength(10); 39 | r.setBreath(5); 40 | cout< 2 | using namespace std; 3 | int main() 4 | { 5 | int a=10,b=15; 6 | cout<<"value of a is"<< a <<"address of a is :"<<&a< 7 | using namespace std; 8 | 9 | class A1 10 | { 11 | public: 12 | A1() 13 | { 14 | int a = 20, b = 35, c = 0; 15 | c = a + b; 16 | cout << "sum is:" << c << endl; 17 | } 18 | }; 19 | class A2 20 | { 21 | public: 22 | A2() 23 | { 24 | int x = 50, y = 42, z; 25 | z = x - y; 26 | cout << "difference is:" << z << endl; 27 | } 28 | }; 29 | class s : public A1, public A2 30 | { 31 | public: 32 | s() : A1(), A2() 33 | { 34 | int r = 40, s = 8, t; 35 | t = r * s; 36 | cout << "product is:" << t << endl; 37 | } 38 | }; 39 | int main() 40 | { 41 | s obj; 42 | return 0; 43 | } 44 | -------------------------------------------------------------------------------- /day-09/program_2.cpp: -------------------------------------------------------------------------------- 1 | // Insertion Operator Overloading 2 | #include 3 | using namespace std; 4 | 5 | class Complex 6 | { 7 | private: 8 | int real; 9 | int img; 10 | 11 | public: 12 | Complex(int r = 0, int i = 0) 13 | { 14 | real = r; 15 | img = i; 16 | } 17 | friend ostream &operator<<(ostream &out, const Complex &c); 18 | Complex operator+(const Complex &other) 19 | { 20 | Complex temp; 21 | temp.real = this->real + other.real; 22 | temp.img = this->img + other.img; 23 | return temp; 24 | } 25 | }; 26 | ostream &operator<<(ostream &out, const Complex &c) 27 | { 28 | out << c.real << "+ " << c.img; 29 | return out; 30 | } 31 | int main() 32 | { 33 | Complex c1(4, 3); 34 | Complex c2(3, 4); 35 | Complex c3 = c1 + c2; 36 | 37 | cout << "c1:" << c1 << endl; 38 | cout << "c2:" << c2 << endl; 39 | cout << "c3:" << c3 << endl; 40 | 41 | return 0; 42 | } -------------------------------------------------------------------------------- /day-07/program_4.cpp: -------------------------------------------------------------------------------- 1 | // Data Hiding in CPP 2 | #include 3 | using namespace std; 4 | class Rectangle 5 | { 6 | private: 7 | int length; 8 | int breath; 9 | 10 | public: 11 | void setLength(int l) 12 | { 13 | if (l >= 0) 14 | { 15 | length = l; 16 | } 17 | else 18 | { 19 | length = 0; 20 | } 21 | } 22 | void setBreath(int b) 23 | { 24 | if (b >= 0) 25 | { 26 | breath = b; 27 | } 28 | else 29 | { 30 | breath = 0; 31 | } 32 | } 33 | int getLength() 34 | { 35 | return length; 36 | } 37 | int getbreath() 38 | { 39 | return breath; 40 | } 41 | int area() 42 | { 43 | return length * breath; 44 | } 45 | }; 46 | 47 | int main() 48 | { 49 | Rectangle r; 50 | r.setLength(10); 51 | r.setBreath(20); 52 | cout << r.area() << endl; 53 | cout << "length is" << r.getLength() << endl; 54 | 55 | return 0; 56 | } -------------------------------------------------------------------------------- /day-14/program_4.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | using namespace std; 7 | 8 | int main() { 9 | ifstream inputFile("input.txt"); 10 | ofstream outputFile("output.txt"); 11 | 12 | if (!inputFile.is_open()) { 13 | cerr << "Error opening input file!" << endl; 14 | return 1; 15 | } 16 | 17 | vector data; 18 | 19 | string line; 20 | while (getline(inputFile, line)) { 21 | data.push_back(line); 22 | } 23 | 24 | inputFile.close(); 25 | 26 | cout << "Data from the vector:" << endl; 27 | for (const auto& item : data) { 28 | cout << item << endl; 29 | } 30 | 31 | if (!outputFile.is_open()) { 32 | cerr << "Error opening output file!" << endl; 33 | return 1; 34 | } 35 | 36 | for (const auto& item : data) { 37 | outputFile << item << endl; 38 | } 39 | 40 | outputFile.close(); 41 | 42 | cout << "Data has been written to 'output.txt'" << endl; 43 | 44 | return 0; 45 | } 46 | -------------------------------------------------------------------------------- /day-14/program_3.cpp: -------------------------------------------------------------------------------- 1 | //file handling in vector 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | using namespace std; 8 | 9 | int main() { 10 | ifstream inputFile("input.txt"); 11 | ofstream outputFile("output.txt"); 12 | 13 | if (!inputFile.is_open()) { 14 | cerr << "Error opening input file!" << endl; 15 | return 1; 16 | } 17 | 18 | vector data; 19 | 20 | string line; 21 | while (getline(inputFile, line)) { 22 | data.push_back(line); 23 | } 24 | 25 | inputFile.close(); 26 | 27 | cout << "Data from the vector:" << endl; 28 | for (const auto& item : data) { 29 | cout << item << endl; 30 | } 31 | 32 | if (!outputFile.is_open()) { 33 | cerr << "Error opening output file!" << endl; 34 | return 1; 35 | } 36 | 37 | for (const auto& item : data) { 38 | outputFile << item << endl; 39 | } 40 | 41 | outputFile.close(); 42 | 43 | cout << "Data has been written to 'output.txt'" << endl; 44 | 45 | return 0; 46 | } 47 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2024 RAHUL PRASAD 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /day-13/program_2.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | template 5 | class Stack 6 | { 7 | private: 8 | T* stk; 9 | int top; 10 | int size; 11 | 12 | public: 13 | Stack(int s2) 14 | { 15 | size = s2; 16 | top = -1; 17 | stk = new T[size]; 18 | } 19 | 20 | void push(T x) 21 | { 22 | if (top == size - 1) 23 | { 24 | cout << "Stack is full" << endl; 25 | } 26 | else 27 | { 28 | top++; 29 | stk[top] = x; 30 | } 31 | } 32 | 33 | void pop() 34 | { 35 | if (top == -1) 36 | { 37 | cout << "Stack is empty" << endl; 38 | } 39 | else 40 | { 41 | cout << "Popped element: " << stk[top] << endl; 42 | top--; 43 | } 44 | } 45 | }; 46 | 47 | int main() 48 | { 49 | Stack intStack(5); 50 | intStack.push(1); 51 | intStack.push(2); 52 | intStack.push(3); 53 | intStack.pop(); 54 | 55 | Stack doubleStack(5); 56 | doubleStack.push(1.1); 57 | doubleStack.push(2.2); 58 | doubleStack.push(3.3); 59 | doubleStack.pop(); 60 | 61 | return 0; 62 | } 63 | -------------------------------------------------------------------------------- /Practice/calculator.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | int main() 4 | { 5 | double var1,var2; 6 | beginning: 7 | cout<<"enter the value of the first number"<>var1; 9 | cout<<"enter the value of second number"<>var2; 11 | 12 | char decision; 13 | cout<<"what calculation do you want to perform"<>decision; 19 | 20 | switch(decision) 21 | { 22 | case'+': 23 | cout<>decision2; 41 | 42 | if(decision2=='y'||decision2=='Y') 43 | goto beginning; 44 | 45 | return 0; 46 | } -------------------------------------------------------------------------------- /Practice/inheritance1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | class Rectangle 4 | { 5 | protected: 6 | double length ; 7 | double breadth; 8 | 9 | public: 10 | Rectangle (double l,double b):length(l),breadth(b){} 11 | // { 12 | // length=l; 13 | // breath=b; 14 | // } 15 | double getlength() 16 | { 17 | return length; 18 | } 19 | double getbreadth() 20 | { 21 | return breadth; 22 | } 23 | }; 24 | class Cuboid:public Rectangle 25 | { 26 | private: 27 | double height; 28 | 29 | public: 30 | Cuboid (double l,double b, double h):Rectangle(l,b),height(h){} 31 | // { 32 | // length=l; 33 | // breath=b; 34 | // height=h; 35 | // } 36 | double getheight() 37 | { 38 | return height; 39 | } 40 | double calculateVolume() 41 | { 42 | return length*breadth*height; 43 | } 44 | }; 45 | 46 | int main() 47 | { 48 | double length,breadth,height; 49 | cout<<"enter the length of the cuboid"<>length; 51 | cout<<"enetr the breadth of cuboid"<>breadth; 53 | cout<<"enter the height of the cuboid"<>height; 55 | 56 | Cuboid cuboid(length,breadth,height); 57 | 58 | cout<<"cuboid volume:"< 7 | #include 8 | 9 | using namespace std; 10 | 11 | class Engine 12 | { 13 | private: 14 | int maxSpeed; 15 | 16 | public: 17 | Engine(int speed) : maxSpeed(speed) {} 18 | 19 | void displayInfo() 20 | { 21 | cout << "Max Speed: " << maxSpeed << " mph" << endl; 22 | } 23 | }; 24 | 25 | class Car 26 | { 27 | private: 28 | string color; 29 | Engine carEngine; 30 | 31 | public: 32 | Car(const string &carColor, int engineSpeed) : color(carColor), carEngine(engineSpeed) {} 33 | 34 | void carInfo() 35 | { 36 | cout << "Car color: " << color << endl; 37 | carEngine.displayInfo(); 38 | } 39 | }; 40 | 41 | class SportsCar 42 | { 43 | private: 44 | Car baseCar; 45 | bool isConvertible; 46 | 47 | public: 48 | SportsCar(const string &carColor, int engineSpeed, bool convertible) 49 | : baseCar(carColor, engineSpeed), isConvertible(convertible) {} 50 | 51 | void sportsCarInfo() 52 | { 53 | baseCar.carInfo(); 54 | cout << "Convertible: " << (isConvertible ? "Yes" : "No") << endl; 55 | } 56 | }; 57 | 58 | int main() 59 | { 60 | SportsCar mySportsCar("Red", 200, true); 61 | mySportsCar.sportsCarInfo(); 62 | 63 | return 0; 64 | } 65 | -------------------------------------------------------------------------------- /day-10/program_5.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | *Base class pointer can point on derieved class object. 3 | *But only those functions which are in base class, can be called. 4 | *If derieved class is having overrides functions they will not be called unless base class functions 5 | are declared as virtual. 6 | *Derieved class pointer cannot point on base class object. 7 | */ 8 | #include 9 | 10 | using namespace std; 11 | 12 | class Base 13 | { 14 | public: 15 | virtual void fun1() 16 | { 17 | cout << "fun1 of Base" << endl; 18 | } 19 | 20 | void fun2() 21 | { 22 | cout << "fun2 of Base" << endl; 23 | } 24 | 25 | void fun3() 26 | { 27 | cout << "fun3 of Base" << endl; 28 | } 29 | }; 30 | 31 | class Derived : public Base 32 | { 33 | public: 34 | void fun4() 35 | { 36 | cout << "fun4 of Derived" << endl; 37 | } 38 | 39 | void fun5() 40 | { 41 | cout << "fun5 of Derived" << endl; 42 | } 43 | }; 44 | 45 | int main() 46 | { 47 | Base *p; 48 | p = new Derived(); 49 | 50 | p->fun1(); // This will call the overridden function in Derived if it is declared virtual 51 | p->fun2(); 52 | p->fun3(); 53 | // p->fun4(); // This line will cause a compilation error because fun4 is not in the Base class 54 | // p->fun5(); // This line will cause a compilation error for the same reason 55 | 56 | delete p; // Always delete dynamically allocated memory 57 | 58 | return 0; 59 | } -------------------------------------------------------------------------------- /Practice/filehandling.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | using namespace std; 6 | 7 | class Student 8 | { 9 | private: 10 | string name; 11 | int roll; 12 | string branch; 13 | 14 | public: 15 | Student() {} 16 | Student(string n, int r, string b) 17 | { 18 | name = n; 19 | roll = r; 20 | branch = b; 21 | } 22 | friend ofstream &operator<<(ofstream &ofs, const Student &s); 23 | friend ifstream &operator>>(ifstream &ifs, Student &s); 24 | friend ostream &operator<<(ostream &os, const Student &s); 25 | }; 26 | 27 | ofstream &operator<<(ofstream &ofs, const Student &s) 28 | { 29 | ofs << s.name << endl; 30 | ofs << s.roll << endl; 31 | ofs << s.branch << endl; 32 | return ofs; 33 | } 34 | 35 | ifstream &operator>>(ifstream &ifs, Student &s) 36 | { 37 | ifs >> s.name; 38 | ifs >> s.roll; 39 | ifs >> s.branch; 40 | return ifs; 41 | } 42 | 43 | ostream &operator<<(ostream &os, const Student &s) 44 | { 45 | os << "Name: " << s.name << endl; 46 | os << "Roll: " << s.roll << endl; 47 | os << "Branch: " << s.branch << endl; 48 | return os; 49 | } 50 | 51 | int main() 52 | { 53 | ofstream ofs("Test.txt"); 54 | Student s1("Rahul", 10, "CS"); 55 | ofs << s1; 56 | ofs.close(); 57 | 58 | Student s2; 59 | ifstream ifs("Test.txt"); 60 | ifs >> s2; // Read data into s2 61 | cout << s2; // Display s2 62 | 63 | return 0; 64 | } 65 | -------------------------------------------------------------------------------- /day-08/program_2.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | class Rectangle 5 | { 6 | private: 7 | int length; 8 | int breath; 9 | 10 | public: 11 | Rectangle() 12 | { 13 | length = 0; 14 | breath = 0; 15 | } // Default Constructors 16 | 17 | Rectangle(int l, int b) 18 | { 19 | length = l; 20 | breath = b; 21 | } // Parameterized Constructors 22 | 23 | Rectangle(Rectangle &r) 24 | { 25 | length = r.length; 26 | breath = r.breath; 27 | } // Copy Constructors 28 | 29 | void setLength(int l) 30 | { 31 | length = l; 32 | } // Accessor 33 | 34 | void setBreath(int b) 35 | { 36 | breath = b; 37 | } // Accessor 38 | 39 | int getLength() 40 | { 41 | return length; 42 | } // Mutator 43 | 44 | int getBreath() 45 | { 46 | return breath; 47 | } // Mutator 48 | 49 | int perimeter() 50 | { 51 | return 2 * (length + breath); 52 | } // Facilitaors 53 | 54 | ~Rectangle(); // destructor 55 | }; 56 | 57 | int main() 58 | { 59 | Rectangle r; 60 | cout << "Length: " << r.getLength() << ", Breath: " << r.getBreath() << endl; 61 | 62 | Rectangle r1(5, 10); 63 | cout << "Length: " << r1.getLength() << ", Breath: " << r1.getBreath() << endl; 64 | 65 | Rectangle r2(r1); 66 | cout << "Length: " << r2.getLength() << ", Breath: " << r2.getBreath() << endl; 67 | 68 | r.setLength(3); 69 | r.setBreath(6); 70 | cout << "Perimeter of r: " << r.perimeter() << endl; 71 | 72 | return 0; 73 | } 74 | -------------------------------------------------------------------------------- /day-10/program_4.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Access Specifiers 3 | *Public: All memebers of base will have same accessibility in derieved class. 4 | *Protected: All members of base will become protected in derieved class. 5 | *private: All members of base will become private in derieved class. 6 | */ 7 | #include 8 | using namespace std; 9 | 10 | class Parent 11 | { 12 | private: 13 | int a; 14 | 15 | protected: 16 | int b; 17 | 18 | public: 19 | int c; 20 | 21 | void funcparent() 22 | { 23 | a = 10; // Private member, not accessible in derived classes 24 | b = 20; // Accessible in derived classes 25 | c = 30; // Accessible everywhere 26 | } 27 | }; 28 | 29 | class Child : private Parent 30 | { 31 | private: 32 | // a, b, and c are not directly accessible in Child 33 | public: 34 | void funcChild() 35 | { 36 | // a = 10; // Not accessible, as 'a' is private in the base class 37 | b = 5; // Accessible, as 'b' is protected in the base class 38 | c = 15; // Accessible, as 'c' is public in the base class 39 | } 40 | }; 41 | 42 | class Grandchild : public Child 43 | { 44 | public: 45 | void funcgrandchild() 46 | { 47 | // a = 10; // Not accessible, as 'a' is private in the base class 48 | // b = 5; // Not accessible directly in the derived class 49 | //c = 15; // Accessible, as 'c' is public in the base class 50 | } 51 | }; 52 | 53 | int main() 54 | { 55 | Child c1; 56 | // c1.a = 10; // 'a' is private and not accessible in Child 57 | // c1.b = 5; // 'b' is protected and accessible in Child 58 | //c1.c = 20; // Accessible, as 'c' is public 59 | 60 | return 0; 61 | } -------------------------------------------------------------------------------- /day-10/program_2.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | *IS-A relationship: 3 | In object oriented programming, the concept of IS-A is a totally based on 4 | Inheritance, which can be of two types class Inheritance or Interface Inheritance. 5 | It is just like saying " A is B type of thing." 6 | For Example, Apple is a fruit, Car is a Vehicale etc. 7 | Inheritance is uni-directional. For Example, House is a building. But is not a house. 8 | */ 9 | #include 10 | #include 11 | using namespace std; 12 | 13 | class Car 14 | { 15 | private: 16 | string color; 17 | int maxspeed; 18 | 19 | public: 20 | void carInfo() 21 | { 22 | cout << "Car color: " << color << ", Max speed: " << maxspeed << " mph" << endl; 23 | } 24 | 25 | void setcolor(const string &newcolor) 26 | { 27 | color = newcolor; 28 | } 29 | 30 | void setmaxspeed(int newmaxspeed) 31 | { 32 | maxspeed = newmaxspeed; 33 | } 34 | }; 35 | 36 | class SportsCar : public Car 37 | { 38 | private: 39 | bool isConvertible; 40 | 41 | public: 42 | void sportsCarInfo() 43 | { 44 | carInfo(); // Calling the base class method 45 | cout << "Convertible: " << (isConvertible ? "Yes" : "No") << endl; 46 | } 47 | 48 | void setConvertible(bool convertible) 49 | { 50 | isConvertible = convertible; 51 | } 52 | }; 53 | 54 | int main() 55 | { 56 | SportsCar mySportsCar; 57 | 58 | // Setting Car properties 59 | mySportsCar.setcolor("Red"); 60 | mySportsCar.setmaxspeed(200); 61 | 62 | // Setting SportsCar specific property 63 | mySportsCar.setConvertible(true); 64 | 65 | // Displaying information 66 | mySportsCar.sportsCarInfo(); 67 | 68 | return 0; 69 | } 70 | -------------------------------------------------------------------------------- /day-09/program_4.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | class Rectangle 5 | { 6 | private: 7 | int length; 8 | int breadth; 9 | 10 | public: 11 | Rectangle(int l = 0, int b = 0) 12 | { 13 | setLength(l); 14 | setBreadth(b); 15 | } 16 | 17 | int getLength() 18 | { 19 | return length; 20 | } 21 | 22 | int getBreadth() 23 | { 24 | return breadth; 25 | } 26 | 27 | void setLength(int l) 28 | { 29 | if (l >= 0) 30 | { 31 | length = l; 32 | } 33 | else 34 | { 35 | length = 0; 36 | } 37 | } 38 | 39 | void setBreadth(int b) 40 | { 41 | if (b >= 0) 42 | { 43 | breadth = b; 44 | } 45 | else 46 | { 47 | breadth = 0; 48 | } 49 | } 50 | 51 | int area() 52 | { 53 | return length * breadth; 54 | } 55 | }; 56 | 57 | class Cuboid : public Rectangle 58 | { 59 | private: 60 | int height; 61 | 62 | public: 63 | Cuboid(int l = 0, int b = 0, int h = 0) : Rectangle(l, b) 64 | { 65 | setHeight(h); 66 | } 67 | 68 | int getHeight() 69 | { 70 | return height; 71 | } 72 | 73 | void setHeight(int h) 74 | { 75 | if (h >= 0) 76 | { 77 | height = h; 78 | } 79 | else 80 | { 81 | height = 0; 82 | } 83 | } 84 | 85 | int volume() 86 | { 87 | return getLength() * getBreadth() * getHeight(); 88 | } 89 | }; 90 | 91 | int main() 92 | { 93 | Rectangle r(10, 20); 94 | cout << "Rectangle Area: " << r.area() << endl; 95 | cout << "Length is: " << r.getLength() << endl; 96 | 97 | Cuboid c(5, 10, 15); 98 | cout << "Cuboid Volume: " << c.volume() << endl; 99 | 100 | return 0; 101 | } 102 | -------------------------------------------------------------------------------- /Practice/vectorfile.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | using namespace std; 5 | 6 | class Item 7 | { 8 | private: 9 | string name; 10 | float price; 11 | int qty; 12 | 13 | public: 14 | Item() {} // Default constructor for the Item class 15 | Item(string n, float p, int q); // Constructor with parameters for Item 16 | friend istream &operator>>(istream &is, Item &i); // Overloaded input operator 17 | friend ostream &operator<<(ostream &os, const Item &i); // Overloaded output operator 18 | }; 19 | 20 | int main() 21 | { 22 | int n; 23 | cout << "Enter number of Items: "; 24 | cin >> n; // Read the number of items to be entered by the user 25 | 26 | vector list; // Create a vector to store Item objects 27 | 28 | cout << "Enter All Items: " << endl; 29 | for (int i = 0; i < n; i++) 30 | { 31 | Item item; // Create an Item object to hold user input 32 | cout << "Enter Item " << i + 1 << " Name, price, and quantity: "; 33 | cin >> item; // Read item data from the user 34 | list.push_back(item); // Add the item to the vector 35 | } 36 | 37 | ofstream fos("Items.txt"); // Open a file stream for writing 38 | for (const Item &item : list) 39 | { 40 | fos << item << endl; // Write each item to the file 41 | } 42 | 43 | Item item; 44 | ifstream fis("Items.txt"); // Open a file stream for reading 45 | for (int i = 0; i < n; i++) 46 | { 47 | fis >> item; // Read item data from the file 48 | cout << "Item " << i << ":" << endl 49 | << item << endl; // Display the item's details 50 | } 51 | } 52 | 53 | Item::Item(string n, float p, int q) 54 | { 55 | name = n; 56 | price = p; 57 | qty = q; 58 | } 59 | 60 | istream &operator>>(istream &is, Item &i) 61 | { 62 | is >> i.name >> i.price >> i.qty; // Read item data from the input stream 63 | return is; 64 | } 65 | 66 | ostream &operator<<(ostream &os, const Item &i) 67 | { 68 | os << "Name: " << i.name << endl; // Display the item's name 69 | os << "Price: $" << i.price << endl; // Display the item's price 70 | os << "Quantity: " << i.qty << endl; // Display the item's quantity 71 | return os; 72 | } 73 | -------------------------------------------------------------------------------- /day-09/program_5.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | class Rectangle 5 | { 6 | private: 7 | double length; 8 | double breadth; 9 | 10 | public: 11 | Rectangle(double l = 0, double b = 0) 12 | { 13 | setLength(l); 14 | setBreadth(b); 15 | } 16 | 17 | double getLength() 18 | { 19 | return length; 20 | } 21 | 22 | double getBreadth() 23 | { 24 | return breadth; 25 | } 26 | 27 | void setLength(double l) 28 | { 29 | if (l >= 0) 30 | { 31 | length = l; 32 | } 33 | else 34 | { 35 | length = 0; 36 | } 37 | } 38 | 39 | void setBreadth(double b) 40 | { 41 | if (b >= 0) 42 | { 43 | breadth = b; 44 | } 45 | else 46 | { 47 | breadth = 0; 48 | } 49 | } 50 | 51 | double area() 52 | { 53 | return length * breadth; 54 | } 55 | }; 56 | 57 | class Cuboid : public Rectangle 58 | { 59 | private: 60 | double height; 61 | 62 | public: 63 | Cuboid(double l = 0, double b = 0, double h = 0) : Rectangle(l, b) 64 | { 65 | setHeight(h); 66 | } 67 | 68 | double getHeight() 69 | { 70 | return height; 71 | } 72 | 73 | void setHeight(double h) 74 | { 75 | if (h >= 0) 76 | { 77 | height = h; 78 | } 79 | else 80 | { 81 | height = 0; 82 | } 83 | } 84 | 85 | double volume() 86 | { 87 | return getLength() * getBreadth() * getHeight(); 88 | } 89 | }; 90 | 91 | int main() 92 | { 93 | double length, breadth, height; 94 | 95 | cout << "Enter length of the rectangle: "; 96 | cin >> length; 97 | 98 | cout << "Enter breadth of the rectangle: "; 99 | cin >> breadth; 100 | 101 | Rectangle r(length, breadth); 102 | cout << "Rectangle Area: " << r.area() << endl; 103 | cout << "Length is: " << r.getLength() << endl; 104 | 105 | cout << "\nEnter length of the cuboid: "; 106 | cin >> length; 107 | 108 | cout << "Enter breadth of the cuboid: "; 109 | cin >> breadth; 110 | 111 | cout << "Enter height of the cuboid: "; 112 | cin >> height; 113 | 114 | Cuboid c(length, breadth, height); 115 | cout << "Cuboid Volume: " << c.volume() << endl; 116 | 117 | return 0; 118 | } 119 | -------------------------------------------------------------------------------- /Practice/storehandling.cpp: -------------------------------------------------------------------------------- 1 | #include // Include the input/output stream library 2 | #include // Include the file stream library 3 | #include // Include the vector container from the C++ Standard Library 4 | 5 | using namespace std; // Use the standard C++ namespace to simplify code 6 | 7 | class Item { 8 | private: 9 | string name; 10 | float price; 11 | int qty; 12 | 13 | public: 14 | Item() {} // Default constructor 15 | Item(string n, float p, int q); // Parameterized constructor 16 | friend ifstream& operator>>(ifstream& fis, Item& i); // Friend function for reading from a file 17 | friend ofstream& operator<<(ofstream& fos, const Item& i); // Friend function for writing to a file 18 | friend ostream& operator<<(ostream& os, const Item& i); // Friend function for displaying to the console 19 | }; 20 | 21 | int main() { 22 | int n; // Number of items 23 | string name; 24 | float price; 25 | int qty; 26 | 27 | cout << "Enter number of Items: "; 28 | cin >> n; // Read the number of items from the user 29 | 30 | vector itemList; // Create a vector to store the items 31 | 32 | cout << "Enter All Items" << endl; 33 | for (int i = 0; i < n; i++) { 34 | cout << "Enter Item " << i + 1 << " Name, Price, and Quantity: "; 35 | cin >> name >> price >> qty; // Read item details from the user 36 | itemList.push_back(Item(name, price, qty)); // Add the item to the vector 37 | } 38 | 39 | ofstream fos("Items.txt"); // Open a file for writing 40 | for (const Item& item : itemList) { 41 | fos << item; // Write each item to the file 42 | } 43 | 44 | Item item; 45 | ifstream fis("Items.txt"); // Open the file for reading 46 | cout << "Items read from file:" << endl; 47 | for (int i = 0; i < n; i++) { 48 | fis >> item; // Read each item from the file 49 | cout << "Item " << i << ": " << item << endl; // Display the item to the console 50 | } 51 | 52 | return 0; 53 | } 54 | 55 | Item::Item(string n, float p, int q) { 56 | name = n; 57 | price = p; 58 | qty = q; 59 | } 60 | 61 | ofstream& operator<<(ofstream& fos, const Item& i) { 62 | fos << i.name << endl << i.price << endl << i.qty << endl; // Write item details to the file 63 | return fos; 64 | } 65 | 66 | ifstream& operator>>(ifstream& fis, Item& i) { 67 | fis >> i.name >> i.price >> i.qty; // Read item details from the file 68 | return fis; 69 | } 70 | 71 | ostream& operator<<(ostream& os, const Item& i) { 72 | os << "Name: " << i.name << endl << "Price: " << i.price << endl << "Quantity: " << i.qty << endl; // Display item details to the console 73 | return os; 74 | } 75 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Programming in C/C++ Efficiently 2 | ================================ 3 | 4 | Git Repository Overview 5 | ----------------------- 6 | 7 | This Git repository serves as a comprehensive resource for mastering C++ basics and Object-Oriented Programming (OOP) concepts. Whether you're a beginner or an experienced programmer, this repository is designed to provide a well-organized collection of programs, tutorials, and documentation to enhance your C++ development skills. 8 | 9 | ### Key Features: 10 | 11 | 1. ### Fundamental Syntax: 12 | 13 | * Explore the core syntax of C++ programming language. 14 | * Understand data types, variables, and basic operations. 15 | 2. ### Object-Oriented Programming (OOP) Concepts: 16 | 17 | * Learn essential OOP principles such as encapsulation, inheritance, and polymorphism. 18 | * Apply OOP concepts to design and structure your programs efficiently. 19 | 3. ### Examples and Exercises: 20 | 21 | * Engage in hands-on practice with a multitude of examples and exercises. 22 | * Reinforce your understanding of key concepts through practical application. 23 | 24 | DAY 1: Getting Started 25 | ---------------------- 26 | 27 | ### 1\. The First Example: 28 | 29 | Write a Cpp program to print hello world. 30 | 31 | ### 2\. The Second Example: 32 | 33 | Write a cpp program to print hello world using namespace std. 34 | 35 | ### 3\. The Third Example: 36 | 37 | Write a cpp using the function endl. 38 | 39 | ### 4\. The fourth Example: 40 | 41 | Write a Cpp program using the function endl. 42 | 43 | ### 5\. The Fifth Example: 44 | 45 | Write a Cpp program using the basic Arithmethic operators. 46 | 47 | DAY 2: Moving On 48 | ---------------------- 49 | 50 | ### 1\. The First Example: 51 | 52 | Write a Cpp program for different types of data types. 53 | 54 | ### 2\. The Second Example: 55 | 56 | Write a cpp program to enter the values in the ruun time and display them. 57 | 58 | ### 3\. The Third Example: 59 | 60 | Write a cpp program to implement simple arrays or array basics. 61 | 62 | ### 4\. The fourth Example: 63 | 64 | Write a Cpp program to use for loop and traverse a 1d array. 65 | 66 | ### 5\. The Fifth Example: 67 | 68 | Write a Cpp program using while loop and do while loop. 69 | 70 | DAY 3: Challenges 71 | ---------------------- 72 | 73 | ### 1\. The First Example: 74 | 75 | Write a Cpp program using for each loop to implement arrays. 76 | 77 | ### 2\. The Second Example: 78 | 79 | Write a cpp program to implement Auto using for each loop . 80 | 81 | ### 3\. The Third Example: 82 | 83 | Write a cpp program to find the sum of the array elements. 84 | 85 | ### 4\. The fourth Example: 86 | 87 | Write a Cpp program to find max elemnt in the array. 88 | 89 | ### 5\. The Fifth Example: 90 | 91 | Write a Cpp program for binary search. 92 | 93 | DAY 4: Exploration 94 | ---------------------- 95 | 96 | ### 1\. The First Example: 97 | 98 | Write a Cpp program to implement a pattern. 99 | 100 | ### 2\. The Second Example: 101 | 102 | Write a cpp program to implement a pattern. 103 | 104 | ### 3\. The Third Example: 105 | 106 | Write a cpp program to implement a pattern. 107 | 108 | ### 4\. The fourth Example: 109 | 110 | Write a Cpp program to implement 2D arrays. 111 | 112 | ### 5\. The Fifth Example: 113 | 114 | Write a Cpp program for to implement a 2d array using for each. 115 | 116 | DAY 5: Creativity. 117 | ---------------------- 118 | 119 | ### 0\. Some Basic Concepts: 120 | 121 | ### 1\. The First Example: 122 | 123 | Write a Cpp program using pointers and do some traversal. 124 | 125 | ### 2\. The Second Example: 126 | 127 | Write a cpp program for allocation and deallocation in pointers. 128 | 129 | ### 3\. The Third Example: 130 | 131 | Write a cpp program to create a reference pointer using pointer location. 132 | 133 | ### 4\. The fourth Example: 134 | 135 | Write a Cpp program to implement pointer to function in CPP. 136 | 137 | ### 5\. The Fifth Example: 138 | 139 | Write a Cpp program to implement pointer to function and find the min value of the two arguments. 140 | 141 | 142 | DAY 6: Persistence. 143 | ---------------------- 144 | 145 | ### 0\. Some Basic Concepts: 146 | 147 | ### 1\. The First Example: 148 | 149 | Write a Cpp program to implement simple fumctions. 150 | 151 | ### 2\. The Second Example: 152 | 153 | Write a cpp program to implement function overloading. 154 | 155 | ### 3\. The Third Example: 156 | 157 | Write a cpp program to implement function template. 158 | 159 | ### 4\. The fourth Example: 160 | 161 | Write a Cpp program to implement function template . 162 | 163 | ### 5\. The Fifth Example: 164 | 165 | Write a Cpp program to implement function template using public and private functions template. 166 | 167 | Object Oriented Programming starts 168 | 169 | DAY 7: Optimization. 170 | ---------------------- 171 | 172 | ### 0\. Some Basic Concepts: 173 | 174 | ### 1\. The First Example: 175 | 176 | Write a Cpp program to implement class. 177 | 178 | ### 2\. The Second Example: 179 | 180 | Write a cpp program to implement pointer to class. 181 | 182 | ### 3\. The Third Example: 183 | 184 | Write a cpp program to implement heap to class. 185 | 186 | ### 4\. The fourth Example: 187 | 188 | Write a Cpp program to implement Data Hiding in CPP . 189 | 190 | ### 5\. The Fifth Example: 191 | 192 | Write a Cpp program to implement Data Hiding in CPP. 193 | 194 | DAY 8: Adaptability. 195 | ---------------------- 196 | 197 | ### 0\. Some Basic Concepts: 198 | 199 | ### 1\. The First Example: 200 | 201 | Write a Cpp program to implement Constructors. 202 | 203 | ### 2\. The Second Example: 204 | 205 | Write a cpp program to implement Types of Constructors. 206 | 207 | ### 3\. The Third Example: 208 | 209 | Write a cpp program to implement Scope Resolution Operator. 210 | 211 | ### 4\. The fourth Example: 212 | 213 | Write a Cpp program to implement Inline Functions . 214 | 215 | ### 5\. The Fifth Example: 216 | 217 | Write a Cpp program to implement Operator Overloading. 218 | 219 | DAY 9: Innovation. 220 | ---------------------- 221 | 222 | ### 0\. Some Basic Concepts: 223 | 224 | ### 1\. The First Example: 225 | 226 | Write a Cpp program to implement Friend Operator Overloading. 227 | 228 | ### 2\. The Second Example: 229 | 230 | Write a cpp program to implement Insertion Operator Overloading. 231 | 232 | ### 3\. The Third Example: 233 | 234 | Write a cpp program to implement Inheritance. 235 | 236 | ### 4\. The fourth Example: 237 | 238 | Write a Cpp program to implement Inheritance. 239 | 240 | ### 5\. The Fifth Example: 241 | 242 | Write a Cpp program to implement Inheritance. 243 | 244 | DAY 10: Reflection. 245 | ---------------------- 246 | 247 | ### 1\. The First Example: 248 | 249 | Write a Cpp program to implement Constructors in Class Member. 250 | 251 | ### 2\. The Second Example: 252 | 253 | Write a cpp program to implement Is-A relationship. 254 | 255 | ### 3\. The Third Example: 256 | 257 | Write a cpp program to implement Has-A relationship. 258 | 259 | ### 4\. The fourth Example: 260 | 261 | Write a Cpp program to implement Access Specifiers. 262 | 263 | ### 5\. The Fifth Example: 264 | 265 | Write a Cpp program to implement Base Class Pointers. 266 | 267 | DAY 11: Determination. 268 | ---------------------- 269 | 270 | ### 0\. Some Basic Concepts: 271 | 272 | ### 1\. The First Example: 273 | 274 | Write a Cpp program to implement Function Overloading in Polymorphism. 275 | 276 | ### 2\. The Second Example: 277 | 278 | Write a cpp program to implement Virtual Functions. 279 | 280 | ### 3\. The Third Example: 281 | 282 | Write a cpp program to implement Virtual polymorphism 283 | 284 | ### 4\. The fourth Example: 285 | 286 | Write a Cpp program to implement Runtime polymorphism. 287 | 288 | ### 5\. The Fifth Example: 289 | 290 | Write a Cpp program to implement Runtime polymorphism. 291 | 292 | DAY 12: Consistency. 293 | ---------------------- 294 | 295 | ### 0\. Some Basic Concepts: 296 | 297 | ### 1\. The First Example: 298 | 299 | Write a Cpp program to implement Abstract classes. 300 | 301 | ### 2\. The Second Example: 302 | 303 | Write a cpp program to implement Friend Function and Classes. 304 | 305 | ### 3\. The Third Example: 306 | 307 | Write a cpp program to implement Static Members. 308 | 309 | ### 4\. The fourth Example: 310 | 311 | Write a Cpp program to implement Static members. 312 | 313 | ### 5\. The Fifth Example: 314 | 315 | Write a Cpp program to implement Nested classes in CPP. 316 | 317 | DAY 13: Resilience. 318 | ---------------------- 319 | 320 | ### 0\. Some Basic Concepts: 321 | 322 | ### 1\. The First Example: 323 | 324 | Write a Cpp program to implement Exception Handling. 325 | 326 | ### 2\. The Second Example: 327 | 328 | Write a cpp program to implement Template functions and classes. 329 | 330 | ### 3\. The Third Example: 331 | 332 | Write a cpp program to implement Constructors. 333 | 334 | ### 4\. The fourth Example: 335 | 336 | Write a Cpp program to implement Destructors. 337 | 338 | ### 5\. The Fifth Example: 339 | 340 | Write a Cpp program to implement IO streams. 341 | 342 | DAY 14: Learning Never Ends. 343 | ---------------------- 344 | 345 | ### 0\. Some Basic Concepts: 346 | 347 | ### 1\. The First Example: 348 | 349 | Write a Cpp program to implement Vector. 350 | 351 | ### 2\. The Second Example: 352 | 353 | Write a cpp program to implement Maps. 354 | 355 | ### 3\. The Third Example: 356 | 357 | Write a cpp program to implement File handling in Vector. 358 | 359 | ### 4\. The fourth Example: 360 | 361 | Write a Cpp program to implement File handling in Vector. 362 | 363 | ### 5\. The Fifth Example: 364 | 365 | Write a Cpp program to implement Maps. 366 | 367 | 368 | Next Steps: 369 | ----------- 370 | 371 | Continue your learning journey by exploring the examples and exercises provided in this repository. Gain practical experience to solidify your grasp of C++ programming and OOP principles. 372 | 373 | 374 | C++ Projects Showcase 375 | ===================== 376 | 377 | 1\. Snake Game 378 | ------------------ 379 | 380 | 2\. Tic Tac Game 381 | ------------------ 382 | 383 | 3\. Guess The Number 384 | ------------------ 385 | 386 | 4\. Calculator 387 | ------------------ 388 | 389 | 5\. Rock Paper Scissors 390 | ------------------ 391 | 392 | 5\. Power Options 393 | ------------------ 394 | 395 | 6\. HangMang Game 396 | ------------------ 397 | 398 | 7\. Base Converter Program 399 | ------------------ 400 | 401 | Happy coding! 402 | --------------------------------------------------------------------------------