├── Algorithm_Sort.cpp ├── Array.cpp ├── Binary_Tree.cpp ├── Diamond.cpp ├── Exception_Handling.cpp ├── File_Handling.cpp ├── Friend_function.cpp ├── Half_pyramid_with_numbers.cpp ├── Heap_Deletion.cpp ├── Heap_Insertion.cpp ├── HelloWorld.cpp ├── Hollow_Rectangle.cpp ├── Hollow_Rhombus.cpp ├── If_else.cpp ├── Inorder_Binary_Tree.cpp ├── Level_Order_Traversal.cpp ├── Linked_List.cpp ├── Linked_List1.cpp ├── Postorder_Binary_Tree.cpp ├── Preorder_Binary_Tree.cpp ├── README.md ├── Square.cpp ├── butterfly.cpp ├── character_in_string.cpp ├── cin_and_cout.cpp ├── class_and_object.cpp ├── hello.cpp ├── ifstream.cpp ├── largest_number.cpp ├── loops.cpp ├── no_code.cpp ├── ofstream.cpp ├── question1.cpp ├── rhombus.cpp ├── sorting.cpp ├── swap.cpp ├── table.cpp ├── triangle_pattern.cpp └── triangle_pattern2.cpp /Algorithm_Sort.cpp: -------------------------------------------------------------------------------- 1 | // Sorting using Algorithm 2 | 3 | # include 4 | # include 5 | using namespace std; 6 | 7 | int main() { 8 | int n; 9 | cout<<"Enter the length of array: "; 10 | cin>>n; 11 | 12 | int arr[n]; 13 | for (int i=0; i>arr[i]; 15 | } 16 | 17 | sort(arr,arr+n); 18 | 19 | for (int i=0; i 2 | using namespace std; 3 | 4 | int main() { 5 | int n; 6 | cout<<"Enter the value of n: "; 7 | cin>>n; 8 | 9 | int arr[n]; 10 | 11 | for (int i=0; i>arr[i]; 13 | } 14 | 15 | cout< 2 | using namespace std; 3 | 4 | class node { 5 | public: 6 | int data; 7 | node* left; 8 | node* right; 9 | node(int d) { 10 | this -> data = d; 11 | this -> left = NULL; 12 | this -> right = NULL; 13 | } 14 | }; 15 | 16 | node* buildTree(node* root) { 17 | cout<<"Enter the data: "<>data; 20 | root = new node (data); 21 | 22 | if (data == -1) { 23 | return NULL; 24 | } 25 | 26 | cout<<"Enter data for inserting in left: "< left = buildTree(root->left); 28 | cout<<"Enter data for inserting in right: "<right = buildTree(root->right); 30 | return root; 31 | 32 | } 33 | 34 | // preorder 35 | 36 | 37 | int main() { 38 | node* root = NULL; 39 | 40 | // Creating a tree 41 | root = buildTree(root); 42 | return 0; 43 | } 44 | -------------------------------------------------------------------------------- /Diamond.cpp: -------------------------------------------------------------------------------- 1 | # include 2 | using namespace std; 3 | 4 | int main() { 5 | int n; 6 | cout<<"Enter the value of n: "; 7 | cin>>n; 8 | 9 | // Diamond Code 10 | for (int i=1; i<=n; i++) { 11 | for (int j=1; j<=n-i; j++) { 12 | cout<<" "; 13 | } 14 | for (int k=1; k<=i; k++) { 15 | cout<<"* "; 16 | } 17 | for (int l=2; l<=i; l++) { 18 | cout<<"* "; 19 | } 20 | cout< 2 | using namespace std; 3 | 4 | int main() { 5 | int age; 6 | cout<<"Enter your age: "; 7 | cin>>age; 8 | 9 | try{ 10 | if (age >= 18) { 11 | cout<<"You are eligible to vote"; 12 | } 13 | else { 14 | throw(age); 15 | } 16 | } 17 | catch (int num) { 18 | cout<<"Your age is "< 2 | # include 3 | 4 | using namespace std; 5 | 6 | // ofstream 7 | 8 | int main() { 9 | // file ko open karna 10 | ofstream fout; 11 | fout.open("zoom.txt"); // create kar dega phir open kr dega 12 | // write kar sakta hu 13 | fout<<"Hello India"; 14 | 15 | fout.close(); // Resources release kar paauon 16 | } 17 | -------------------------------------------------------------------------------- /Friend_function.cpp: -------------------------------------------------------------------------------- 1 | # include 2 | using namespace std; 3 | 4 | class Complex{ 5 | int a,b; 6 | 7 | public: 8 | void setNumber(int n1, int n2) { 9 | a = n1; 10 | b = n2; 11 | } 12 | 13 | // Below line means that nonmember - sumcomplex function is aloowed to do anything with my private parts 14 | 15 | friend Complex sumComplex(Complex o1, Complex o2); 16 | void printNumber() { 17 | cout<<"Your number is "< 2 | using namespace std; 3 | 4 | int main() { 5 | int n; 6 | cout<<"Enter the value of n: "; 7 | cin>>n; 8 | 9 | for (int i=1; i<=n; i++) { 10 | for (int j=1; j<=i; j++) { 11 | cout< 2 | using namespace std; 3 | 4 | class heap { 5 | public: 6 | int arr[100]; 7 | int size; 8 | 9 | heap() { 10 | arr[0] = -1; 11 | size = 0; 12 | } 13 | 14 | void insert(int val) { 15 | size = size + 1; 16 | int index = size; 17 | arr[index] = val; 18 | 19 | while (index > 1) { 20 | int parent = index/2; 21 | 22 | if (arr[parent] < arr[index]) { 23 | swap(arr[parent], arr[index]); 24 | index = parent; 25 | } 26 | else { 27 | return ; 28 | } 29 | } 30 | } 31 | 32 | void print() { 33 | for (int i=1; i<=size; i++) { 34 | cout< 2 | using namespace std; 3 | 4 | class heap { 5 | public: 6 | int arr[100]; 7 | int size; 8 | 9 | heap() { 10 | arr[0] = -1; 11 | size = 0; 12 | } 13 | 14 | void insert(int val) { 15 | size = size + 1; 16 | int index = size; 17 | arr[index] = val; 18 | 19 | while (index > 1) { 20 | int parent = index/2; 21 | 22 | if (arr[parent] < arr[index]) { 23 | swap(arr[parent], arr[index]); 24 | index = parent; 25 | } 26 | else { 27 | return ; 28 | } 29 | } 30 | } 31 | 32 | void print() { 33 | for (int i=1; i<=size; i++) { 34 | cout< 2 | using namespace std; 3 | int main() { 4 | cout<<"Hello World"; 5 | } 6 | -------------------------------------------------------------------------------- /Hollow_Rectangle.cpp: -------------------------------------------------------------------------------- 1 | # include 2 | using namespace std; 3 | 4 | int main() { 5 | int row, col; 6 | cout<<"Enter the value of row: "; 7 | cin>>row; 8 | cout<<"Enter the value of col: "; 9 | cin>>col; 10 | 11 | for (int i=1; i<=row; i++) { 12 | for (int j=1; j<=col; j++) { 13 | if (i == 1 || i == row || j == 1 || j == col) { 14 | cout<<"* "; 15 | } 16 | else { 17 | cout<<" "; 18 | } 19 | } 20 | cout< 2 | using namespace std; 3 | 4 | int main() { 5 | int n; 6 | cout<<"Enter the value of n: "; 7 | cin>>n; 8 | 9 | for (int i=1; i<=n; i++) { 10 | for (int j=1; j 2 | using namespace std; 3 | 4 | int main() { 5 | int n; 6 | cout<<"Enter value of n: "; 7 | cin>>n; 8 | if (n>=18) { 9 | cout<<"you can vote"; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Inorder_Binary_Tree.cpp: -------------------------------------------------------------------------------- 1 | # include 2 | # include 3 | using namespace std; 4 | 5 | class node { 6 | public: 7 | int data; 8 | node* left; 9 | node* right; 10 | node(int d) { 11 | this -> data = d; 12 | this -> left = NULL; 13 | this -> right = NULL; 14 | } 15 | }; 16 | 17 | node* buildTree(node* root) { 18 | cout<<"Enter the data: "<>data; 21 | root = new node (data); 22 | 23 | if (data == -1) { 24 | return NULL; 25 | } 26 | 27 | cout<<"Enter data for inserting in left: "< left = buildTree(root->left); 29 | cout<<"Enter data for inserting in right: "<right = buildTree(root->right); 31 | return root; 32 | 33 | } 34 | 35 | void LevelOrderTraversal(node* root) { 36 | queue q; 37 | q.push(root); 38 | q.push(NULL); 39 | 40 | while (!q.empty()) { 41 | node* temp = q.front(); 42 | q.pop(); 43 | 44 | if (temp == NULL) { // Purana level complete ho chuka hai 45 | cout<data<<" "; 52 | if (temp -> left) { 53 | q.push(temp->left); 54 | } 55 | 56 | if (temp -> right) { 57 | q.push(temp->right); 58 | } 59 | } 60 | } 61 | } 62 | 63 | void inorder(node* root) { 64 | // base code 65 | if (root == NULL) { 66 | return ; 67 | } 68 | inorder(root -> left); 69 | cout< data<<" "; 70 | inorder(root -> right); 71 | } 72 | 73 | int main() { 74 | node* root = NULL; 75 | 76 | // Creating a tree 77 | root = buildTree(root); 78 | 79 | // 1 3 7-1-1 11 -1 -1 5 17 -1 -1 -1 80 | // Level Order 81 | cout<<"Printing the level order of traversal output: "< 2 | # include 3 | using namespace std; 4 | 5 | class node { 6 | public: 7 | int data; 8 | node* left; 9 | node* right; 10 | node(int d) { 11 | this -> data = d; 12 | this -> left = NULL; 13 | this -> right = NULL; 14 | } 15 | }; 16 | 17 | node* buildTree(node* root) { 18 | cout<<"Enter the data: "<>data; 21 | root = new node (data); 22 | 23 | if (data == -1) { 24 | return NULL; 25 | } 26 | 27 | cout<<"Enter data for inserting in left: "< left = buildTree(root->left); 29 | cout<<"Enter data for inserting in right: "<right = buildTree(root->right); 31 | return root; 32 | 33 | } 34 | 35 | void LevelOrderTraversal(node* root) { 36 | queue q; 37 | q.push(root); 38 | q.push(NULL); 39 | 40 | while (!q.empty()) { 41 | node* temp = q.front(); 42 | q.pop(); 43 | 44 | if (temp == NULL) { // Purana level complete ho chuka hai 45 | cout<data<<" "; 52 | if (temp -> left) { 53 | q.push(temp->left); 54 | } 55 | 56 | if (temp -> right) { 57 | q.push(temp->right); 58 | } 59 | } 60 | } 61 | } 62 | 63 | int main() { 64 | node* root = NULL; 65 | 66 | // Creating a tree 67 | root = buildTree(root); 68 | 69 | // 1 3 7-1-1 11 -1 -1 5 17 -1 -1 -1 70 | // Level Order 71 | cout<<"Printing the level order of traversal output: "< 2 | using namespace std; 3 | 4 | int main() { 5 | return 0; 6 | } 7 | -------------------------------------------------------------------------------- /Linked_List1.cpp: -------------------------------------------------------------------------------- 1 | // Add a node at the head 2 | // Add a node at the Tail 3 | // Add a node at the Position 4 | 5 | # include 6 | using namespace std; 7 | 8 | class Node{ 9 | public: 10 | int val; 11 | Node* next; 12 | 13 | Node (int data) { 14 | val = data; 15 | next = NULL; 16 | } 17 | }; 18 | 19 | void InsertatHead(Node* &head, int val) { 20 | Node* new_node = new Node(val); 21 | new_node->next = head; 22 | head = new_node; 23 | } 24 | 25 | void InsertatTail(Node* &head, int val) { 26 | Node* new_node = new Node(val); 27 | Node* temp = head; 28 | while (temp->next!=NULL) { 29 | temp=temp->next; 30 | } 31 | // temp has reached the last node 32 | temp->next = new_node; 33 | } 34 | 35 | void InsertatPosition(Node* head, int val, int pos) { 36 | if (pos==0) { 37 | InsertatHead(head, val); 38 | return; 39 | } 40 | 41 | Node* new_node = new Node(val); 42 | Node* temp = head; 43 | int current_pos = 0; 44 | while(current_pos!=pos-1) { 45 | temp = temp->next; 46 | current_pos++; 47 | 48 | } 49 | // temp is pointing to node at pos - 1 50 | new_node->next = temp->next; 51 | temp->next = new_node; 52 | } 53 | 54 | void display(Node* head) { 55 | Node* temp = head; 56 | while (temp != NULL){ 57 | cout<val<<"->"; 58 | temp = temp->next; 59 | 60 | } 61 | cout<<"NULL"<val<<" "<next< 2 | using namespace std; 3 | 4 | class node{ 5 | public: 6 | int data; 7 | node* left; 8 | node* right; 9 | 10 | node (int d) { 11 | this -> data = d; 12 | this -> left = NULL; 13 | this -> right = NULL; 14 | } 15 | }; 16 | 17 | node* buildTree(node* root) { 18 | cout<<"Enter the data: "<>data; 21 | root = new node(data); 22 | 23 | if (data == -1) { 24 | return NULL; 25 | } 26 | cout<<"Enter data for inserting in left: "< left = buildTree(root -> left); 28 | cout<<"Enter data for inserting in right "< right = buildTree(root -> right); 30 | return root; 31 | } 32 | 33 | void inorder(node* root) { 34 | if (root == NULL) { 35 | return ; 36 | } 37 | 38 | inorder(root -> left); 39 | cout<data<<" "; 40 | inorder(root -> right); 41 | } 42 | 43 | void postorder(node* root) { 44 | // base code 45 | if (root == NULL) { 46 | return ; 47 | } 48 | postorder(root -> left); 49 | postorder(root -> right); 50 | cout< data<<" "; 51 | } 52 | 53 | 54 | int main() { 55 | node* root = NULL; 56 | 57 | root = buildTree(root); 58 | 59 | postorder(root); 60 | 61 | return 0; 62 | } 63 | -------------------------------------------------------------------------------- /Preorder_Binary_Tree.cpp: -------------------------------------------------------------------------------- 1 | # include 2 | # include 3 | using namespace std; 4 | 5 | class node { 6 | public: 7 | int data; 8 | node* left; 9 | node* right; 10 | node(int d) { 11 | this -> data = d; 12 | this -> left = NULL; 13 | this -> right = NULL; 14 | } 15 | }; 16 | 17 | node* buildTree(node* root) { 18 | cout<<"Enter the data: "<>data; 21 | root = new node (data); 22 | 23 | if (data == -1) { 24 | return NULL; 25 | } 26 | 27 | cout<<"Enter data for inserting in left: "< left = buildTree(root->left); 29 | cout<<"Enter data for inserting in right: "<right = buildTree(root->right); 31 | return root; 32 | 33 | } 34 | 35 | void LevelOrderTraversal(node* root) { 36 | queue q; 37 | q.push(root); 38 | q.push(NULL); 39 | 40 | while (!q.empty()) { 41 | node* temp = q.front(); 42 | q.pop(); 43 | 44 | if (temp == NULL) { // Purana level complete ho chuka hai 45 | cout<data<<" "; 52 | if (temp -> left) { 53 | q.push(temp->left); 54 | } 55 | 56 | if (temp -> right) { 57 | q.push(temp->right); 58 | } 59 | } 60 | } 61 | } 62 | 63 | void inorder(node* root) { 64 | // base code 65 | if (root == NULL) { 66 | return ; 67 | } 68 | inorder(root -> left); 69 | cout< data<<" "; 70 | inorder(root -> right); 71 | } 72 | 73 | void preorder(node* root) { 74 | // base code 75 | if (root == NULL) { 76 | return ; 77 | } 78 | cout< data<<" "; 79 | preorder(root -> left); 80 | preorder(root -> right); 81 | } 82 | 83 | void postorder(node* root) { 84 | // base code 85 | if (root == NULL) { 86 | return ; 87 | } 88 | postorder(root -> left); 89 | postorder(root -> right); 90 | cout< data<<" "; 91 | } 92 | 93 | node* buildFromLevelOrder(node* &root) { 94 | queue q; 95 | cout<<"Enter data for root: "<>data; 98 | root = new node(data); 99 | q.push(root); 100 | 101 | while (!q.empty()) { 102 | node* temp = q.front(); 103 | q.pop(); 104 | 105 | cout<<"Enter left node for: "<data<>leftData; 108 | 109 | if(leftData != -1) { 110 | temp -> left = new node(leftData); 111 | q.push(temp->left); 112 | } 113 | 114 | cout<<"Enter right node for: "<data<>rightData; 117 | 118 | if(rightData != -1) { 119 | temp -> right = new node(rightData); 120 | q.push(temp->right); 121 | } 122 | } 123 | } 124 | 125 | int main() { 126 | node* root = NULL; 127 | 128 | // Creating a tree 129 | root = buildTree(root); 130 | 131 | // 1 3 7-1-1 11 -1 -1 5 17 -1 -1 -1 132 | // Level Order 133 | cout<<"Printing the level order of traversal output: "< 2 | using namespace std; 3 | 4 | int main() { 5 | int n; 6 | cout<<"Enter the value of n: "; 7 | cin>>n; 8 | 9 | for (int i=0; i 2 | using namespace std; 3 | 4 | int main() { 5 | int n; 6 | cout<<"Enter the value of n: "; 7 | cin>>n; 8 | 9 | for (int i=1; i<=n; i++) { 10 | for (int j=1; j<=i; j++) { 11 | cout<<"* "; 12 | } 13 | for (int k=1; k<=(n-i)*2; k++) { 14 | cout<<" "; 15 | } 16 | for (int l=1; l<=i; l++) { 17 | cout<<"* "; 18 | } 19 | cout<=1; i--) { 23 | for (int j=1; j<=i; j++) { 24 | cout<<"* "; 25 | } 26 | for (int k=1; k<=(n-i)*2; k++) { 27 | cout<<" "; 28 | } 29 | for (int l=1; l<=i; l++) { 30 | cout<<"* "; 31 | } 32 | cout< 2 | # include 3 | using namespace std; 4 | 5 | int main() { 6 | string inp; 7 | char ch; 8 | 9 | cin>>inp; 10 | cin>>ch; 11 | 12 | int count = 0; 13 | for (char c : inp) { 14 | if (c == ch) { 15 | count++; 16 | } 17 | } 18 | 19 | cout< 2 | # include 3 | using namespace std; 4 | 5 | int main() { 6 | int age; 7 | cin>>age; 8 | cout<<"Your age is "< 2 | using namespace std; 3 | 4 | class Class { 5 | public: 6 | void output() { 7 | cout<<"Class and Object"; 8 | } 9 | 10 | }; 11 | 12 | int main() { 13 | Class object; 14 | object.output(); 15 | return 0; 16 | } 17 | -------------------------------------------------------------------------------- /hello.cpp: -------------------------------------------------------------------------------- 1 | # include 2 | using namespace std; 3 | int main() { 4 | cout<<"Hello"; 5 | return 0; 6 | } 7 | -------------------------------------------------------------------------------- /ifstream.cpp: -------------------------------------------------------------------------------- 1 | # include 2 | # include 3 | 4 | using namespace std; 5 | 6 | int main() { 7 | ifstream fin; 8 | // file ko open karo 9 | fin.open("zoom.txt"); 10 | // fir read karo 11 | char c; 12 | //fin>>c; 13 | c = fin.get(); 14 | 15 | while (!fin.eof()) { 16 | cout<>c; 18 | c = fin.get(); 19 | } 20 | 21 | fin.close(); 22 | 23 | } 24 | -------------------------------------------------------------------------------- /largest_number.cpp: -------------------------------------------------------------------------------- 1 | # include 2 | using namespace std; 3 | 4 | int main() { 5 | int a,b,c; 6 | cout<<"Enter the value of a: "; 7 | cin>>a; 8 | cout<<"EWnter the value of b: "; 9 | cin>>b; 10 | cout<<"Enter the value of c: "; 11 | cin>>c; 12 | 13 | if (a>b && a>c) { 14 | cout<c && b>a) { 17 | cout< 2 | using namespace std; 3 | 4 | int main() { 5 | int n; 6 | cout<<"Enter the value of n: "; 7 | cin>>n; 8 | 9 | for (int i=1; i<=n; i++) { 10 | cout< 2 | using namespace std; 3 | 4 | int main() { 5 | cout<<"No code for today."; 6 | } 7 | -------------------------------------------------------------------------------- /ofstream.cpp: -------------------------------------------------------------------------------- 1 | # include 2 | # include 3 | 4 | using namespace std; 5 | 6 | // ofstream 7 | 8 | int main() { 9 | // file ko open karna 10 | ofstream fout; 11 | fout.open("zoom.txt"); // create kar dega phir open kr dega 12 | // write kar sakta hu 13 | fout<<"Hello India"; 14 | 15 | fout.close(); // Resources release kar paauon 16 | } 17 | -------------------------------------------------------------------------------- /question1.cpp: -------------------------------------------------------------------------------- 1 | Early Closure Charges are usually applicable when you want to repay the entire outstanding loan amount in one single payment. 2 | Early Closure Charges are 5% of the Principal Outstanding. 3 | Part Payment Charges are usually applicable when you want to repay a part of outstanding loan amount. 4 | Part Prepayment charges are 5% of the Part Payment Amount (Part Payment will be allowed twice in a loan calendar year and once in a loan calendar month. The minimum amount accepted for part payment will be equal to one EMI. Maximum amount allowed for part payment will be 25% of the balance principal in one year.) 5 | Documentation Charges & Processing Fee is applicable for processing your two wheeler loan. Documentation charges are 6 | -------------------------------------------------------------------------------- /rhombus.cpp: -------------------------------------------------------------------------------- 1 | # include 2 | using namespace std; 3 | 4 | int main() { 5 | int n; 6 | cout<<"Enter the value of n: "; 7 | cin>>n; 8 | 9 | for (int i=1; i<=n; i++) { 10 | for (int j=1; j<=n-i; j++) { 11 | cout<<" "; 12 | } 13 | for (int k=1; k<=n; k++) { 14 | cout<<"* "; 15 | } 16 | cout< 2 | using namespace std; 3 | 4 | int main() { 5 | int n; 6 | cout<<"Enter the value of n: "; 7 | cin>>n; 8 | 9 | int arr[n]; 10 | cout<<"Enter the value of array: "; 11 | for (int i=0; i>arr[i]; 13 | } 14 | 15 | cout<<"Original Array: "; 16 | for (int i=0; i arr[j+1]) { 26 | int temp = arr[j]; 27 | arr[j] = arr[j+1]; 28 | arr[j+1] = temp; 29 | } 30 | } 31 | } 32 | 33 | cout<<"The sorted arrary: "; 34 | 35 | for (int i=0; i 2 | using namespace std; 3 | 4 | int main() { 5 | int a; 6 | cout<<"Enter the value of a: "; 7 | cin>>a; 8 | 9 | int b; 10 | cout<<"Enter the value of b: "; 11 | cin>>b; 12 | 13 | // Swap 14 | int temp = a; 15 | a = b; 16 | b = temp; 17 | 18 | cout<<"Swapped value are: "< 2 | using namespace std; 3 | int main() { 4 | int n; 5 | cout<<"Enter value of n: "; 6 | cin>>n; 7 | for (int i=1; i<=10; i++) { 8 | cout<>n; 8 | 9 | for (int i=1; i<=n; i++) { 10 | for (int j=1; j<=i; j++) { 11 | cout<<"* "; 12 | } 13 | cout< 2 | using namespace std; 3 | 4 | int main() { 5 | int n; 6 | cout<<"Enter the value of n: "; 7 | cin>>n; 8 | 9 | for (int i=1; i<=n; i++) { 10 | for (int j=1; j<=n-i+1; j++) { 11 | cout<<" "; 12 | } 13 | for (int k=1; k<=i; k++) { 14 | cout<<"* "; 15 | } 16 | cout<