├── Module 1 ├── .gitignore ├── float_output.cpp ├── header_file.cpp ├── input.cpp ├── min_max.cpp ├── output.cpp ├── string_input.cpp ├── swap.cpp ├── switch_case.cpp ├── switch_case_2.cpp ├── switch_case_3.cpp └── test.cpp ├── Module 2 ├── .gitignore ├── dynamic_array.cpp ├── dynamic_array_size_increase.cpp ├── dynamic_data.cpp ├── return_array_from_function.cpp ├── static_data.cpp └── ternary_operator.cpp ├── Module 3 ├── .gitignore ├── class_and_object.cpp ├── constructor.cpp ├── dynamic_object.cpp ├── return_object_from_function.cpp └── sorting.cpp ├── Module 5 ├── .gitignore ├── capacity.cpp ├── element_access.cpp ├── iterator.cpp ├── modifiers.cpp ├── string.cpp ├── string_input_space.cpp └── stringstream.cpp ├── Module 6.5 ├── .gitignore ├── P_Count_Words.cpp └── find.cpp ├── Module 6 ├── .gitignore ├── dynamic_object_copy.cpp ├── function_in_class.cpp ├── namespaces.cpp ├── ranged_based_for_loop.cpp ├── reference.cpp ├── reverse_word_printing.cpp ├── sort_string.cpp ├── string_constructor.cpp └── this_keyword.cpp ├── Module 7 ├── array_of_objects.cpp ├── counting_sort.cpp ├── custom_sort_using_frequency_object_array.cpp ├── max_from_objects.cpp ├── sort_array_using_selection_sort.cpp └── sort_array_using_sort_function.cpp └── README.md /Module 1/.gitignore: -------------------------------------------------------------------------------- 1 | .cph/ 2 | .vscode/ 3 | *.txt 4 | *.exe 5 | *.bin -------------------------------------------------------------------------------- /Module 1/float_output.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | int main() 5 | { 6 | float a; 7 | cin>>a; 8 | cout< 2 | using namespace std; 3 | int main() 4 | { 5 | 6 | return 0; 7 | } -------------------------------------------------------------------------------- /Module 1/input.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | int main() 4 | { 5 | int a,b; 6 | // scanf("%d %d",&a,&b); 7 | cin>>a>>b; 8 | cout<"< 2 | #include 3 | using namespace std; 4 | // int my_min(int a,int b) 5 | // { 6 | // if(ab) return a; 12 | // else return b; 13 | // } 14 | int main() 15 | { 16 | int a,b; 17 | cin>>a>>b; 18 | int mn=min(a,b); 19 | int mx=max(a,b); 20 | cout< 2 | using namespace std; 3 | int main() 4 | { 5 | // printf("Hello World"); -> for c 6 | // std::cout<<"Hello World"; 7 | // std::cout<<"Hello\n"; 8 | // std::cout<<"World\n"; 9 | // std::cout<<"Hello "<<"World"; 10 | // std::cout<<"Hello"< 2 | #include 3 | using namespace std; 4 | int main() 5 | { 6 | char s[100]; 7 | cin.getline(s,100); 8 | cout< 2 | #include 3 | using namespace std; 4 | // void my_swap(int *a,int *b) 5 | // { 6 | // int tmp=*a; 7 | // *a=*b; 8 | // *b=tmp; 9 | // } 10 | int main() 11 | { 12 | int a,b; 13 | cin>>a>>b; 14 | swap(a,b); 15 | cout< 2 | using namespace std; 3 | int main() 4 | { 5 | int v; 6 | cin>>v; 7 | switch(v) 8 | { 9 | case 1: 10 | cout<<"One"< 2 | using namespace std; 3 | int main() 4 | { 5 | char a; 6 | cin>>a; 7 | switch(a) 8 | { 9 | case 'a': 10 | cout<<"Vowel"< 2 | using namespace std; 3 | int main() 4 | { 5 | int a; 6 | cin>>a; 7 | switch(a%2) // 0 or 1 8 | { 9 | case 0: 10 | cout<<"Even"< 2 | int main() 3 | { 4 | printf("Hello"); 5 | return 0; 6 | } -------------------------------------------------------------------------------- /Module 2/.gitignore: -------------------------------------------------------------------------------- 1 | .cph/ 2 | .vscode/ 3 | *.txt 4 | *.exe 5 | *.bin -------------------------------------------------------------------------------- /Module 2/dynamic_array.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | int main() 4 | { 5 | int * a=new int[5]; // int a[5] 6 | for(int i=0;i<5;i++) 7 | { 8 | cin>>a[i]; 9 | } 10 | for(int i=0;i<5;i++) 11 | { 12 | cout< 2 | using namespace std; 3 | int main() 4 | { 5 | int *a=new int[5]; 6 | for(int i=0;i<5;i++) 7 | { 8 | cin>>a[i]; 9 | } 10 | int *b=new int[7]; 11 | for(int i=0;i<5;i++) 12 | { 13 | b[i]=a[i]; 14 | } 15 | b[5]=60; 16 | b[6]=70; 17 | for(int i=0;i<7;i++) 18 | { 19 | cout< 2 | using namespace std; 3 | int main() 4 | { 5 | // int * a=new int; // syntax 6 | // *a=10; 7 | // cout<<*a< 2 | using namespace std; 3 | int* fun() 4 | { 5 | int *a=new int[5]; 6 | // int a[5]; 7 | for(int i=0;i<5;i++) 8 | { 9 | cin>>a[i]; 10 | } 11 | return a; 12 | } 13 | int main() 14 | { 15 | int *a=fun(); 16 | for(int i=0;i<5;i++) 17 | { 18 | cout< 2 | using namespace std; 3 | int main() 4 | { 5 | int x=10; 6 | return 0; 7 | } -------------------------------------------------------------------------------- /Module 2/ternary_operator.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | int main() 4 | { 5 | int x=10; 6 | // if(x%2==0) 7 | // { 8 | // cout<<"Even"; 9 | // } 10 | // else 11 | // { 12 | // cout<<"Odd"; 13 | // } 14 | // ternary 15 | (x%2==0)? cout<<"Even" : cout<<"Odd"; 16 | return 0; 17 | } -------------------------------------------------------------------------------- /Module 3/.gitignore: -------------------------------------------------------------------------------- 1 | .cph/ 2 | .vscode/ 3 | *.txt 4 | *.exe 5 | *.bin -------------------------------------------------------------------------------- /Module 3/class_and_object.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | class Student 4 | { 5 | public: 6 | char name[100]; 7 | int roll; 8 | int cls; 9 | char section; 10 | }; 11 | int main() 12 | { 13 | Student rahim; 14 | rahim.roll=29; 15 | rahim.cls=9; 16 | rahim.section='A'; 17 | char nm[100]="Rahim Uddin"; 18 | strcpy(rahim.name,nm); 19 | 20 | Student karim; 21 | karim.roll=55; 22 | karim.cls=9; 23 | karim.section='C'; 24 | char nm2[100]="Karim Cholimulla"; 25 | strcpy(karim.name,nm2); 26 | 27 | cout< 2 | using namespace std; 3 | class Student 4 | { 5 | public: 6 | char name[100]; 7 | int roll; 8 | int cls; 9 | char section; 10 | 11 | Student(int r,char s,int c,char* n) 12 | { 13 | roll=r; 14 | section=s; 15 | cls=c; 16 | strcpy(name,n); 17 | } 18 | }; 19 | int main() 20 | { 21 | Student rahim(29,'A',7,"Rahim Ullah"); 22 | Student karim(55,'D',7,"Karim Cholimullah"); 23 | 24 | 25 | 26 | cout< 2 | using namespace std; 3 | class Student 4 | { 5 | public: 6 | char name[100]; 7 | int roll; 8 | int cls; 9 | char section; 10 | 11 | Student(int r,char s,int c,char* n) 12 | { 13 | roll=r; 14 | section=s; 15 | cls=c; 16 | strcpy(name,n); 17 | } 18 | }; 19 | int main() 20 | { 21 | char name[100]="Rahim Ullah"; 22 | // Student rahim(5,'A',11,name); 23 | Student* rahim = new Student(5,'A',11,name); 24 | (*rahim).roll=55; 25 | 26 | // int * a = new int; 27 | // *a=10; 28 | // cout<<*a< 38 | 39 | cout<name<roll<section<cls<name<roll<section<cls< 2 | using namespace std; 3 | class Student 4 | { 5 | public: 6 | char name[100]; 7 | int roll; 8 | int cls; 9 | char section; 10 | 11 | Student(int r,char s,int c,char* n) 12 | { 13 | roll=r; 14 | section=s; 15 | cls=c; 16 | strcpy(name,n); 17 | } 18 | }; 19 | Student fun() 20 | { 21 | char name[100]="Rahim Ullah"; 22 | Student r(29,'C',7,name); 23 | return r; 24 | } 25 | int main() 26 | { 27 | Student rahim=fun(); 28 | 29 | cout< 2 | using namespace std; 3 | int main() 4 | { 5 | int n; 6 | cin>>n; 7 | int a[n]; 8 | for(int i=0;i>a[i]; 11 | } 12 | // sorting ascending 13 | // sort(a,a+n); 14 | // sorting descending 15 | // sort(a,a+n,greater()); 16 | for(int i=0;i 2 | using namespace std; 3 | int main() 4 | { 5 | // string s="Hello World"; 6 | // cout<>s; 27 | // s.resize(5); 28 | // s.resize(20,'X'); 29 | // cout< 2 | using namespace std; 3 | int main() 4 | { 5 | string s; 6 | cin>>s; 7 | cout< 2 | using namespace std; 3 | int main() 4 | { 5 | string s; 6 | cin>>s; 7 | // for(int i=0;i 2 | using namespace std; 3 | int main() 4 | { 5 | // string a="Hello"; 6 | // string b="A"; 7 | // a+=b; 8 | // a.append(b); 9 | // cout< works 12 | // a=a+"A"; -> works 13 | // a[5]='A'; -> didn't work 14 | // a.push_back('A'); // works 15 | // a.pop_back(); 16 | // a.pop_back(); 17 | // cout< 2 | using namespace std; 3 | int main() 4 | { 5 | string s1="Hello"; 6 | string s2="hello"; 7 | if(s1 == s2) 8 | { 9 | cout<<"Same"< 2 | using namespace std; 3 | int main() 4 | { 5 | int x; 6 | cin>>x; 7 | // cin.ignore(); 8 | getchar(); 9 | string s; 10 | // cin>>s; 11 | // cin.getline(s,100); char s[100]; 12 | getline(cin,s); 13 | cout< 2 | using namespace std; 3 | int main() 4 | { 5 | string s; 6 | getline(cin,s); 7 | stringstream ss; 8 | ss<> word) 12 | { 13 | cnt++; 14 | } 15 | cout< 2 | using namespace std; 3 | int main() 4 | { 5 | string s; 6 | getline(cin,s); 7 | bool inside_word=false; 8 | int cnt=0; 9 | for(char c:s) 10 | { 11 | if(isalpha(c)) 12 | { 13 | if(inside_word==false) 14 | { 15 | cnt++; 16 | } 17 | inside_word=true; 18 | } 19 | else 20 | { 21 | inside_word=false; 22 | } 23 | } 24 | cout< 2 | using namespace std; 3 | int main() 4 | { 5 | string s="BRITISHEGYPTGHANA"; 6 | int t=s.find("EGYPT"); 7 | cout< 2 | using namespace std; 3 | class Person 4 | { 5 | public: 6 | string name; 7 | int age; 8 | Person(string name,int age) 9 | { 10 | this->name=name; 11 | this->age=age; 12 | } 13 | }; 14 | int main() 15 | { 16 | Person* rakib=new Person("Rakib Ahsan",25); 17 | Person* sakib=new Person("Sakib Ahamed",23); 18 | 19 | // rakib=sakib; 20 | // rakib->name=sakib->name; 21 | // rakib->age=sakib->age; 22 | *rakib=*sakib; 23 | delete sakib; 24 | cout<name<<" "<age< 2 | using namespace std; 3 | class Person 4 | { 5 | public: 6 | string name; 7 | int age; 8 | int marks1; 9 | int marks2; 10 | Person(string nm,int ag,int m1,int m2) 11 | { 12 | name=nm; 13 | age=ag; 14 | marks1=m1; 15 | marks2=m2; 16 | } 17 | void hello() 18 | { 19 | cout< 2 | using namespace std; 3 | namespace Rakib 4 | { 5 | int age=24; 6 | void hello() 7 | { 8 | cout<<"Rakib namespaces"< 2 | using namespace std; 3 | int main() 4 | { 5 | string s; 6 | cin>>s; 7 | // for(int i=0;i 2 | using namespace std; 3 | void print(string s) 4 | { 5 | s="world"; 6 | } 7 | int main() 8 | { 9 | string s="hello"; 10 | print(s); 11 | cout< 2 | using namespace std; 3 | void print(stringstream& ss) 4 | { 5 | string word; 6 | if(ss>>word) 7 | { 8 | 9 | print(ss); 10 | cout< 2 | using namespace std; 3 | int main() 4 | { 5 | string s; 6 | cin>>s; 7 | sort(s.begin(),s.end()); 8 | cout< 2 | using namespace std; 3 | int main() 4 | { 5 | // string s="hello world"; 6 | // 1 7 | // string s("hello world"); 8 | // 2 9 | // string s("hello world",7); 10 | // 3 11 | // string a="hello world"; 12 | // string s(a,4); 13 | // 4 14 | string s(26,'A'); 15 | cout< 2 | using namespace std; 3 | class Person 4 | { 5 | public: 6 | string name; 7 | int age; 8 | Person(string name,int age) 9 | { 10 | this->name=name; 11 | this->age=age; 12 | } 13 | void hello() 14 | { 15 | cout<<"Hello"< 2 | using namespace std; 3 | class Student 4 | { 5 | public: 6 | string name; 7 | int roll; 8 | int marks; 9 | }; 10 | int main() 11 | { 12 | Student a[3]; 13 | for(int i=0;i<3;i++) 14 | { 15 | getline(cin,a[i].name); 16 | cin>>a[i].roll>>a[i].marks; 17 | cin.ignore(); 18 | } 19 | for(int i=0;i<3;i++) 20 | { 21 | cout< 2 | using namespace std; 3 | int main() 4 | { 5 | int n; 6 | cin>>n; 7 | int frq[26]={0}; 8 | for(int i=0;i>a; 12 | frq[a-'a']++; 13 | } 14 | for(char i='a';i<='z';i++) 15 | { 16 | if(frq[i-'a'] > 0) 17 | { 18 | for(int j=0;j 2 | using namespace std; 3 | class CustomSort 4 | { 5 | public: 6 | char c; 7 | int cnt; 8 | }; 9 | bool cmp(CustomSort a, CustomSort b) 10 | { 11 | if(a.cnt > b.cnt) return true; 12 | else return false; 13 | } 14 | int main() 15 | { 16 | int n; 17 | cin>>n; 18 | // int frq[26]={0}; 19 | CustomSort frq[26]; 20 | for(int i=0;i<26;i++) 21 | { 22 | frq[i].c=(i+'a'); 23 | frq[i].cnt=0; 24 | } 25 | for(int i=0;i>c; 29 | frq[c-'a'].cnt++; 30 | } 31 | sort(frq,frq+26,cmp); 32 | for(int i=0;i<26;i++) 33 | { 34 | if(frq[i].cnt>0) 35 | { 36 | for(int j=0;j 2 | using namespace std; 3 | class Student 4 | { 5 | public: 6 | string name; 7 | int roll; 8 | int marks; 9 | }; 10 | int main() 11 | { 12 | Student a[3]; 13 | for(int i=0;i<3;i++) 14 | { 15 | getline(cin,a[i].name); 16 | cin>>a[i].roll>>a[i].marks; 17 | cin.ignore(); 18 | } 19 | Student mx; 20 | mx.marks=INT_MIN; 21 | for(int i=0;i<3;i++) 22 | { 23 | if(a[i].marks>mx.marks) 24 | { 25 | mx=a[i]; 26 | } 27 | } 28 | cout< 2 | using namespace std; 3 | class Student 4 | { 5 | public: 6 | string name; 7 | int roll; 8 | int marks; 9 | }; 10 | int main() 11 | { 12 | Student a[3]; 13 | for(int i=0;i<3;i++) 14 | { 15 | getline(cin,a[i].name); 16 | cin>>a[i].roll>>a[i].marks; 17 | cin.ignore(); 18 | } 19 | for(int i=0;i<2;i++) 20 | { 21 | for(int j=i+1;j<3;j++) 22 | { 23 | if(a[i].roll > a[j].roll) 24 | { 25 | swap(a[i],a[j]); 26 | } 27 | } 28 | } 29 | for(int i=0;i<3;i++) 30 | { 31 | cout< 2 | using namespace std; 3 | class Student 4 | { 5 | public: 6 | string name; 7 | int roll; 8 | int marks; 9 | }; 10 | bool cmp(Student a,Student b) 11 | { 12 | if(a.marks > b.marks) return true; 13 | else return false; 14 | } 15 | int main() 16 | { 17 | Student a[3]; 18 | for(int i=0;i<3;i++) 19 | { 20 | getline(cin,a[i].name); 21 | cin>>a[i].roll>>a[i].marks; 22 | cin.ignore(); 23 | } 24 | // sort function 25 | sort(a,a+3,cmp); 26 | for(int i=0;i<3;i++) 27 | { 28 | cout<