├── 5.cpp ├── ArmstrongNumber.python ├── BMIindex.py ├── BT to BST.java ├── BinarySearch.java ├── BinarySearchTree.java ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── CPP ├── 01_Helloworld.cpp ├── 02_anatomy.cpp ├── 03_variables.cpp ├── 04_pointer.cpp ├── 05_Arrays.cpp ├── 05_pointerArray.cpp ├── 06_structure.cpp ├── 07_union.cpp ├── 08_String.cpp ├── 09_function.cpp ├── 10_funcCall.cpp ├── 11_inlineFunction.cpp ├── 12_recursion.cpp ├── 13_FO_max.cpp ├── 13_FO_volume.cpp ├── 13_funcOverloading.cpp ├── 14_Class.cpp ├── 14_oops_Student.cpp ├── 15_Binary.cpp ├── 16_shop.cpp ├── 17_emp.cpp ├── 18_empObjArray.cpp ├── 18_objArray.cpp ├── 19_objPassing.cpp ├── 20_friendFunction.cpp ├── 21_friendClass.cpp ├── 22_friend2func.cpp ├── 23_friendFunction.cpp ├── 24_constructor.cpp ├── 25_parameterizedConstructor.cpp ├── 26_axis.cpp ├── 27_constuctorOverloading.cpp ├── 28_max3.cpp ├── 29_ConstructorDefaultArgc.cpp ├── 29_pr_complexDefaultConsturctor.cpp ├── 30_DynamicInitObjConsturctor.cpp ├── 31_copyConstructor.cpp ├── 32_Destructor.cpp ├── 33_Inheritance.cpp ├── 34_inheritance-new.cpp ├── 35_private.cpp ├── 35_singleInheritance.cpp ├── 36_Protected.cpp ├── 37_multilavel.cpp ├── 38_multipleINHERITANCE.cpp ├── 39_Calculactor.cpp ├── 40_FNameInheritance.cpp ├── 41_ambiguity.cpp ├── 42_ambiguity2.cpp ├── 43_VirtualBaseClass.cpp ├── 44_Calc.cpp ├── 45_ConstVirtual.cpp ├── 46_initList.cpp ├── 47_pointNewDel.cpp ├── 48_PointerObj.cpp ├── 49_arrPointerObj.cpp ├── 50_thisPointer.cpp ├── 51_polymorphism.cpp ├── 52_operatorOverloading.cpp ├── 53_incrementOverloading.cpp ├── 54_unaryOprator.cpp ├── 55_binaryOperator.cpp ├── 56_unaryOperator.cpp ├── 57_arrSubOp.cpp ├── 58_SteamInsertionOpOverloading.cpp ├── 59_AssignmentOperatorOverloading.cpp ├── 60_PointerDerived.cpp ├── 61_virtualFunc.cpp ├── 62_cwhVirtualFuction.cpp ├── 63_abstractClass.cpp ├── 64_fileHandling.cpp ├── 64_fileHandling.exe ├── 64_sample.txt ├── 65_errorHandling.cpp └── rectanglearea.cpp ├── CaseCheck.java ├── Clockwise_Rotate.java ├── CountNums.java ├── DISHA ├── Demands 5G and Wi-Fi.md ├── Dutch_National_flag_algorithm.java ├── Employee_SalarySlip.py ├── FactorialofaNumber.python ├── Gingerit python tutorial.md ├── Github repo.md ├── GnomeSort.cpp ├── Greeting.java ├── Hello.class ├── Hello.java ├── HelloWorld.cpp ├── HelloWorld.java ├── Hospital management ├── main.c └── readme.md ├── Import turtle ├── Kruskal.java ├── LCM.py ├── Largest.java ├── LeapYear.python ├── Login Form ├── Users.dat ├── login.cpp ├── login.exe └── readme.md ├── Longest_palindromic_substring.cpp ├── MergeSort.java ├── No_Idea.py ├── Palindrome.java ├── Palindrome.python ├── Password Generator.py ├── QuickSort.java ├── READ ME ├── README.md ├── Recursive_Sum_Num.java ├── Reverse.java ├── Stream.java ├── String3_Freq ├── StringPalindromeCheck.cpp ├── StudentAssistant-master ├── Backmenu.h ├── Calculator.c ├── ClassRoutine.c ├── DCalculator.c ├── DemoWallet.c ├── EasyMatrix.c ├── PeriodicTable.c ├── PersonalDiary.c ├── StudentAssistant.c ├── StudentAssistant.exe └── StudentAssistant.png ├── Sudoku Solver ├── Sudoku.class └── Sudoku.java ├── TraverseLinkedList.c ├── Unique_Paths.cpp ├── Valid_Palindrome.py ├── WildcardMatching.java ├── amazon-price-scraper ├── main.py ├── randomPassGen.py └── requirements.txt ├── armstrong number.md ├── binarySearch.cpp ├── binarysearchtree.py ├── c.md ├── calculator.java ├── celebrityprob.java ├── classmatrix.java ├── code.md ├── count.java ├── countallpossiblepaths.cpp ├── factorialusingrecursion ├── fibonacci series ├── fibonaccirecursion.c ├── findAllDuplicates.java ├── guiCalculator.java ├── hamiltonprob.java ├── hellloworld.c ├── hello.go ├── hello.java ├── hello_world_shubham.md ├── img_show.cpp ├── import_turtle.md ├── iplmatch.java ├── maths.cpp ├── minchara.java ├── new.md ├── occurances.java ├── printArray.java ├── quickSort.cpp ├── replaceleastgreater.java ├── rockpaperscissor.py ├── schedule.py ├── set_operations.py ├── shalu461975 ├── snakeWaterGunGame.js ├── spriallmatrix.cpp ├── sum.cpp ├── thanks.py ├── turtle.py ├── turtle_pattern.py └── tweepy.md /5.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | int main(){ 3 | 4 | int season; //1-spring 2-summer 3-monsoon 4-winter 5 | printf("enter season(1-4) \n"); 6 | scanf("%d",&season); 7 | 8 | switch(season){ 9 | 10 | case 1: printf("spring \n"); 11 | break; 12 | 13 | case 2: printf("summer \n"); 14 | break; 15 | 16 | case 3: printf("monsoon \n"); 17 | break; 18 | 19 | case 4: printf("winter \n"); 20 | break; 21 | 22 | default: printf("enter a valid number \n"); 23 | 24 | } 25 | 26 | 27 | 28 | } -------------------------------------------------------------------------------- /ArmstrongNumber.python: -------------------------------------------------------------------------------- 1 | # Python program to check if the number is an Armstrong number or not 2 | 3 | # take input from the user 4 | num = int(input("Enter a number: ")) 5 | 6 | # initialize sum 7 | sum = 0 8 | 9 | # find the sum of the cube of each digit 10 | temp = num 11 | while temp > 0: 12 | digit = temp % 10 13 | sum += digit ** 3 14 | temp //= 10 15 | 16 | # display the result 17 | if num == sum: 18 | print(num,"is an Armstrong number") 19 | else: 20 | print(num,"is not an Armstrong number") 21 | -------------------------------------------------------------------------------- /BMIindex.py: -------------------------------------------------------------------------------- 1 | h=float(input("Enter your height in meters: ")) 2 | w=float(input("Enter your Weight in Kg: ")) 3 | 4 | BMI=w/(h*h) 5 | print("BMI Calculated is: ",BMI) 6 | 7 | if(BMI>0): 8 | if(BMI<=16): 9 | print("You are very underweight") 10 | elif(BMI<=18.5): 11 | print("You are underweight") 12 | elif(BMI<=25): 13 | print("Congrats! You are Healthy") 14 | elif(BMI<=30): 15 | print("You are overweight") 16 | else: 17 | print("You are very overweight") 18 | else: 19 | print("enter valid details") 20 | -------------------------------------------------------------------------------- /BT to BST.java: -------------------------------------------------------------------------------- 1 | import java.util.Arrays; 2 | 3 | public class ConvertBTtoBST { 4 | 5 | //Represent a node of binary tree 6 | public static class Node{ 7 | int data; 8 | Node left; 9 | Node right; 10 | 11 | public Node(int data){ 12 | //Assign data to the new node, set left and right children to null 13 | this.data = data; 14 | this.left = null; 15 | this.right = null; 16 | } 17 | } 18 | 19 | //Represent the root of binary tree 20 | public Node root; 21 | 22 | int[] treeArray; 23 | int index = 0; 24 | 25 | public ConvertBTtoBST(){ 26 | root = null; 27 | } 28 | 29 | //convertBTBST() will convert a binary tree to binary search tree 30 | public Node convertBTBST(Node node) { 31 | 32 | //Variable treeSize will hold size of tree 33 | int treeSize = calculateSize(node); 34 | treeArray = new int[treeSize]; 35 | 36 | //Converts binary tree to array 37 | convertBTtoArray(node); 38 | 39 | //Sort treeArray 40 | Arrays.sort(treeArray); 41 | 42 | //Converts array to binary search tree 43 | Node d = createBST(0, treeArray.length -1); 44 | return d; 45 | } 46 | 47 | //calculateSize() will calculate size of tree 48 | public int calculateSize(Node node) 49 | { 50 | int size = 0; 51 | if (node == null) 52 | return 0; 53 | else { 54 | size = calculateSize (node.left) + calculateSize (node.right) + 1; 55 | return size; 56 | } 57 | } 58 | 59 | //convertBTtoArray() will convert the given binary tree to its corresponding array representation 60 | public void convertBTtoArray(Node node) { 61 | //Check whether tree is empty 62 | if(root == null){ 63 | System.out.println("Tree is empty"); 64 | return; 65 | } 66 | else { 67 | if(node.left != null) 68 | convertBTtoArray(node.left); 69 | //Adds nodes of binary tree to treeArray 70 | treeArray[index] = node.data; 71 | index++; 72 | if(node.right != null) 73 | convertBTtoArray(node.right); 74 | } 75 | } 76 | 77 | //createBST() will convert array to binary search tree 78 | public Node createBST(int start, int end) { 79 | 80 | //It will avoid overflow 81 | if (start > end) { 82 | return null; 83 | } 84 | 85 | //Variable will store middle element of array and make it root of binary search tree 86 | int mid = (start + end) / 2; 87 | Node node = new Node(treeArray[mid]); 88 | 89 | //Construct left subtree 90 | node.left = createBST(start, mid - 1); 91 | 92 | //Construct right subtree 93 | node.right = createBST(mid + 1, end); 94 | 95 | return node; 96 | } 97 | 98 | //inorder() will perform inorder traversal on binary search tree 99 | public void inorderTraversal(Node node) { 100 | 101 | //Check whether tree is empty 102 | if(root == null){ 103 | System.out.println("Tree is empty"); 104 | return; 105 | } 106 | else { 107 | 108 | if(node.left!= null) 109 | inorderTraversal(node.left); 110 | System.out.print(node.data + " "); 111 | if(node.right!= null) 112 | inorderTraversal(node.right); 113 | 114 | } 115 | } 116 | 117 | public static void main(String[] args) { 118 | 119 | ConvertBTtoBST bt = new ConvertBTtoBST(); 120 | //Add nodes to the binary tree 121 | bt.root = new Node(1); 122 | bt.root.left = new Node(2); 123 | bt.root.right = new Node(3); 124 | bt.root.left.left = new Node(4); 125 | bt.root.left.right = new Node(5); 126 | bt.root.right.left = new Node(6); 127 | bt.root.right.right = new Node(7); 128 | 129 | //Display given binary tree 130 | System.out.println("Inorder representation of binary tree: "); 131 | bt.inorderTraversal(bt.root); 132 | 133 | //Converts binary tree to corresponding binary search tree 134 | Node bst = bt.convertBTBST(bt.root); 135 | 136 | //Display corresponding binary search tree 137 | System.out.println("\nInorder representation of resulting binary search tree: "); 138 | bt.inorderTraversal(bst); 139 | } 140 | } 141 | -------------------------------------------------------------------------------- /BinarySearch.java: -------------------------------------------------------------------------------- 1 | class BinarySearch 2 | { 3 | int binarySearch(int arr[], int l, int r, int x) 4 | { 5 | if (r >= l) { 6 | int mid = l + (r - l) / 2; 7 | if (arr[mid] == x) 8 | return mid; 9 | if (arr[mid] > x) 10 | return binarySearch(arr, l, mid - 1, x); 11 | return binarySearch(arr, mid + 1, r, x); 12 | } 13 | return -1; 14 | } 15 | public static void main(String args[]) 16 | { 17 | BinarySearch ob = new BinarySearch(); 18 | int arr[] = { 2, 3, 4, 10, 40 }; 19 | int n = arr.length; 20 | int x = 10; 21 | int result = ob.binarySearch(arr, 0, n - 1, x); 22 | if (result == -1) 23 | System.out.println("Element not present"); 24 | else 25 | System.out.println("Element found at index " 26 | + result); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /CPP/01_Helloworld.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | cout << "hello Harry!"; 8 | return 0; 9 | } 10 | -------------------------------------------------------------------------------- /CPP/02_anatomy.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; // standard he compartment aahe jya madhe cout aani cin ase function aahet 3 | 4 | int main(int argc, char const *argv[]) 5 | { 6 | std::cout << "I am kunal"; // std asel tar jar me khup header files include kelya aani tya madhe same name ne anek function asel tar konta choose karaycha tya sathi aapan std:: cha vapar karto (he garajeche nahi jar aapan globally namespace std kel asel tar) 7 | return 0; 8 | } 9 | -------------------------------------------------------------------------------- /CPP/03_variables.cpp: -------------------------------------------------------------------------------- 1 | #include //tells compiler to find library we used 2 | 3 | using namespace std; // it tels compiler to look inside compartment named std if it can't find some functions 4 | 5 | int main() 6 | { 7 | int kunal, a, b, c; 8 | 9 | a = 33; 10 | b = 45; 11 | c = 99; 12 | kunal = 1; 13 | cout << kunal << endl 14 | << a << endl 15 | << b << endl 16 | << c << endl; 17 | int marksInMath = 8; 18 | cout << marksInMath; 19 | 20 | getchar(); 21 | return 0; 22 | } 23 | -------------------------------------------------------------------------------- /CPP/04_pointer.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() 5 | { 6 | // pointer : pointer is a data type which holds the address of other data types 7 | 8 | // int a = 3; 9 | // int *b = &a; 10 | // /*/ & ---> Addressing operator (address of) 11 | // * ---> Dereferencing operator (value at) */ 12 | 13 | // cout << "The address of a is " << &a << endl; // address of a 14 | // cout << "The value of b is " << b << endl; // value of b 15 | // cout << "The value at b is " << *b << endl; // value at b 16 | // cout << "The address of b is " << &b << endl; // address of b 17 | 18 | // // pointer to pointer 19 | // int **c = &b; 20 | // cout << "The address of b is " << &b << endl; 21 | // cout << "The value of address c is " << c << endl; 22 | // cout << "The value at address c is " << *c << endl; 23 | // cout << "The value at address value_at(value_at(c)) is " << **c << endl; 24 | 25 | int x = 10; 26 | int *y = &x; 27 | int **z = &y; 28 | 29 | cout << "the value of x is (x) " << x << endl; 30 | cout << "The address of x is (&x)" << &x << endl 31 | << endl; 32 | 33 | cout << "the value of address y is (y) " << y << endl; 34 | cout << "the address of address y is (&y) " << &y << endl; 35 | cout << "The value at address y is (*y) " << *y << endl 36 | << endl; 37 | 38 | cout << "the value of z is (z) " << z << endl; 39 | cout << "the value at address z is (*z) " << *z << endl; 40 | cout << "the value at(value at(z)) is (**z) " << **z << endl; 41 | } 42 | -------------------------------------------------------------------------------- /CPP/05_Arrays.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | 6 | int main() 7 | { 8 | // An array is a collection of items of similar type stored in contiguous memory locations 9 | // an array start with index 0 10 | // array ____________________ 11 | // |_a_|_b_|_c_|_d_|_f_| 12 | // 0 1 2 3 4 13 | 14 | char array[5] = {'a', 'b', 'c', 'd', 'e'}; 15 | cout << array[0] << endl; 16 | cout << array[1] << endl; 17 | cout << array[2] << endl; 18 | cout << array[3] << endl; 19 | cout << array[4] << endl 20 | << endl; 21 | 22 | array[2] = 'j'; // changing the values of array (elements) 23 | 24 | cout << array[0] << endl; 25 | cout << array[1] << endl; 26 | cout << array[2] << endl; 27 | cout << array[3] << endl; 28 | cout << array[4] << endl 29 | << endl; 30 | 31 | // Accessing array using loop 32 | 33 | for (int i = 0; i < 5; i++) 34 | { 35 | cout << "The value of array[" << i << "] is " << array[i] << endl; 36 | } 37 | 38 | cout << endl; 39 | 40 | int i = 0; 41 | while (i < 5) 42 | { 43 | cout << "The value of array[" << i << "] is " << array[i] << endl; 44 | i++; 45 | } 46 | 47 | cout << endl; 48 | 49 | i = 0; 50 | do 51 | { 52 | cout << "The value of array[" << i << "] is " << array[i] << endl; 53 | i++; 54 | } while (i < 5); 55 | 56 | cout << endl; 57 | 58 | return 0; 59 | } 60 | -------------------------------------------------------------------------------- /CPP/05_pointerArray.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | 6 | int main() 7 | { 8 | // array _________________________ 9 | // |_11_|_12_|_13_|_14_|_15_| 10 | // index 0 1 2 3 4 11 | 12 | // In normal data types 13 | // int a = 3; 14 | // &a ----> is address of a 15 | 16 | // but in array's 17 | // only name is require for address 18 | // array ---> address of array first element 19 | 20 | // &array ----> is Wrong!!! 21 | // (*)p = array; 22 | // (*)p++ 23 | return 0; 24 | } 25 | -------------------------------------------------------------------------------- /CPP/06_structure.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | typedef struct emp 6 | { 7 | int eid; 8 | char favChar; 9 | double salary; 10 | } ep; 11 | 12 | int main() 13 | { 14 | ep kunal; 15 | kunal.eid = 1; 16 | kunal.favChar = 'k'; 17 | kunal.salary = 12000.612; 18 | 19 | cout << kunal.eid << endl; 20 | cout << kunal.favChar << endl; 21 | cout << kunal.salary << endl; 22 | 23 | struct emp om; 24 | om.eid = 2; 25 | om.favChar = 'o'; 26 | om.salary = 130000.712; 27 | 28 | cout << om.eid << endl; 29 | cout << om.favChar << endl; 30 | cout << om.salary << endl; 31 | return 0; 32 | } 33 | -------------------------------------------------------------------------------- /CPP/07_union.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | 6 | union money 7 | { 8 | int gold; 9 | char nameToBorrow; 10 | float pounds; 11 | }; 12 | 13 | int main() 14 | { 15 | union money m1; 16 | m1.gold = 23; 17 | m1.nameToBorrow = 'k'; 18 | cout << m1.gold << endl; 19 | return 0; 20 | } 21 | -------------------------------------------------------------------------------- /CPP/08_String.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | 6 | int getLength(char name[]) 7 | { 8 | int count = 0; 9 | for (int i = 0; name[i] != '\0'; i++) 10 | { 11 | count++; 12 | } 13 | return count; 14 | } 15 | 16 | int main() 17 | { 18 | 19 | char name[20]; 20 | char name2[3]; 21 | 22 | cout << "enter your name: " << endl; 23 | cin >> name; 24 | // name[2] = '\0'; 25 | 26 | cout << "Your name is " << name << endl; 27 | 28 | cout << "length of string is " << getLength(name); 29 | 30 | return 0; 31 | } 32 | -------------------------------------------------------------------------------- /CPP/09_function.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | 6 | int sum(int a, int b); // function declare 7 | void g(void); 8 | 9 | int main() 10 | { 11 | int num1, num2; 12 | cout << "Enter num1: " << endl; 13 | cin >> num1; 14 | cout << "Enter num2: " << endl; 15 | cin >> num2; 16 | 17 | cout << "The sum is " << sum(num1, num2) << endl; // function call 18 | g(); 19 | return 0; 20 | } 21 | 22 | int sum(int a, int b) // function defined 23 | { 24 | // 25 | int c = a + b; 26 | return c; 27 | } 28 | 29 | void g() 30 | { 31 | cout << "Iam kunal" << endl; 32 | } 33 | -------------------------------------------------------------------------------- /CPP/10_funcCall.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | 6 | int sum(int a, int b) 7 | { 8 | int c = a + b; 9 | } 10 | 11 | // this will not swap actually 12 | void swap(int a, int b) 13 | { 14 | int c = a; 15 | a = b; 16 | b = c; 17 | } 18 | 19 | void swapPointer(int *a, int *b) 20 | { 21 | int c = *a; 22 | *a = *b; 23 | *b = c; 24 | } 25 | 26 | void swapReference(int &a, int &b) 27 | { 28 | int c = a; 29 | a = b; 30 | b = c; 31 | } 32 | 33 | int main() 34 | { 35 | int a = 4, b = 5; 36 | cout << "The sum of 4 and 5 is " << sum(a, b) << endl; 37 | cout << "The value of a is " << a << " & b is " << b << endl; 38 | cout << "After swapping " << endl; 39 | // swap(a, b); this will not actually swap a & b 40 | // swapPointer(&a, &b); 41 | swapReference(a, b); 42 | cout << "The value of a is " << a << " & b is " << b << endl; 43 | return 0; 44 | } 45 | -------------------------------------------------------------------------------- /CPP/11_inlineFunction.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | 6 | int product(int a, int b) 7 | { 8 | static int c = 0; // Initialization runs only one time // function chi own property 9 | c = c + 1; // next time this function is run, the value of c variable will be retained 10 | return a * b + c; 11 | } 12 | 13 | // jevha function madhe nahi chya barabar kam hot tevha inline function cha use karava 14 | // recursion , static variable, loops, switch in this case don't use inline function 15 | inline int divide(int a, int b) // use inline when simplest code want to do 16 | { 17 | return a / b; // jevha function madhe nahi chya barobar kam hot asel aani function madhe 18 | } 19 | 20 | float moneyReceived(float currentMoney, float factor = 1.04) 21 | { 22 | return currentMoney * factor; 23 | } 24 | 25 | int s(const char *p) 26 | { 27 | int i = 0, cnt = 0; 28 | while (p[i] != '\0') 29 | { 30 | p[i]; 31 | i++; 32 | cnt++; 33 | } 34 | return cnt; 35 | } 36 | 37 | int main() 38 | { 39 | int a = 24, b = 2; 40 | float money = 100000; 41 | char p[20]; 42 | cout << "a is " << a << endl 43 | << "b is " << b << endl 44 | << endl; 45 | // cout << "the product of a & b is " << product(a, b) << endl 46 | // << endl; 47 | // cout << "the divide of a & b is " << divide(a, b) << endl; 48 | // cout << "the divide of a & b is " << divide(a, b) << endl; 49 | // cout << "the divide of a & b is " << divide(a, b) << endl; 50 | // cout << "the divide of a & b is " << divide(a, b) << endl; 51 | // cout << "the divide of a & b is " << divide(a, b) << endl; 52 | // cout << "the divide of a & b is " << divide(a, b) << endl; 53 | // cout << "the divide of a & b is " << divide(a, b) << endl; 54 | // cout << "the divide of a & b is " << divide(a, b) << endl; 55 | 56 | cout << p << endl; 57 | cout << "Length of string is " << s(p) << endl; 58 | 59 | cout << "If you have " << money << " rs in your bank account, you will receive " << moneyReceived(money) << " Rs after 1 year" << endl 60 | << endl; 61 | cout << "for VIP, If you have " << money << " rs in your bank account, you will receive " << moneyReceived(money, 1.10) << " Rs after 1 year" << endl 62 | << endl; 63 | cout << "enter str" << endl; 64 | cin >> p; 65 | cout << "Length of string is " << s(p) << endl; 66 | return 0; 67 | } 68 | -------------------------------------------------------------------------------- /CPP/12_recursion.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | 6 | int factorial(int n) 7 | { 8 | if (n <= 1) 9 | { 10 | return 1; 11 | } 12 | return n * factorial(n - 1); 13 | } 14 | int main() 15 | { 16 | int a; 17 | cout << "Enter a number: " << endl; 18 | cin >> a; 19 | cout << "The factorial of " << a << " is " << factorial(a) << endl; 20 | return 0; 21 | } 22 | 23 | int fib(int n) 24 | { 25 | if (n <= 1) 26 | { 27 | return 1; 28 | } 29 | return fib(n - 2) + fib(n - 1); 30 | } 31 | -------------------------------------------------------------------------------- /CPP/13_FO_max.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | 6 | void max(int a, int b) 7 | { 8 | if (a > b) 9 | cout << a << " is greater than " << b << endl; 10 | else 11 | cout << b << " is greater than " << a << endl; 12 | } 13 | 14 | int max(int a, int b, int c) 15 | { 16 | if (a > b && a > c) 17 | { 18 | return a; 19 | } 20 | else if (b > a && b > c) 21 | { 22 | return b; 23 | } 24 | else 25 | { 26 | return c; 27 | } 28 | } 29 | int main() 30 | { 31 | int a, b, c; 32 | a = 100; 33 | b = 123; 34 | c = 243; 35 | 36 | max(a, b); 37 | cout << "the max of these is " << max(a, b, c) << endl; 38 | return 0; 39 | } 40 | -------------------------------------------------------------------------------- /CPP/13_FO_volume.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | 6 | // volume of sphere 7 | float volume(float pi, float r) 8 | { 9 | return 4 * (pi * r * r * r) / 3; 10 | } 11 | 12 | // volume of cube 13 | float volume(float r) 14 | { 15 | return r * r * r; 16 | } 17 | 18 | // volume of cylinder 19 | float volume(float pi, float r, float h) 20 | { 21 | return pi * r * r * h; 22 | } 23 | int main() 24 | { 25 | float r, pi, h; 26 | r = 5; 27 | pi = 3.14; 28 | h = 9; 29 | 30 | cout << "Volume of cube is " << volume(r) << endl; 31 | cout << "Volume of sphere is " << volume(pi, r) << endl; 32 | cout << "volume of cylinder is " << volume(pi, r, h) << endl; 33 | 34 | return 0; 35 | } 36 | -------------------------------------------------------------------------------- /CPP/13_funcOverloading.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | 6 | int product(int a, int b) 7 | { 8 | return a * b; 9 | } 10 | 11 | int product(int a, int b, int c) 12 | { 13 | return a * b * c; 14 | } 15 | int main() 16 | { 17 | int a, b, c; 18 | a = 10; 19 | b = 20; 20 | c = 30; 21 | 22 | cout << "The product of a & b is " << product(a, b) << endl; 23 | cout << "The product of a, b & c is " << product(a, b, c) << endl; 24 | return 0; 25 | } 26 | -------------------------------------------------------------------------------- /CPP/14_Class.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | 6 | class MyClass 7 | { 8 | private: // only fuction inside the class can access this data 9 | int a, b, c; 10 | 11 | public: // whole program can access this data 12 | int d, e; 13 | 14 | void setData(int a1, int b1, int c1); 15 | void getData() 16 | { 17 | cout << "the value of a is " << a << endl; 18 | cout << "the value of b is " << b << endl; 19 | cout << "the value of c is " << c << endl; 20 | cout << "the value of d is " << d << endl; 21 | cout << "the value of e is " << e << endl; 22 | } 23 | }; 24 | 25 | void MyClass::setData(int a1, int b1, int c1) 26 | { 27 | a = a1; 28 | b = b1; 29 | c = c1; 30 | } 31 | int main() 32 | { 33 | MyClass e1; 34 | e1.d = 123; 35 | e1.e = 999; 36 | e1.setData(1, 23, 43); 37 | e1.getData(); 38 | return 0; 39 | } 40 | -------------------------------------------------------------------------------- /CPP/14_oops_Student.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | 6 | class Student 7 | { 8 | private: 9 | int roll; 10 | char name; 11 | 12 | public: 13 | Student(int roll); 14 | ~Student(); 15 | }; 16 | 17 | Student::Student(int roll) 18 | { 19 | } 20 | 21 | Student::~Student() 22 | { 23 | } 24 | 25 | int main() 26 | { 27 | 28 | return 0; 29 | } 30 | -------------------------------------------------------------------------------- /CPP/15_Binary.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | using namespace std; 6 | 7 | class binary 8 | { 9 | private: 10 | string s; 11 | void chk_binary(void); 12 | 13 | public: 14 | void read(void); 15 | void display(void); 16 | void ones_complement(void); 17 | }; 18 | 19 | void binary::read(void) 20 | { 21 | cout << "Enter binary number ----> " << endl; 22 | cin >> s; 23 | } 24 | void binary::chk_binary(void) 25 | { 26 | for (int i = 0; i < s.length(); i++) 27 | { 28 | if (s[i] != '0' && s[i] != '1') 29 | { 30 | cout << "Invalid binary format !!!"; 31 | exit(0); 32 | } 33 | } 34 | } 35 | void binary::display(void) 36 | { 37 | chk_binary(); 38 | cout << "Your binary is ----> "; 39 | cout << s << endl; 40 | } 41 | void binary::ones_complement(void) 42 | { 43 | chk_binary(); 44 | for (int i = 0; i < s.length(); i++) 45 | { 46 | if (s.at(i) == '0') 47 | { 48 | s[i] = '1'; 49 | } 50 | else 51 | { 52 | s[i] = '0'; 53 | } 54 | } 55 | cout << endl 56 | << "After ones complement " << endl; 57 | } 58 | int main() 59 | { 60 | binary a; 61 | a.read(); 62 | a.display(); 63 | a.ones_complement(); 64 | a.display(); 65 | getch(); 66 | return 0; 67 | } 68 | -------------------------------------------------------------------------------- /CPP/16_shop.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | 6 | class Shop 7 | { 8 | private: 9 | int itemId[100]; 10 | int itemPrice[100]; 11 | int counter; 12 | 13 | public: 14 | Shop(/* args */); 15 | ~Shop(); 16 | 17 | void setPrice(); 18 | void displayPrice(); 19 | }; 20 | 21 | Shop::Shop(/* args */) 22 | { 23 | counter = 0; 24 | } 25 | 26 | Shop::~Shop() 27 | { 28 | } 29 | 30 | void Shop::setPrice() 31 | { 32 | char c; 33 | cout << "Enter Item Id for no " << counter + 1 << endl; 34 | cin >> itemId[counter]; 35 | 36 | cout << "Enter Item Price" << endl; 37 | cin >> itemPrice[counter]; 38 | 39 | counter++; 40 | 41 | cout << "Do you want to insert new item ??" << endl; 42 | cin >> c; 43 | 44 | if (c == 'y') 45 | { 46 | setPrice(); 47 | } 48 | } 49 | void Shop::displayPrice() 50 | { 51 | cout << "Displaying total created items" << endl 52 | << endl; 53 | for (int i = 0; i < counter; i++) 54 | { 55 | cout << "Price for Item id " << itemId[i] << " is " << itemPrice[i] << endl; 56 | } 57 | } 58 | 59 | int main() 60 | { 61 | Shop s1; 62 | s1.setPrice(); 63 | s1.displayPrice(); 64 | s1.~Shop(); 65 | return 0; 66 | } 67 | -------------------------------------------------------------------------------- /CPP/17_emp.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | using namespace std; 6 | 7 | class Emp 8 | { 9 | private: 10 | int empId; 11 | string empName; 12 | int empSalary; 13 | static int counter; 14 | 15 | public: 16 | void getData(); 17 | void display(); 18 | static void getCounter(void); 19 | }; 20 | void Emp::getData() 21 | { 22 | cout << endl 23 | << "Enter emp id: "; 24 | cin >> empId; 25 | cout << endl 26 | << "Enter emp Name: "; 27 | cin >> empName; 28 | cout << endl 29 | << "Enter emp salary: "; 30 | cin >> empSalary; 31 | cout << endl 32 | << "----------------------------------" << endl 33 | << endl; 34 | counter++; 35 | } 36 | void Emp::display() 37 | { 38 | cout << "Employee number is ---------> " << counter << endl; 39 | cout << "Employee Id is: " << empId << endl; 40 | cout << "Employee Name is: " << empName << endl; 41 | cout << "Employee Salary is: " << empSalary << endl; 42 | cout << "___________________________________" << endl 43 | << endl; 44 | } 45 | int Emp::counter; // default value is zero 46 | // counter is static data member of class emp 47 | void Emp::getCounter(void) 48 | { 49 | cout << "the counter is " << counter << endl; 50 | } 51 | int main() 52 | { 53 | Emp Kunal, Harry, Alice; 54 | 55 | Kunal.getData(); 56 | Kunal.display(); 57 | Kunal.getCounter(); 58 | 59 | Harry.getData(); 60 | Harry.display(); 61 | Harry.getCounter(); 62 | 63 | Alice.getData(); 64 | Alice.display(); 65 | Alice.getCounter(); 66 | 67 | getch(); 68 | return 0; 69 | } 70 | -------------------------------------------------------------------------------- /CPP/18_empObjArray.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | using namespace std; 6 | 7 | class Emp 8 | { 9 | private: 10 | int empNo; 11 | double salary; 12 | string empName, city, Dname; 13 | 14 | // fuctions 15 | public: 16 | void accept() 17 | { 18 | cout << endl 19 | << "Enter your EmpNo : "; 20 | cin >> empNo; 21 | 22 | cout 23 | << "Enter your name : "; 24 | cin >> empName; 25 | 26 | cout 27 | << "Enter your Salary : "; 28 | cin >> salary; 29 | 30 | cout 31 | << "Enter your department : "; 32 | cin >> Dname; 33 | 34 | cout 35 | << "Enter your working city : "; 36 | cin >> city; 37 | } 38 | 39 | void display() 40 | { 41 | cout 42 | << "Emp no : " << empNo << endl; 43 | cout << "Emp Name : " << empName << endl; 44 | cout << "Emp salary : " << salary << endl; 45 | cout << "Emp city : " << city << endl; 46 | cout << "Emp Department : " << Dname << endl; 47 | } 48 | 49 | Emp(); 50 | ~Emp(); 51 | }; 52 | 53 | Emp::Emp() 54 | { 55 | } 56 | 57 | Emp::~Emp() 58 | { 59 | } 60 | 61 | int main() 62 | { 63 | Emp empDetails[3]; 64 | 65 | for (int i = 0; i < 3; i++) 66 | { 67 | empDetails[i].accept(); 68 | cout << endl 69 | << "Employee number is " << i + 1 << endl; 70 | empDetails[i].display(); 71 | } 72 | 73 | return 0; 74 | } 75 | -------------------------------------------------------------------------------- /CPP/18_objArray.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | 6 | class objArray 7 | { 8 | int id; 9 | int constNum; 10 | 11 | public: 12 | void setId(void) 13 | { 14 | constNum = 100; 15 | cout << "Enter the id for constNumber: "; 16 | cin >> id; 17 | } 18 | 19 | void getId(void) 20 | { 21 | cout << "constNum is " << constNum << " id is " << id << endl; 22 | } 23 | }; 24 | 25 | int main() 26 | { 27 | objArray OA[5]; 28 | 29 | for (int i = 0; i < 5; i++) 30 | { 31 | OA[i].setId(); 32 | OA[i].getId(); 33 | } 34 | 35 | return 0; 36 | } 37 | -------------------------------------------------------------------------------- /CPP/19_objPassing.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | 6 | class complex 7 | { 8 | int a, b; 9 | 10 | public: 11 | void setData(int v1, int v2); 12 | void getData(); 13 | void sumOfData(complex o1, complex o2); 14 | }; 15 | 16 | void complex::setData(int v1, int v2) 17 | { 18 | a = v1; 19 | b = v2; 20 | } 21 | 22 | void complex::getData() 23 | { 24 | cout << "complex number is " << a << " + " << b << "i" << endl; 25 | } 26 | 27 | void complex::sumOfData(complex o1, complex o2) 28 | { 29 | a = o1.a + o2.a; 30 | b = o1.b + o2.b; 31 | } 32 | int main() 33 | { 34 | complex c1, c2, c3; 35 | 36 | c1.setData(2, 4); 37 | c1.getData(); 38 | 39 | c2.setData(3, 2); 40 | c2.getData(); 41 | 42 | c3.sumOfData(c1, c2); 43 | c3.getData(); 44 | 45 | return 0; 46 | } 47 | -------------------------------------------------------------------------------- /CPP/20_friendFunction.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | 6 | class complex 7 | { 8 | int a, b; 9 | 10 | public: 11 | void setData(int n1, int n2); 12 | void getData(); 13 | friend complex sumOfComplexNum(complex o1, complex o2); 14 | }; 15 | 16 | void complex::setData(int n1, int n2) 17 | { 18 | a = n1; 19 | b = n2; 20 | } 21 | 22 | void complex::getData() 23 | { 24 | cout << "Your number is " << a << " + " << b << "i" << endl; 25 | } 26 | 27 | complex sumOfComplexNum(complex o1, complex o2) 28 | { 29 | complex o3; 30 | o3.setData((o1.a + o2.a), (o1.b + o2.b)); 31 | return o3; 32 | } 33 | 34 | int main() 35 | { 36 | complex c1, c2, sum; 37 | c1.setData(1, 4); 38 | c1.getData(); 39 | 40 | c2.setData(3, 5); 41 | c2.getData(); 42 | 43 | sum = sumOfComplexNum(c1, c2); 44 | sum.getData(); 45 | return 0; 46 | } 47 | 48 | /* 49 | Properties of friend function 50 | 51 | 1. Not in the scope of the class 52 | 2. friend function is allowed to do anything with class members 53 | 3. Since it is not in the scope of the class, it cannot be called from the object of that class 54 | 4. can be invoked without the help of any object 55 | 5. usually contains the objects as arguments 56 | 6. can be declared inside public or private section of the class 57 | 7. it can not access the members directly by their names and need object_name.member_name to access any member. 58 | */ 59 | -------------------------------------------------------------------------------- /CPP/21_friendClass.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | 6 | class complex; 7 | class calculator 8 | { 9 | public: 10 | int SumComplex(complex, complex); 11 | int add(int a, int b); 12 | int sumImgComplex(complex, complex); 13 | }; 14 | class complex 15 | { 16 | int a, b; 17 | friend class calculator; 18 | 19 | public: 20 | void setData(int n1, int n2); 21 | void getData(); 22 | }; 23 | 24 | void complex::setData(int n1, int n2) 25 | { 26 | a = n1; 27 | b = n2; 28 | } 29 | void complex::getData() 30 | { 31 | cout << "The number is " << a << " + " << b << "i" << endl; 32 | } 33 | 34 | int calculator::SumComplex(complex o1, complex o2) 35 | { 36 | return (o1.a + o2.a); 37 | } 38 | int calculator::add(int a, int b) 39 | { 40 | return (a + b); 41 | } 42 | 43 | int calculator::sumImgComplex(complex o1, complex o2) 44 | { 45 | return (o1.b + o2.b); 46 | } 47 | 48 | int main() 49 | { 50 | complex c1, c2; 51 | 52 | c1.setData(2, 3); 53 | c1.getData(); 54 | c2.setData(4, 5); 55 | c2.getData(); 56 | 57 | calculator calc; 58 | int res = calc.SumComplex(c1, c2); 59 | cout << "the sum of real part of c1 ad c2 is " << res << endl; 60 | 61 | int addRes = calc.add(2, 3); 62 | cout << "the addition of 2 and 3 is " << addRes << endl; 63 | 64 | int imgRes = calc.sumImgComplex(c1, c2); 65 | cout << "the sum of imaginary part of c1 ad c2 is " << imgRes << endl; 66 | return 0; 67 | } 68 | -------------------------------------------------------------------------------- /CPP/22_friend2func.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | 6 | class Y; 7 | 8 | class X 9 | { 10 | int data; 11 | 12 | public: 13 | void setValue(int value) 14 | { 15 | data = value; 16 | } 17 | 18 | friend int add(X o1, Y o2); 19 | }; 20 | 21 | class Y 22 | { 23 | int data; 24 | 25 | public: 26 | void setValue(int value) 27 | { 28 | data = value; 29 | } 30 | friend int add(X o1, Y o2); 31 | }; 32 | 33 | int add(X o1, Y o2) 34 | { 35 | return (o1.data + o2.data); 36 | } 37 | 38 | int main() 39 | { 40 | X o1; 41 | Y o2; 42 | 43 | o1.setValue(10); 44 | o2.setValue(20); 45 | 46 | int res = add(o1, o2); 47 | cout << "the addition of values is " << res << endl; 48 | return 0; 49 | } 50 | -------------------------------------------------------------------------------- /CPP/23_friendFunction.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | 6 | class Y; 7 | class X 8 | { 9 | int num1; 10 | friend void swapNum(X &, Y &); 11 | 12 | public: 13 | void getNum(int x) 14 | { 15 | num1 = x; 16 | } 17 | void showNum() 18 | { 19 | cout << "value of num1 " << num1 << endl; 20 | } 21 | }; 22 | 23 | class Y 24 | { 25 | int num2; 26 | 27 | public: 28 | void getNum(int x) 29 | { 30 | num2 = x; 31 | } 32 | void showNum() 33 | { 34 | cout << "value of num2 " << num2 << endl; 35 | } 36 | friend void swapNum(X &, Y &); 37 | }; 38 | 39 | void swapNum(X &o1, Y &o2) 40 | { 41 | int temp = o1.num1; 42 | o1.num1 = o2.num2; 43 | o2.num2 = temp; 44 | cout << endl 45 | << "After swapping of values " << endl; 46 | } 47 | 48 | int main() 49 | { 50 | X o1; 51 | Y o2; 52 | 53 | o1.showNum(); 54 | 55 | o1.getNum(10); 56 | o1.showNum(); 57 | 58 | o2.getNum(20); 59 | o2.showNum(); 60 | 61 | swapNum(o1, o2); 62 | o1.showNum(); 63 | o2.showNum(); 64 | 65 | return 0; 66 | } 67 | -------------------------------------------------------------------------------- /CPP/24_constructor.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | class Complex 6 | { 7 | private: 8 | int a, b; 9 | 10 | public: 11 | /* 12 | 13 | Creating a constructor 14 | # constructor It is a special member function with the same name as of the class. 15 | # it is used to initialize the objects of its class. 16 | # It is automatically invoked whenever an object is created. 17 | 18 | */ 19 | Complex(void); 20 | void printNumber() 21 | { 22 | cout << "your number is " << a << " + " << b << "i" << endl; 23 | } 24 | }; 25 | 26 | Complex::Complex(void) // --------> this is default constructor (no parameter) 27 | { 28 | a = 0; 29 | b = 0; 30 | cout << "inside the constructor" << endl; 31 | } 32 | 33 | int main() 34 | { 35 | Complex o1, o2, o3; 36 | 37 | o1.printNumber(); 38 | o2.printNumber(); 39 | o3.printNumber(); 40 | o1.printNumber(); 41 | return 0; 42 | } 43 | 44 | /* 45 | Characteristics of constructor 46 | 47 | 1. It should be declared inside the pubic section of the class. 48 | 2. they are automatically invoked whenever the object is created. 49 | 3. aapan kahi pan constructor madhe lihu shakto aani te pan automatically run hoin. 50 | 4. They cannot return values and do not have return types. 51 | 4. It can have default arguments its called default constructor. 52 | 6. We cannot refer to their address. 53 | */ 54 | -------------------------------------------------------------------------------- /CPP/25_parameterizedConstructor.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | 6 | class Complex 7 | { 8 | int a, b; 9 | 10 | public: 11 | Complex(int x, int y) // parameterized constructor (constructor with parameters) 12 | { 13 | a = x; 14 | b = y; 15 | } 16 | 17 | void printNumber() 18 | { 19 | cout << "your number is " << a << " + " << b << "i" << endl; 20 | } 21 | }; 22 | int main() 23 | { 24 | // implicit constructor call 25 | Complex o1(1, 2); 26 | o1.printNumber(); 27 | 28 | // explicit constructor call 29 | Complex o2 = Complex(12, 3); 30 | o2.printNumber(); 31 | return 0; 32 | } 33 | -------------------------------------------------------------------------------- /CPP/26_axis.cpp: -------------------------------------------------------------------------------- 1 | // Create a function which takes 2 points object and compute the distance between those point. 2 | #include 3 | #include 4 | #include 5 | 6 | using namespace std; 7 | 8 | class point2; 9 | 10 | class point1 11 | { 12 | int x1, y1; 13 | 14 | public: 15 | point1(int a, int b) 16 | { 17 | x1 = a; 18 | y1 = b; 19 | } 20 | void displayPoint() 21 | { 22 | cout << "The point1 is (" << x1 << "," << y1 << ")." << endl; 23 | } 24 | friend void distancePoint(point1, point2); 25 | }; 26 | 27 | class point2 28 | { 29 | int x2, y2; 30 | 31 | public: 32 | point2(int a, int b) 33 | { 34 | x2 = a; 35 | y2 = b; 36 | } 37 | void displayPoint() 38 | { 39 | cout << "The point2 is (" << x2 << "," << y2 << ")." << endl; 40 | } 41 | friend void distancePoint(point1, point2); 42 | }; 43 | 44 | void distancePoint(point1 p1, point2 p2) 45 | { 46 | int res; 47 | int x = p2.x2 - p1.x1; 48 | int y = p2.y2 - p1.y1; 49 | res = sqrt((x * x) + (y * y)); 50 | cout << "The distance between Point 1 to Point 2 is " << res << endl; 51 | } 52 | int main() 53 | { 54 | point1 p1(1, 0); 55 | p1.displayPoint(); 56 | 57 | point2 p2(70, 0); 58 | p2.displayPoint(); 59 | 60 | distancePoint(p1, p2); 61 | 62 | return 0; 63 | } 64 | -------------------------------------------------------------------------------- /CPP/27_constuctorOverloading.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | 6 | class Complex 7 | { 8 | int a, b; 9 | 10 | public: 11 | Complex(int x, int y) 12 | { 13 | cout << "I am parameterized Constructor with two argc !" << endl; 14 | a = x; 15 | b = y; 16 | } 17 | 18 | Complex(int x) 19 | { 20 | cout << "I am parameterized Constructor with one argc !" << endl; 21 | a = x; 22 | b = 0; 23 | } 24 | 25 | Complex() 26 | { 27 | a = 0; 28 | b = 0; 29 | cout << "I am default Constructor !" << endl; 30 | } 31 | 32 | void printComplex() 33 | { 34 | cout << "Complex number is " << a << " + " << b << "i" << endl 35 | << endl; 36 | } 37 | }; 38 | int main() 39 | { 40 | cout << "Constructor Overloading !!!" << endl 41 | << endl; 42 | 43 | Complex o1(2, 4); 44 | o1.printComplex(); 45 | 46 | Complex o2(6); 47 | o2.printComplex(); 48 | 49 | Complex o3; 50 | o3.printComplex(); 51 | 52 | getch(); 53 | return 0; 54 | } 55 | -------------------------------------------------------------------------------- /CPP/28_max3.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | 6 | class MaxNum 7 | { 8 | float a, b, c; 9 | 10 | public: 11 | MaxNum() 12 | { 13 | a = 0; 14 | b = 0; 15 | c = 0; 16 | } 17 | MaxNum(int x, int y, int z) 18 | { 19 | cout << endl 20 | << endl 21 | << "int" << endl; 22 | a = x; 23 | b = y; 24 | c = z; 25 | } 26 | MaxNum(float x, float y, float z) 27 | { 28 | cout << endl 29 | << endl 30 | << "float" << endl; 31 | a = x; 32 | b = y; 33 | c = z; 34 | } 35 | MaxNum(double x, double y, double z) 36 | { 37 | cout << endl 38 | << endl 39 | << "double" << endl; 40 | a = x; 41 | b = y; 42 | c = z; 43 | } 44 | 45 | void findMax() 46 | { 47 | if (a > b && a > c) 48 | { 49 | cout << "Max is " << a << endl; 50 | } 51 | else if (b > a && b > c) 52 | { 53 | cout << "Max is " << b << endl; 54 | } 55 | else 56 | { 57 | cout << "Max is " << c << endl; 58 | } 59 | } 60 | }; 61 | int main() 62 | { 63 | MaxNum o1; 64 | o1.findMax(); 65 | 66 | MaxNum o2(2, 3, 5); 67 | o2.findMax(); 68 | 69 | MaxNum o3(2.4f, 55.4f, 344.4f); 70 | o3.findMax(); 71 | 72 | MaxNum o4(12.2232, 123.2222, 213.222); 73 | o4.findMax(); 74 | return 0; 75 | } 76 | -------------------------------------------------------------------------------- /CPP/29_ConstructorDefaultArgc.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | 6 | class Simple 7 | { 8 | private: 9 | int data1, data2, data3; 10 | 11 | public: 12 | Simple(int a, int b, int c); 13 | ~Simple(); 14 | void printData(); 15 | }; 16 | 17 | Simple::Simple(int a, int b = 9, int c = 0) 18 | { 19 | data1 = a; 20 | data2 = b; 21 | data3 = c; 22 | } 23 | 24 | void Simple::printData(void) 25 | { 26 | cout << "value of variables is is " << data1 << "," << data2 << " and " << data3 << endl; 27 | } 28 | Simple::~Simple() 29 | { 30 | } 31 | 32 | int main() 33 | { 34 | Simple s(1.234); 35 | s.printData(); 36 | 37 | return 0; 38 | } 39 | -------------------------------------------------------------------------------- /CPP/29_pr_complexDefaultConsturctor.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | 6 | class Complex 7 | { 8 | int a, b, c; 9 | 10 | public: 11 | Complex(void) 12 | { 13 | a = 0; 14 | b = 0; 15 | } 16 | Complex(int x, int y = 12) 17 | { 18 | a = x; 19 | b = y; 20 | } 21 | Complex(int x, int y, int z = 0) 22 | { 23 | a = x; 24 | b = y; 25 | c = z; 26 | } 27 | void printData(void) 28 | { 29 | cout << "Your complex number is " << a << " + " << b << "i" << endl; 30 | } 31 | }; 32 | int main() 33 | { 34 | Complex o1; 35 | o1.printData(); 36 | 37 | Complex o2(1); 38 | o2.printData(); 39 | 40 | Complex o3(12, 23, 12); 41 | o3.printData(); 42 | 43 | return 0; 44 | } 45 | -------------------------------------------------------------------------------- /CPP/30_DynamicInitObjConsturctor.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | 6 | class BankDeposit 7 | { 8 | int principal; 9 | int years; 10 | float interestRate; 11 | float returnValue; 12 | 13 | public: 14 | BankDeposit() {} 15 | BankDeposit(int p, int y, int R); 16 | BankDeposit(int p, int y, float r); 17 | void show(void); 18 | }; 19 | 20 | void BankDeposit::show(void) 21 | { 22 | cout << endl 23 | << "principal amount was " << principal 24 | << " return value after " << years << " year is " << returnValue << endl; 25 | } 26 | BankDeposit::BankDeposit(int p, int y, float r) 27 | { 28 | principal = p; 29 | years = y; 30 | interestRate = r; 31 | returnValue = principal; 32 | 33 | for (int i = 0; i < y; i++) 34 | { 35 | returnValue = returnValue * (1 + interestRate); 36 | } 37 | } 38 | 39 | BankDeposit::BankDeposit(int p, int y, int r) 40 | { 41 | principal = p; 42 | years = y; 43 | interestRate = float(r) / 100; 44 | returnValue = principal; 45 | 46 | for (int i = 0; i < y; i++) 47 | { 48 | returnValue = returnValue * (1 + interestRate); 49 | } 50 | } 51 | int main() 52 | { 53 | BankDeposit BD1, BD2, BD3; 54 | 55 | int p, y; 56 | float r; // decimal form 57 | int R; // percentage form 58 | 59 | cout << endl 60 | << "Enter the value of p y and r " << endl; 61 | cin >> p >> y >> r; 62 | BD1 = BankDeposit(p, y, r); 63 | BD1.show(); 64 | 65 | cout << endl 66 | << "Enter the value of p y and R " << endl; 67 | cin >> p >> y >> R; 68 | BD2 = BankDeposit(p, y, R); 69 | BD2.show(); 70 | return 0; 71 | } 72 | -------------------------------------------------------------------------------- /CPP/31_copyConstructor.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Constructor ha aka object che memory dusraya object la assign karto 3 | 4 | 1. When there is no copy constructor found compiler supplies its own copy constructor 5 | 2. jar object ha pahilya pasun banaclela asel tar copy constructor ha call honar nahi 6 | */ 7 | #include 8 | #include 9 | 10 | using namespace std; 11 | 12 | class MyNum 13 | { 14 | int data; 15 | 16 | public: 17 | MyNum() 18 | { 19 | data = 0; 20 | } 21 | MyNum(int n) 22 | { 23 | data = n; 24 | } 25 | MyNum(MyNum &n) 26 | { 27 | cout << "copyConstructorCalled !!!" << endl; 28 | data = n.data; 29 | } 30 | 31 | // function 32 | void show(void) 33 | { 34 | cout << "The value of data is " << data << endl; 35 | } 36 | }; 37 | int main() 38 | { 39 | MyNum n1, n2(12), n3; 40 | n1.show(); 41 | n2.show(); 42 | n3 = n2; 43 | n3.show(); 44 | MyNum neww = n2; 45 | neww.show(); 46 | return 0; 47 | } 48 | -------------------------------------------------------------------------------- /CPP/32_Destructor.cpp: -------------------------------------------------------------------------------- 1 | /* Destructor never takes an argument and does not return any value 2 | automatically called by compiler implicitly 3 | */ 4 | 5 | #include 6 | #include 7 | 8 | using namespace std; 9 | int count = 0; 10 | 11 | class Num 12 | { 13 | 14 | public: 15 | Num() 16 | { 17 | count++; 18 | cout << "Constructor is called. count is " << count << endl; 19 | } 20 | ~Num() 21 | { 22 | count--; 23 | cout << "Destructor is called. count is " << count << endl; 24 | } 25 | }; 26 | 27 | int main() 28 | { 29 | cout << "Main function is started !" << endl; 30 | Num obj; 31 | cout << "inside main function above obj" << endl; 32 | { 33 | cout << "I am inside the nested block" << endl; 34 | Num o; 35 | cout << "obj created and exiting this block" << endl; 36 | } 37 | cout << "back to main " << endl; 38 | return 0; 39 | } 40 | -------------------------------------------------------------------------------- /CPP/33_Inheritance.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | 6 | class MyClass 7 | { 8 | private: 9 | public: 10 | int a; 11 | MyClass() 12 | { 13 | a = 0; 14 | } 15 | MyClass(int x) 16 | { 17 | a = x; 18 | } 19 | void show() 20 | { 21 | cout << "data is " << a << endl; 22 | } 23 | }; 24 | 25 | class NewClass : MyClass 26 | { 27 | private: 28 | int b; 29 | 30 | public: 31 | NewClass(int y) 32 | { 33 | b = y; 34 | } 35 | void show() 36 | { 37 | cout << "data is " << b << endl; 38 | cout << "addition of a and b is " << a + b << endl; 39 | } 40 | }; 41 | 42 | int main() 43 | { 44 | MyClass obj(2); 45 | obj.show(); 46 | 47 | NewClass obj2(4); 48 | obj2.show(); 49 | return 0; 50 | } 51 | -------------------------------------------------------------------------------- /CPP/34_inheritance-new.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | 6 | class Employee 7 | { 8 | 9 | public: 10 | int empId; 11 | float salary; 12 | Employee() {} 13 | Employee(int id) 14 | { 15 | empId = id; 16 | salary = 100; 17 | } 18 | }; 19 | // class {{DerivedClassName}} : {{VisibilityMode}} {{BaseClass}} 20 | // Visibility Mode 21 | // 1. public : public members of base class becomes public members of derived class. 22 | // 2. private : public members of base class becomes private members of derived class. 23 | // -------------- Private members of base class never ever inherited !!! ---------------------- 24 | // 25 | class Programmer : Employee 26 | { 27 | public: 28 | Programmer(int id) 29 | { 30 | empId = id; 31 | } 32 | int languageCode = 9; // 9 for cpp 33 | }; 34 | int main() 35 | { 36 | Employee harry(1), sam(2); 37 | cout << harry.salary << endl; 38 | cout << sam.salary << endl; 39 | 40 | Programmer asdf(12); 41 | cout << asdf.languageCode; 42 | return 0; 43 | } 44 | -------------------------------------------------------------------------------- /CPP/35_private.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | class Base 6 | { 7 | int a; // private by default not inheritable 8 | public: 9 | int b; // public inheritable 10 | void setData(); 11 | int getA(); 12 | int getB(); 13 | }; 14 | void Base ::setData(void) 15 | { 16 | a = 10; 17 | b = 20; 18 | } 19 | int Base::getA() 20 | { 21 | return a; 22 | } 23 | int Base::getB() 24 | { 25 | return b; 26 | } 27 | 28 | class Derived : private Base 29 | { 30 | int c; 31 | 32 | public: 33 | void process(); 34 | void display(); 35 | }; 36 | void Derived::process() 37 | { 38 | setData(); 39 | c = b * getA(); 40 | } 41 | void Derived::display() 42 | { 43 | cout << "Value of a is " << getA() << endl; 44 | cout << "Value of b is " << b << endl; 45 | cout << "Value of c is " << c << endl; 46 | } 47 | 48 | int main() 49 | { 50 | Derived der; 51 | // der.setData(); 52 | der.display(); 53 | der.process(); 54 | der.display(); 55 | 56 | return 0; 57 | } 58 | -------------------------------------------------------------------------------- /CPP/35_singleInheritance.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | class Base 6 | { 7 | int a; // private by default not inheritable 8 | public: 9 | int b; // public inheritable 10 | void setData(); 11 | int getA(); 12 | int getB(); 13 | }; 14 | void Base ::setData(void) 15 | { 16 | a = 10; 17 | b = 20; 18 | } 19 | int Base::getA() 20 | { 21 | return a; 22 | } 23 | int Base::getB() 24 | { 25 | return b; 26 | } 27 | 28 | class Derived : public Base 29 | { 30 | int c; 31 | 32 | public: 33 | void process(); 34 | void display(); 35 | }; 36 | void Derived::process() 37 | { 38 | c = b * getA(); 39 | } 40 | void Derived::display() 41 | { 42 | cout << "Value of a is " << getA() << endl; 43 | cout << "Value of b is " << b << endl; 44 | cout << "Value of c is " << c << endl; 45 | } 46 | 47 | int main() 48 | { 49 | Derived der; 50 | der.setData(); 51 | der.display(); 52 | der.process(); 53 | der.display(); 54 | 55 | return 0; 56 | } 57 | -------------------------------------------------------------------------------- /CPP/36_Protected.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | /* 5 | For a protected Member: 6 | public Derivation private Derivation Protected Derivation 7 | 1. private member not inherited not inherited not inherited 8 | 2. public member public private protected 9 | 3. protected member protected private protected 10 | */ 11 | 12 | using namespace std; 13 | 14 | class Base 15 | { 16 | private: 17 | int b = 0; 18 | 19 | protected: 20 | int a = 0; 21 | 22 | public: 23 | }; 24 | 25 | class Derived : public Base 26 | { 27 | private: 28 | protected: 29 | public: 30 | }; 31 | int main() 32 | { 33 | Base b1; 34 | Derived d; 35 | // cout << d.b; will not run 36 | return 0; 37 | } 38 | -------------------------------------------------------------------------------- /CPP/37_multilavel.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | /* 6 | Notes: 7 | if we are inheriting A and c from B: [A---->B---->C] 8 | 1. A is th base class for B and B is base class for C 9 | 2. A---->B---->C is called Inheritance Path 10 | */ 11 | class Student 12 | { 13 | protected: 14 | int roll_number; 15 | 16 | public: 17 | void set_roll_number(int); 18 | void get_roll_number(void); 19 | }; 20 | 21 | void Student::set_roll_number(int r) 22 | { 23 | roll_number = r; 24 | } 25 | 26 | void Student::get_roll_number() 27 | { 28 | cout << "roll number is " << roll_number << endl; 29 | } 30 | 31 | class Exam : public Student 32 | { 33 | protected: 34 | float maths, physics; 35 | 36 | public: 37 | void set_marks(float m, float p); 38 | void get_marks(void); 39 | }; 40 | 41 | void Exam::set_marks(float m, float p) 42 | { 43 | maths = m; 44 | physics = p; 45 | // if ((maths <= 101.0 && maths >= 0.0) && (physics <= 101.0 && physics >= 0.0)) 46 | // { 47 | // cout << "Marks should be less than 100 and greater than 0 " << endl; 48 | // exit(0); 49 | // } 50 | // else 51 | // { 52 | // cout << "fuck you"; 53 | // } 54 | } 55 | void Exam::get_marks() 56 | { 57 | cout << "The marks in maths are " << maths << " and physics marks is " << physics << endl; 58 | } 59 | class Result : public Exam 60 | { 61 | protected: 62 | float percentage; 63 | 64 | public: 65 | void result() 66 | { 67 | get_roll_number(); 68 | get_marks(); 69 | percentage = (maths + physics) / 2; 70 | cout << "Your percentage is " << percentage; 71 | } 72 | }; 73 | 74 | int main() 75 | { 76 | Result harry; 77 | harry.set_roll_number(100); 78 | harry.set_marks(90, 90); 79 | cout << ".......................Result........................." << endl; 80 | harry.result(); 81 | return 0; 82 | } -------------------------------------------------------------------------------- /CPP/38_multipleINHERITANCE.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | 6 | class A 7 | { 8 | protected: 9 | int a; 10 | 11 | public: 12 | void seta(int a1) 13 | { 14 | a = a1; 15 | } 16 | }; 17 | class B 18 | { 19 | protected: 20 | int b; 21 | 22 | public: 23 | void setb(int b1) 24 | { 25 | b = b1; 26 | } 27 | }; 28 | class C : public A, public B 29 | { 30 | protected: 31 | int c; 32 | 33 | public: 34 | void setc(int c1) 35 | { 36 | c = c1; 37 | } 38 | int product() 39 | { 40 | return a * b * c; 41 | } 42 | void display(void) 43 | { 44 | cout << "The value of A is " << a << endl; 45 | cout << "The value of b is " << b << endl; 46 | cout << "The value of c is " << c << endl; 47 | cout << "The Addition is " << a + b + c << endl; 48 | cout << "The product of a*b*c is " << product() << endl; 49 | } 50 | }; 51 | int main() 52 | { 53 | C obj; 54 | obj.seta(2); 55 | obj.setb(4); 56 | obj.setc(2); 57 | obj.display(); 58 | return 0; 59 | } -------------------------------------------------------------------------------- /CPP/39_Calculactor.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | using namespace std; 6 | 7 | class SimpleCalculator 8 | { 9 | private: 10 | int ch; 11 | 12 | protected: 13 | int a, b; 14 | 15 | public: 16 | SimpleCalculator(); 17 | ~SimpleCalculator(); 18 | void setValue(float v1, float v2) 19 | { 20 | a = v1; 21 | b = v2; 22 | } 23 | void simpmenu() 24 | { 25 | cout << endl 26 | << "Menu for Simple Calculator" << endl; 27 | cout << "1. Add" << endl 28 | << "2. sub" << endl 29 | << "3. Mul" << endl 30 | << "4. div" << endl; 31 | cout << "Enter operation number : "; 32 | cin >> ch; 33 | } 34 | void operations() 35 | { 36 | 37 | switch (ch) 38 | { 39 | case 1: 40 | cout << "Addition of " << a << " and " << b << " is " << a + b << endl; 41 | break; 42 | case 2: 43 | cout << "Subtraction of " << a << " and " << b << " is " << a - b << endl; 44 | break; 45 | case 3: 46 | cout << "Multiplication of " << a << " and " << b << " is " << a * b << endl; 47 | break; 48 | case 4: 49 | cout << "Division of " << a << " and " << b << " is " << a / b << endl; 50 | break; 51 | default: 52 | cout << "Enter valid choice !!!"; 53 | break; 54 | } 55 | } 56 | }; 57 | 58 | SimpleCalculator::SimpleCalculator() 59 | { 60 | } 61 | 62 | SimpleCalculator::~SimpleCalculator() 63 | { 64 | } 65 | 66 | class ScientificCalculator : public SimpleCalculator 67 | { 68 | private: 69 | int ch; 70 | 71 | protected: 72 | public: 73 | void Scimenu() 74 | { 75 | cout << endl 76 | << "Menu for Scientific Calculator" << endl; 77 | cout << "1. Absolute" << endl 78 | << "2. Square root" << endl 79 | << "3. Cube root" << endl 80 | << "4. log10" << endl; 81 | cout << "Enter operation number : "; 82 | cin >> ch; 83 | } 84 | void operations() 85 | { 86 | switch (ch) 87 | { 88 | case 1: 89 | cout << "Absolute of " << a << " and " << b << " is " << abs(a) << " & " << abs(b) << endl; 90 | break; 91 | case 2: 92 | cout << "Square root of " << a << " and " << b << " is " << sqrt(a) << " & " << sqrt(b) << endl; 93 | break; 94 | case 3: 95 | cout << "Cube root of " << a << " and " << b << " is " << cbrt(a) << " & " << cbrt(b) << endl; 96 | break; 97 | case 4: 98 | cout << "log10 of " << a << " and " << b << " is " << log10(a) << " & " << log10(b) << endl; 99 | break; 100 | default: 101 | cout << "Enter valid choice !!!"; 102 | break; 103 | } 104 | } 105 | }; 106 | 107 | class HybridCalculator : public SimpleCalculator, public ScientificCalculator 108 | { 109 | private: 110 | public: 111 | void display() 112 | { 113 | SimpleCalculator simpobj; 114 | simpobj.setValue(10, 20); 115 | simpobj.simpmenu(); 116 | simpobj.operations(); 117 | 118 | ScientificCalculator obj; 119 | obj.setValue(10, 20); 120 | obj.Scimenu(); 121 | obj.operations(); 122 | } 123 | }; 124 | 125 | int main() 126 | { 127 | HybridCalculator obj; 128 | obj.display(); 129 | return 0; 130 | } 131 | -------------------------------------------------------------------------------- /CPP/41_ambiguity.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | 6 | class Base1 7 | { 8 | private: 9 | int a; 10 | 11 | public: 12 | void greet() 13 | { 14 | cout << "How are you? " << endl; 15 | } 16 | }; 17 | 18 | class Base2 19 | { 20 | private: 21 | int b; 22 | 23 | public: 24 | void greet() 25 | { 26 | cout << "Kasa aahes? " << endl; 27 | } 28 | }; 29 | 30 | class Derived : public Base1, public Base2 31 | { 32 | int c; 33 | 34 | public: 35 | void greet() 36 | { 37 | Base1::greet(); 38 | Base2::greet(); 39 | } 40 | }; 41 | int main() 42 | { 43 | // Base1 base1obj; 44 | // Base2 base2obj; 45 | // base1obj.greet(); 46 | // base2obj.greet(); 47 | 48 | Derived d; 49 | d.greet(); 50 | return 0; 51 | } 52 | -------------------------------------------------------------------------------- /CPP/42_ambiguity2.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | 6 | class B 7 | { 8 | public: 9 | void say() 10 | { 11 | cout << "hello World" << endl; 12 | } 13 | }; 14 | class D : public B 15 | { 16 | int a; 17 | 18 | public: 19 | void say() 20 | { 21 | cout << "Hello My Babe" << endl; 22 | } 23 | }; 24 | int main() 25 | { 26 | B b; 27 | b.say(); 28 | 29 | D d; 30 | d.say(); 31 | return 0; 32 | } -------------------------------------------------------------------------------- /CPP/43_VirtualBaseClass.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Virtual Base Class 3 | 4 | class Student is main base class 5 | class Test and Sports inherits data from student base class 6 | class Result is derived from test & sports 7 | 8 | Student 9 | Student --> Test 10 | Student --> sports 11 | test & Sports -- > result 12 | */ 13 | #include 14 | #include 15 | 16 | using namespace std; 17 | 18 | class Student 19 | { 20 | protected: 21 | int rollNo; 22 | 23 | public: 24 | Student() 25 | { 26 | rollNo = 1; 27 | } 28 | void set_Number(int a) 29 | { 30 | rollNo = a; 31 | } 32 | void print_number(void) 33 | { 34 | cout << endl 35 | << "Your Roll No is " << rollNo << endl; 36 | } 37 | }; 38 | 39 | class Test : virtual public Student 40 | { 41 | protected: 42 | float maths, physics; 43 | 44 | public: 45 | Test() 46 | { 47 | maths = 0; 48 | physics = 0; 49 | } 50 | void set_marks(float m1, float m2) 51 | { 52 | maths = m1; 53 | physics = m2; 54 | } 55 | void print_marks(void) 56 | { 57 | cout << "Your Result is here: " << endl 58 | << " Maths : " << maths << endl 59 | << " Physics : " << physics << endl; 60 | } 61 | }; 62 | 63 | class Sports : virtual public Student 64 | { 65 | protected: 66 | float score; 67 | 68 | public: 69 | Sports() 70 | { 71 | score = 0; 72 | } 73 | void set_score(float sc) 74 | { 75 | score = sc; 76 | } 77 | void print_score(void) 78 | { 79 | cout << "Your PT score is " << score << endl; 80 | } 81 | }; 82 | 83 | class Result : public Test, public Sports 84 | { 85 | private: 86 | float total; 87 | 88 | public: 89 | Result() 90 | { 91 | total = 0; 92 | } 93 | void display(void) 94 | { 95 | total = maths + physics + score; 96 | print_number(); 97 | print_marks(); 98 | print_score(); 99 | cout << "Your total score is " << total << endl; 100 | } 101 | }; 102 | 103 | int main() 104 | { 105 | Result kunal; 106 | kunal.set_Number(101); 107 | kunal.set_marks(60, 90); 108 | kunal.set_score(9); 109 | kunal.display(); 110 | 111 | Result Harry; 112 | Harry.set_Number(102); 113 | Harry.set_marks(34, 33); 114 | Harry.set_score(6); 115 | Harry.display(); 116 | return 0; 117 | } 118 | -------------------------------------------------------------------------------- /CPP/44_Calc.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | using namespace std; 6 | 7 | class SimpleCalculator 8 | { 9 | protected: 10 | int a, b; 11 | 12 | public: 13 | void getData() 14 | { 15 | cout << "Enter the value of a" << endl; 16 | cin >> a; 17 | cout << "Enter the value of b" << endl; 18 | cin >> b; 19 | } 20 | void performOperation() 21 | { 22 | cout << "The value of a + b is " << a + b << endl; 23 | cout << "The value of a - b is " << a - b << endl; 24 | cout << "The value of a * b is " << a * b << endl; 25 | cout << "The value of a / b is " << a / b << endl; 26 | } 27 | }; 28 | class ScientificCalculator 29 | { 30 | protected: 31 | int a, b; 32 | 33 | public: 34 | void getData() 35 | { 36 | cout << endl 37 | << "Enter the value of a" << endl; 38 | cin >> a; 39 | cout << "Enter the value of b" << endl; 40 | cin >> b; 41 | } 42 | void performOperation() 43 | { 44 | cout << "The value of sin(a) is " << sin(a) << endl; 45 | cout << "The value of cos(a) is " << cos(a) << endl; 46 | cout << "The value of pow(a, 3) is " << pow(a, 3) << endl; 47 | cout << "The value of exp(a) is " << exp(a) << endl; 48 | cout << "The value of tan(a) is " << tan(a) << endl 49 | << endl; 50 | 51 | cout << "The value of sin(b) is " << sin(b) << endl; 52 | cout << "The value of cos(b) is " << cos(b) << endl; 53 | cout << "The value of pow(b, 3) is " << pow(b, 3) << endl; 54 | cout << "The value of exp(b) is " << exp(b) << endl; 55 | cout << "The value of tan(b) is " << tan(b) << endl 56 | << endl; 57 | } 58 | }; 59 | 60 | class HybridCalculator : public SimpleCalculator, public ScientificCalculator 61 | { 62 | public: 63 | void SimpleCalcDisplay() 64 | { 65 | SimpleCalculator::getData(); 66 | SimpleCalculator::performOperation(); 67 | } 68 | void SciCalcDisplay() 69 | { 70 | ScientificCalculator::getData(); 71 | ScientificCalculator::performOperation(); 72 | } 73 | }; 74 | int main() 75 | { 76 | HybridCalculator calc; 77 | calc.SimpleCalcDisplay(); 78 | calc.SciCalcDisplay(); 79 | return 0; 80 | } -------------------------------------------------------------------------------- /CPP/45_ConstVirtual.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | 6 | /* 7 | Constructor execution in inheritance 8 | 9 | case1: 10 | 11 | class B: public A{ 12 | order of execution of constructor ---> A() -> B() 13 | } 14 | 15 | case2: 16 | 17 | class B: public A, public C{ 18 | order of execution of constructor ---> A() -> C() -> B() 19 | } 20 | 21 | case3: 22 | 23 | class B: public C, public A{ 24 | order of execution of constructor ---> C() -> A() -> B() 25 | } 26 | 27 | case4: 28 | 29 | class B: public C, virtual public A{ 30 | order of execution of constructor ---> A() -> C() -> B() 31 | } 32 | 33 | 34 | case5: 35 | 36 | class B: virtual public C, public A{ 37 | order of execution of constructor ---> C() -> A() -> B() 38 | } 39 | 40 | case6: 41 | 42 | class B: virtual public C, virtual public A{ 43 | order of execution of constructor ---> C() -> A() -> B() 44 | } 45 | */ 46 | 47 | class Base1 48 | { 49 | int data1; 50 | 51 | public: 52 | Base1(int i) 53 | { 54 | data1 = i; 55 | cout << "Base1 class constructor called" << endl; 56 | } 57 | void printData1(void) 58 | { 59 | cout << "the value of Data1 is " << data1 << endl; 60 | } 61 | }; 62 | 63 | class Base2 64 | { 65 | int data2; 66 | 67 | public: 68 | Base2(int i) 69 | { 70 | data2 = i; 71 | cout << "Base2 class constructor called" << endl; 72 | } 73 | void printData2(void) 74 | { 75 | cout << "the value of Data2 is " << data2 << endl; 76 | } 77 | }; 78 | 79 | class Derived1 : public Base1 80 | { 81 | int data3; 82 | 83 | public: 84 | Derived1(int a, int c) : Base1(a) 85 | { 86 | data3 = c; 87 | cout << "Derived1 class constructor called!" << endl; 88 | } 89 | void printData3(void) 90 | { 91 | cout << "the value of Data3 is " << data3 << endl; 92 | } 93 | }; 94 | 95 | class Derived2 : public Base1, public Base2 96 | { 97 | int data3; 98 | 99 | public: 100 | Derived2(int a, int b, int c) : Base2(a), Base1(b) 101 | { 102 | data3 = c; 103 | cout << "Derived2 class constructor called!" << endl; 104 | } 105 | void printData3(void) 106 | { 107 | cout << "the value of Data3 is " << data3 << endl; 108 | } 109 | }; 110 | 111 | class Derived3 : public Base2, public Base1 112 | { 113 | int data3; 114 | 115 | public: 116 | Derived3(int a, int b, int c) : Base2(a), Base1(b) 117 | { 118 | data3 = c; 119 | cout << "Derived3 class constructor called!" << endl; 120 | } 121 | void printData3(void) 122 | { 123 | cout << "the value of Data3 is " << data3 << endl; 124 | } 125 | }; 126 | 127 | class Derived4 : public Base2, virtual public Base1 128 | { 129 | int data3; 130 | 131 | public: 132 | Derived4(int a, int b, int c) : Base2(a), Base1(b) 133 | { 134 | data3 = c; 135 | cout << "Derived4 class constructor called!" << endl; 136 | } 137 | void printData3(void) 138 | { 139 | cout << "the value of Data3 is " << data3 << endl; 140 | } 141 | }; 142 | 143 | class Derived5 : virtual public Base2, public Base1 144 | { 145 | int data3; 146 | 147 | public: 148 | Derived5(int a, int b, int c) : Base2(a), Base1(b) 149 | { 150 | data3 = c; 151 | cout << "Derived5 class constructor called!" << endl; 152 | } 153 | void printData3(void) 154 | { 155 | cout << "the value of Data3 is " << data3 << endl; 156 | } 157 | }; 158 | 159 | class Derived6 : virtual public Base2, virtual public Base1 160 | { 161 | int data3; 162 | 163 | public: 164 | Derived6(int a, int b, int c) : Base2(a), Base1(b) // initialization-section 165 | { 166 | data3 = c; 167 | cout << "Derived6 class constructor called!" << endl; 168 | } 169 | void printData3(void) 170 | { 171 | cout << "the value of Data3 is " << data3 << endl; 172 | } 173 | }; 174 | 175 | int main() 176 | { 177 | Derived1 obj1(3, 4); 178 | cout << endl; 179 | Derived2 obj2(2, 3, 4); 180 | cout << endl; 181 | Derived3 obj3(2, 3, 4); 182 | cout << endl; 183 | Derived4 obj4(2, 3, 4); 184 | cout << endl; 185 | Derived5 obj5(2, 3, 4); 186 | cout << endl; 187 | Derived6 obj6(2, 3, 4); 188 | 189 | return 0; 190 | } 191 | -------------------------------------------------------------------------------- /CPP/46_initList.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | /* 6 | Initialization list & initialization section 7 | 8 | constructor(argument-list) : initialization-section 9 | { 10 | 11 | } 12 | */ 13 | 14 | class init 15 | { 16 | private: 17 | int a, b; 18 | 19 | public: 20 | // init(int i, int j) : a(i), b(j) 21 | // init(int i, int j) : a(i), b(i + j) 22 | // init(int i, int j) : a(i), b(3 * j) 23 | // init(int i, int j) : a(i), b(a * j) 24 | // init(int i, int j) : b(j), a(i * b) // err will not come | a initialise first a will be initialise first 25 | init(int i, int j) : a(i), b(a * j) 26 | { 27 | // constructor body 28 | cout << "I am in constructor" << endl; 29 | cout << "value of a " << a << endl; 30 | cout << "value of b " << b << endl; 31 | } 32 | }; 33 | 34 | int main() 35 | { 36 | init obj(2, 3); 37 | return 0; 38 | } 39 | -------------------------------------------------------------------------------- /CPP/47_pointNewDel.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | 6 | int main() 7 | { 8 | 9 | int a = 4; 10 | int *ptr = &a; 11 | 12 | *ptr = 999; 13 | cout << "the value of a is " << a << endl; 14 | cout << "the value of &a is " << &a << endl; 15 | cout << "the value of ptr is " << ptr << endl; 16 | cout << "the value of *ptr is " << *ptr << endl; 17 | cout << "the value of &ptr is " << &ptr << endl; 18 | 19 | int *p = new int(34); 20 | cout << "the value at address p is " << *(p) << endl; 21 | cout << "the value at address p is " << p << endl; 22 | 23 | delete p; 24 | 25 | int *pp = new int(a); 26 | cout << "value at pp " << *pp << endl; 27 | 28 | int *arr = new int[4]; 29 | arr[0] = 2; 30 | *(arr + 1) = 4; 31 | arr[2] = 6; 32 | arr[3] = 8; 33 | 34 | // delete[] arr; 35 | 36 | for (int i = 0; i < sizeof(arr); i++) 37 | { 38 | cout << "arr[" << i << "] = " << arr[i] << endl; 39 | } 40 | 41 | float *abc = new float('a'); 42 | cout << "value of *abc is " << *abc << endl; 43 | 44 | return 0; 45 | } 46 | -------------------------------------------------------------------------------- /CPP/48_PointerObj.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | 6 | class Complex 7 | { 8 | int real, imag; 9 | 10 | public: 11 | void setData(int a, int b) 12 | { 13 | real = a; 14 | imag = b; 15 | } 16 | void getData() 17 | { 18 | cout << "The real part is " << real; 19 | cout << " The imaginary part is " << imag << endl; 20 | } 21 | }; 22 | int main() 23 | { 24 | // Complex c; 25 | // Complex *ptr = &c; 26 | // Complex *ptr = new Complex; 27 | // // (*ptr).setData(12, 2); 28 | // ptr->setData(12, 2); 29 | // (*ptr).getData(); 30 | 31 | Complex *ptr1 = new Complex[4]; 32 | ptr1->setData(1, 2); 33 | (ptr1 + 1)->setData(7, 5); 34 | (ptr1 + 2)->setData(99, 96); 35 | (ptr1 + 3)->setData(21, 90); 36 | 37 | for (int i = 0; i < 4; i++) 38 | { 39 | (ptr1 + i)->getData(); 40 | } 41 | 42 | return 0; 43 | } 44 | -------------------------------------------------------------------------------- /CPP/49_arrPointerObj.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | 6 | class Shop 7 | { 8 | int id; 9 | float price; 10 | 11 | public: 12 | void setData(int a, int b) 13 | { 14 | id = a; // implicit this pointer invoked 15 | price = b; 16 | } 17 | 18 | void getData(void) 19 | { 20 | cout << "Code of this item is " << id << endl; 21 | cout << "Price of the object is " << price << endl 22 | << endl; 23 | } 24 | }; 25 | 26 | int main() 27 | { 28 | int size = 3, p, q; 29 | Shop *ptr = new Shop[size]; // *ptr ha store shop cha address 30 | Shop *ptrTemp = ptr; 31 | 32 | for (int i = 0; i < size; i++) 33 | { 34 | cout << "Enter id and price of item " << i + 1 << endl; 35 | cin >> p >> q; 36 | ptr->setData(p, q); 37 | ptr++; 38 | } 39 | 40 | for (int i = 0; i < size; i++) 41 | { 42 | cout << "Item number: " << i + 1 << endl; 43 | ptrTemp->getData(); 44 | ptrTemp++; 45 | } 46 | 47 | return 0; 48 | } -------------------------------------------------------------------------------- /CPP/50_thisPointer.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | 6 | class A 7 | { 8 | int a; 9 | 10 | protected: 11 | public: 12 | // A &setData(int a) 13 | void setData(int a) 14 | { 15 | this->a = a; // priority is give to the local variable 16 | // return *this; 17 | } 18 | void getData(void) 19 | { 20 | cout << "The value of a is " << a << endl; 21 | } 22 | }; 23 | 24 | int main() 25 | { 26 | A a; 27 | a.setData(4); 28 | // a.setData(4).getData(); // implicit invoke 29 | a.getData(); // explicit invoke 30 | return 0; 31 | } 32 | -------------------------------------------------------------------------------- /CPP/51_polymorphism.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | 6 | class Base 7 | { 8 | public: 9 | int _base = 2; 10 | virtual void display() 11 | { 12 | cout << "The value of _base is " << _base << endl; 13 | } 14 | }; 15 | 16 | class Derived : public Base 17 | { 18 | public: 19 | int _derived = 2; 20 | void display() 21 | { 22 | cout << "The value of _base is " << _base << endl; 23 | cout << "The value of _derived is " << _derived << endl; 24 | } 25 | }; 26 | 27 | int main() 28 | { 29 | Base *p_b, b; 30 | Derived d; 31 | 32 | p_b = &d; 33 | p_b->display(); 34 | 35 | return 0; 36 | } -------------------------------------------------------------------------------- /CPP/52_operatorOverloading.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | 6 | class Point 7 | { 8 | private: 9 | int x; 10 | int y; 11 | 12 | public: 13 | Point(int x = 0, int y = 0) : x{x}, y{y} {} 14 | Point operator+(const Point &rhs) 15 | { 16 | Point p; 17 | p.x = x + rhs.x; 18 | p.y = y + rhs.y; 19 | return p; 20 | } 21 | 22 | Point operator-(const Point &rhs) 23 | { 24 | Point p; 25 | p.x = x - rhs.x; 26 | p.y = y - rhs.y; 27 | return p; 28 | } 29 | Point operator*(const Point &rhs) 30 | { 31 | Point p; 32 | p.x = x * rhs.x; 33 | p.y = y * rhs.y; 34 | return p; 35 | } 36 | Point operator/(const Point &rhs) 37 | { 38 | Point p; 39 | p.x = x / rhs.x; 40 | p.y = y / rhs.y; 41 | return p; 42 | } 43 | void display(void) 44 | { 45 | cout << " x: " << x << " y: " << y << endl; 46 | } 47 | }; 48 | 49 | int main() 50 | { 51 | int a = 12; 52 | int b = 10; 53 | int c = a + b; 54 | cout << c << endl; 55 | 56 | Point p1(4, 8), p2(2, 4); 57 | // 1, 2 58 | // 3, 4 59 | Point p3 = p1 + p2; 60 | p3.display(); 61 | 62 | p3 = p1 - p2; 63 | p3.display(); 64 | 65 | p3 = p1 * p2; 66 | p3.display(); 67 | 68 | p3 = p1 / p2; 69 | p3.display(); 70 | 71 | return 0; 72 | } 73 | -------------------------------------------------------------------------------- /CPP/53_incrementOverloading.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | 6 | class Salary 7 | { 8 | private: 9 | int sal; 10 | 11 | public: 12 | Salary(int sal) : sal{sal} {} 13 | 14 | int operator++(int) 15 | { 16 | cout << "in operator function" << endl; 17 | ++sal; 18 | } 19 | 20 | int operator++() 21 | { 22 | sal++; 23 | } 24 | 25 | void Display() 26 | { 27 | cout << "Salary is " << sal << endl; 28 | } 29 | 30 | int operator--() 31 | { 32 | --sal; 33 | } 34 | int operator--(int) 35 | { 36 | --sal; 37 | } 38 | }; 39 | 40 | int main() 41 | { 42 | Salary s(1000); 43 | s.Display(); 44 | 45 | ++s; 46 | s.Display(); 47 | 48 | s++; 49 | s.Display(); 50 | 51 | --s; 52 | s.Display(); 53 | 54 | s--; 55 | s.Display(); 56 | 57 | return 0; 58 | } 59 | -------------------------------------------------------------------------------- /CPP/54_unaryOprator.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | 6 | class Point 7 | { 8 | int x; 9 | int y; 10 | 11 | public: 12 | Point(int x = 0, int y = 0) : x(x), y(x) {} 13 | 14 | void print() 15 | { 16 | cout << "x: " << x << " y: " << y << endl; 17 | } 18 | 19 | Point operator-() 20 | { 21 | return Point(-x, -y); 22 | } 23 | }; 24 | 25 | int main() 26 | { 27 | Point p1(1, 2), p2; 28 | p1.print(); 29 | p2.print(); 30 | Point p3 = -p1; 31 | p3.print(); 32 | return 0; 33 | } 34 | -------------------------------------------------------------------------------- /CPP/55_binaryOperator.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | 6 | class Complex 7 | { 8 | private: 9 | int x, y; 10 | 11 | public: 12 | Complex(int x = 0, int y = 0) : x(x), y(y) {} 13 | Complex operator+(const Complex &rhs) 14 | { 15 | Complex c3; 16 | c3.x = rhs.x + x; 17 | c3.y = rhs.y + y; 18 | return c3; 19 | } 20 | 21 | Complex operator-(const Complex &rhs) 22 | { 23 | Complex c4; 24 | c4.x = x - rhs.x; 25 | c4.y = y - rhs.y; 26 | return c4; 27 | } 28 | void display() 29 | { 30 | cout << "The number is " << x << " + " << y << "i" << endl; 31 | } 32 | }; 33 | 34 | int main() 35 | { 36 | Complex c1(2, 3), c2(4, 6); 37 | c1.display(); 38 | c2.display(); 39 | Complex c3 = c1 + c2; 40 | c3.display(); 41 | 42 | Complex c4 = c1 - c2; 43 | c4.display(); 44 | return 0; 45 | } -------------------------------------------------------------------------------- /CPP/56_unaryOperator.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | 6 | class Simple 7 | { 8 | private: 9 | int a; 10 | 11 | public: 12 | Simple(int a = 0) : a(a) {} 13 | void display(void) 14 | { 15 | cout << "a: " << a << endl; 16 | } 17 | 18 | int operator-() 19 | { 20 | int *p = &a; 21 | a = -(*p); 22 | return (a); 23 | } 24 | }; 25 | 26 | int main() 27 | { 28 | Simple s(8); 29 | s.display(); 30 | 31 | -s; 32 | s.display(); 33 | 34 | // Simple s2 = -s; 35 | // s2.display(); 36 | return 0; 37 | } -------------------------------------------------------------------------------- /CPP/57_arrSubOp.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Overloading [] operator in c++ (Array Subscript Operator) 3 | 4 | Points: 5 | 1. Array subscript Operator can not be used to chk out of bound classes. 6 | 2. Array Subscript operator can not be friend fuction and others too ( -> , () , = ) 7 | */ 8 | 9 | #include 10 | #include 11 | 12 | using namespace std; 13 | 14 | class Point 15 | { 16 | int arr[2]; // x -> 0 , y -> 1 17 | public: 18 | Point(int x = 0, int y = 0) 19 | { 20 | arr[0] = x; 21 | arr[1] = y; 22 | } 23 | void Print() 24 | { 25 | cout << "x: " << arr[0] << " y: " << arr[1] << endl; 26 | } 27 | 28 | int &operator[](int pos) 29 | { 30 | if (pos == 0) 31 | { 32 | return arr[0]; 33 | } 34 | else if (pos == 1) 35 | { 36 | return arr[1]; 37 | } 38 | else 39 | { 40 | cout << "Out of bound case. " << endl; 41 | exit(0); 42 | } 43 | 44 | { 45 | /* code */ 46 | } 47 | } 48 | }; 49 | 50 | int main() 51 | { 52 | Point p1(2, 3); 53 | p1.Print(); 54 | p1[0] = 11; 55 | p1[1] = 12; 56 | p1.Print(); 57 | p1[0] = 20; 58 | p1.Print(); 59 | return 0; 60 | } -------------------------------------------------------------------------------- /CPP/58_SteamInsertionOpOverloading.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | /* 5 | 6 | Topic : << & >> Operator Overloading in c++ 7 | 8 | << extraction operator 9 | >> stream insertion operator 10 | 11 | Points 12 | 13 | 1. When we need overload << & >> ? 14 | cout << (user defined type) OR cin >> (user defined type). 15 | 2. It can't be class member function (reason we will discuss), You have to make it friend function of your class. 16 | 17 | */ 18 | using namespace std; 19 | 20 | class Test 21 | { 22 | string x; 23 | 24 | public: 25 | Test(string x = "0") : x(x) {} 26 | friend istream &operator>>(istream &input, Test &obj); 27 | friend ostream &operator<<(ostream &output, Test &obj); 28 | }; 29 | 30 | istream &operator>>(istream &input, Test &obj) 31 | { 32 | input >> obj.x; 33 | return input; 34 | } 35 | 36 | ostream &operator<<(ostream &output, Test &obj) 37 | { 38 | output << obj.x << endl; 39 | return output; 40 | } 41 | int main() 42 | { 43 | Test t; 44 | cin >> t; 45 | cout << t; 46 | return 0; 47 | } 48 | -------------------------------------------------------------------------------- /CPP/59_AssignmentOperatorOverloading.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | 6 | class Test 7 | { 8 | private: 9 | int *x; 10 | 11 | public: 12 | Test(int val = 0) : x(new int(val)) {} 13 | ~Test(); 14 | void setX(int val) { *x = val; } 15 | void print() 16 | { 17 | cout << "output: " << *x << endl; 18 | } 19 | Test &operator=(const Test &rhs) 20 | { 21 | if (this != &rhs) 22 | *x = *rhs.x; 23 | return *this; 24 | } 25 | }; 26 | 27 | Test::~Test() 28 | { 29 | } 30 | 31 | int main() 32 | { 33 | Test t1(10); 34 | Test t2; 35 | t2 = t1; 36 | t1.setX(20); 37 | t1.print(); 38 | t2.print(); 39 | 40 | return 0; 41 | } 42 | -------------------------------------------------------------------------------- /CPP/60_PointerDerived.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | 6 | class Base 7 | { 8 | public: 9 | int base_var; 10 | Base() 11 | { 12 | base_var = 0; 13 | } 14 | void display() 15 | { 16 | cout << "The value of base_var is " << base_var << endl; 17 | } 18 | }; 19 | class Derived : public Base 20 | { 21 | public: 22 | int Derived_var; 23 | Derived() 24 | { 25 | Derived_var = 0; 26 | } 27 | void display() 28 | { 29 | cout << "The value of base_var is " << base_var << endl; 30 | cout << "The value of derived_var is " << Derived_var << endl; 31 | } 32 | }; 33 | int main() 34 | { 35 | Base *basePointer, B_obj; 36 | Derived derivedObj; 37 | basePointer = &derivedObj; 38 | basePointer->display(); 39 | basePointer->base_var = 90; 40 | basePointer->display(); 41 | basePointer->base_var = 12345678; 42 | basePointer->display(); 43 | 44 | cout << "---------------------------------------------------------------------" << endl; 45 | 46 | Derived *derivedPointer; 47 | derivedPointer = &derivedObj; 48 | derivedPointer->display(); 49 | derivedPointer->base_var = 1111; 50 | derivedPointer->Derived_var = 22222; 51 | derivedPointer->display(); 52 | 53 | cout << "---------------------------------------------------------------------" << endl; 54 | 55 | // derivedPointer = &B_obj; 56 | return 0; 57 | } 58 | -------------------------------------------------------------------------------- /CPP/61_virtualFunc.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | 6 | class Base 7 | { 8 | public: 9 | int _base = 2; 10 | virtual void display() 11 | { 12 | cout << "The value of _base is " << _base << endl; 13 | } 14 | }; 15 | 16 | class Derived : public Base 17 | { 18 | public: 19 | int _derived = 2; 20 | void display() 21 | { 22 | cout << "The value of _base is " << _base << endl; 23 | cout << "The value of _derived is " << _derived << endl; 24 | } 25 | }; 26 | 27 | int main() 28 | { 29 | Base *p_b, b; 30 | Derived d; 31 | 32 | p_b = &d; 33 | p_b->display(); 34 | 35 | return 0; 36 | } -------------------------------------------------------------------------------- /CPP/62_cwhVirtualFuction.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | using namespace std; 6 | 7 | class CWH 8 | { 9 | protected: 10 | char title[30]; 11 | float rating; 12 | 13 | public: 14 | CWH(char *s, float r) 15 | { 16 | strcpy(title, s); 17 | rating = r; 18 | } 19 | virtual void display() {} 20 | }; 21 | 22 | class CWHvideos : public CWH 23 | { 24 | }; 25 | 26 | class CHWtext : public CWH 27 | { 28 | }; 29 | 30 | int main() 31 | { 32 | 33 | return 0; 34 | } -------------------------------------------------------------------------------- /CPP/63_abstractClass.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | 6 | int main() 7 | { 8 | 9 | return 0; 10 | } -------------------------------------------------------------------------------- /CPP/64_fileHandling.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | using namespace std; 7 | 8 | int main() 9 | { 10 | string s1 = "KunalDhongade"; 11 | string s2; 12 | ifstream out("64_sample.txt"); 13 | out >> s2; 14 | cout << s2; 15 | return 0; 16 | } 17 | -------------------------------------------------------------------------------- /CPP/64_fileHandling.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/regression1607/HacktoberFest2022/6f7a1b6a6f08a6505f75ae0dad0efd39f7e32cbf/CPP/64_fileHandling.exe -------------------------------------------------------------------------------- /CPP/64_sample.txt: -------------------------------------------------------------------------------- 1 | xyz abc aaa bbb zzz -------------------------------------------------------------------------------- /CPP/65_errorHandling.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | 6 | int main() 7 | { 8 | int a = 0; 9 | try 10 | { 11 | if (a == 0) 12 | { 13 | throw 1; 14 | } 15 | } 16 | catch (int e) 17 | { 18 | cout << "value is 0"; 19 | } 20 | 21 | return 0; 22 | } 23 | -------------------------------------------------------------------------------- /CPP/rectanglearea.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | class Rectangle 6 | { 7 | public: 8 | int width, height; 9 | void display() 10 | { 11 | cout << width << " " << height << "\n"; 12 | } 13 | }; 14 | class RectangleArea : public Rectangle 15 | { 16 | public: 17 | void read_input() 18 | { 19 | cin >> width; 20 | cin >> height; 21 | } 22 | void display() 23 | { 24 | cout << width * height << "\n"; 25 | } 26 | }; 27 | 28 | 29 | int main() 30 | { 31 | /* 32 | * Declare a RectangleArea object 33 | */ 34 | RectangleArea r_area; 35 | 36 | /* 37 | * Read the width and height 38 | */ 39 | r_area.read_input(); 40 | 41 | /* 42 | * Print the width and height 43 | */ 44 | r_area.Rectangle::display(); 45 | 46 | /* 47 | * Print the area 48 | */ 49 | r_area.display(); 50 | 51 | return 0; 52 | } -------------------------------------------------------------------------------- /CaseCheck.java: -------------------------------------------------------------------------------- 1 | import java.util.*; 2 | 3 | public class CaseCheck 4 | { 5 | public static void main(String[] args) 6 | { 7 | Scanner sc = new Scanner(System.in); 8 | char ch = sc.next().charAt(0); 9 | 10 | if(Character.isUpperCase(ch)) 11 | System.out.println("Uppercase"); 12 | else 13 | System.out.println("Lowercase"); 14 | sc.close(); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Clockwise_Rotate.java: -------------------------------------------------------------------------------- 1 | import java.util.*; 2 | class Clockwise_Rotate 3 | { 4 | public static void main() 5 | { 6 | Scanner sc=new Scanner(System.in); 7 | System.out.println("Enter the number of Rows"); 8 | int r=sc.nextInt(); 9 | System.out.println("Enter the number of Columns"); 10 | int c=sc.nextInt(); 11 | int arr[][]=new int[r][c]; 12 | System.out.println("Enter the elements of Matrix"); 13 | for(int i=0;i=0;i--) 33 | { 34 | System.out.print(arr[i][j]+"\t"); 35 | } 36 | System.out.println(" "); 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /CountNums.java: -------------------------------------------------------------------------------- 1 | public class CountNums { 2 | public static void main(String[] args) { 3 | int n = 45535; 4 | 5 | int count = 0; 6 | while (n > 0) { 7 | int rem = n % 10; 8 | if (rem == 5) { 9 | count++; 10 | } 11 | n = n / 10; // n /= 10 12 | } 13 | 14 | System.out.println(count); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /DISHA: -------------------------------------------------------------------------------- 1 | Hacktoberfest Contributor Guide 🎃 2 | Hacktoberfest 2022 is finally here, and we're pretty excited about it. 3 | Open source developers also play a crucial role in making our API's accessible and compatible with different ecosystems. 4 | We think it's a great time to encourage, recognise and reward developers in the community who dedicate their time to creating for others. 5 | 6 | What is Hacktoberfest? 7 | Hacktoberfest is an annual festival hosted by DigitalOcean that takes place in the month of October to celebrate the open source community. 8 | As part of this 31-day celebration, contributors and open source maintainers are encouraged to work on open source projects and win swag to mark the occasion. 9 | Tips for contributors 10 | PRs beyond our open issues are welcome but make sure your contributions are meaningful and beneficial to other users . 11 | otherwise your PR may be closed and marked as ‘invalid’. 12 | Issues before PRs. 13 | If you plan to make a contribution, please make sure there is an issue for it. 14 | You can either find an existing issue or open a new issue if none exists. 15 | 16 | PRs fulfill all the required conditions will be labeled as "hacktoberfest-accepted" before merging. 17 | -------------------------------------------------------------------------------- /Demands 5G and Wi-Fi.md: -------------------------------------------------------------------------------- 1 | The Next Wave of Productivity Demands 5G and Wi-Fi 2 | Shaun McCarthy 3 | 4 | The pandemic accelerated digital transformations for enterprises across the globe. With the flip of a switch, IT workers transitioned to a remote work environment. We took meetings from our kitchens, we learned that it’s not the end of the world when a child or pet crashes a meeting, and some of us rekindled our relationship with sweatpants. It wasn’t without its challenges, but it was still a relatively smooth transition for IT workers. This wasn’t necessarily the case for OT workers, and the pandemic didn’t lead to a rethinking of work for workers in manufacturing, transportation, logistics, and utilities. 5 | 6 | The Future of Work is Hybrid 7 | At Cisco, we believe the future of work is both hybrid and inclusive. Hybrid work is much more than taking video meetings from your kitchen. Hybrid work is a rethinking of networks, policy, security, and of course, collaboration. We are reimagining work not just for IT workers though, but also for OT workers. The power of Wi-Fi 6 and Private 5G are going to bring together people, spaces, and things to reimagine how we work. 8 | 9 | As enterprises and service providers are rethinking network architectures to support hybrid work, they are increasing their reliance on the cloud for greater flexibility, connecting their physical operations with IT and OT systems, and using analytics, AI, ML, and automation to keep employees safe, minimize their carbon footprint, and improve productivity and efficiency while reducing operational costs. And they need to do this all while connecting everyone seamlessly and securely from where they need to be, aiming to deliver a great hybrid work experience for everyone. Talk about challenging! Cisco is proud to continue to innovate in helping enterprises and service providers achieve all of this. 10 | 11 | Helping our Partners Meet Enterprises Where They Are 12 | Cisco Private 5G as a Service provides our partners with more flexibility for expanded future growth and the ability to provide new services. Cisco knows how to build solutions that avoid both complexity and lock-in, enabling partners to empower customers to extend what they already own. Our private 5G solution is ‘Simple to Start’, ‘Intuitive to Operate’, and ‘Trusted’ for enterprise digital transformation. 13 | 14 | Cisco Private 5G is built on our industry-leading mobile core technology and IoT portfolio with Open Radio Access Network (ORAN) technology. Complementary to Wi-Fi (including existing and future versions – Wi-Fi 5/6/6E), Cisco Private 5G integrates with existing enterprise systems, making operations simple and familiar. Our solution is delivered as-a-service in a pay-as-you-go model in cooperation with global service providers and system integration partners, providing an easy way to reduce technical, financial, and operational risks. 15 | 16 | Cisco allows partners like DISH Networks, NTT, Logicalis, and Colt Technology Services to quickly and cost-effectively deliver experiences that enterprises demand, bundling Cisco Private 5G with their own value-added solutions. Read all the partner and customer quotes in the press release. 17 | 18 | Together, Wi-Fi, private 5G and IoT can transform industries and redefine the future of hybrid work. Private 5G enables connectivity for a full range of technologies and use cases, from factory floors to supply chains, remote sensors, and customer engagements. We look forward to continuing to share our vision as well as plenty of use cases and success stories that will inspire you. 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /Dutch_National_flag_algorithm.java: -------------------------------------------------------------------------------- 1 | public class Solution { 2 | public static void main(String[] args){ 3 | int[] nums = {0,2,1,2,0,1,1,2}; 4 | sortColors(nums); 5 | } 6 | public void sortColors(int[] nums) { 7 | int lo = 0; 8 | int hi = nums.length - 1; 9 | int mid = 0; 10 | int temp; 11 | while (mid <= hi) { 12 | switch (nums[mid]) { 13 | case 0: { 14 | temp = nums[lo]; 15 | nums[lo] = nums[mid]; 16 | nums[mid] = temp; 17 | lo++; 18 | mid++; 19 | break; 20 | } 21 | case 1: 22 | mid++; 23 | break; 24 | case 2: { 25 | temp = nums[mid]; 26 | nums[mid] = nums[hi]; 27 | nums[hi] = temp; 28 | hi--; 29 | break; 30 | } 31 | } 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /Employee_SalarySlip.py: -------------------------------------------------------------------------------- 1 | class Employee: 2 | def __init__(self, id, name, sal): 3 | self.id = id 4 | self.name = name 5 | try: 6 | sal = int(sal) 7 | if(sal < 2000): 8 | self.sal = 2000 9 | else: 10 | self.sal = sal 11 | except Exception as e: 12 | print(e) 13 | print("Salary is set to 2000.") 14 | self.sal = 2000 15 | 16 | def SalarySlip(self): 17 | print("\nEmployee_ID: ", self.id) 18 | print("Name: ", self.name) 19 | print("Employee_Basic: ", self.sal) 20 | Employee_HRA = self.sal*0.18 21 | print("Employee_HRA: ", Employee_HRA) 22 | Employee_DA = self.sal*0.1 23 | print("Employee_DA: ", Employee_DA) 24 | Employee_GrossSAL = self.sal+Employee_HRA+Employee_DA 25 | Employee_TAX = 0.1*Employee_GrossSAL 26 | print("Employee_TAX: ", Employee_TAX) 27 | print("Employee_GrossSAL: ", Employee_GrossSAL) 28 | Employee_NET_SAL = Employee_GrossSAL-Employee_TAX 29 | print("Employee_NET SAL: ", Employee_NET_SAL) 30 | if(Employee_GrossSAL >= 2560 and Employee_GrossSAL < 5000): 31 | print("Classification: Group-A") 32 | elif(Employee_GrossSAL >= 5000 and Employee_GrossSAL < 10000): 33 | print("Classification: Group-B") 34 | elif(Employee_GrossSAL >= 10000): 35 | print("Classification: Group-C") 36 | print() 37 | 38 | 39 | while(1): 40 | try: 41 | n = int(input("Enter the Number of Employees: ")) 42 | break 43 | except Exception as e: 44 | print(e) 45 | 46 | l = [] 47 | ids = [] 48 | 49 | for i in range(n): 50 | id = input("Enter the id: ") 51 | if(id in ids or len(id) == 0): 52 | while(id in ids or len(id) == 0): 53 | id = input("Id Already taken or invalid input,Enter Again: ") 54 | ids.append(id) 55 | name = input("Enter the Name: ") 56 | if(len(name) == 0): 57 | while(len(name) == 0): 58 | name = input("Id Already taken or invalid input,Enter Again: ") 59 | sal = input("Enter the Salary: ") 60 | print() 61 | object = Employee(id, name, sal) 62 | l.append(object) 63 | while(1): 64 | id = input("Enter the id of employee to get SalarySlip or 'e' for exit: ") 65 | if(id == 'e'): 66 | exit() 67 | else: 68 | for i in range(n): 69 | if(l[i].id == id): 70 | l[i].SalarySlip() 71 | break 72 | else: 73 | print("Employee Not Found.\n") 74 | -------------------------------------------------------------------------------- /FactorialofaNumber.python: -------------------------------------------------------------------------------- 1 | # Python program to find the factorial of a number provided by the user. 2 | 3 | # change the value for a different result 4 | num = 7 5 | 6 | # To take input from the user 7 | #num = int(input("Enter a number: ")) 8 | 9 | factorial = 1 10 | 11 | # check if the number is negative, positive or zero 12 | if num < 0: 13 | print("Sorry, factorial does not exist for negative numbers") 14 | elif num == 0: 15 | print("The factorial of 0 is 1") 16 | else: 17 | for i in range(1,num + 1): 18 | factorial = factorial*i 19 | print("The factorial of",num,"is",factorial) 20 | -------------------------------------------------------------------------------- /Gingerit python tutorial.md: -------------------------------------------------------------------------------- 1 | Grammer is needed everywhere From writing a letter, email, essay or article. Good Grammer with a correct word spoken help you to communicate clearly and help you to put a good impression on others. So as a programmer we always want to do things with code. So in this post i will give you a brief introduction with example gingerit python module which help you correct spelling with python. 2 | 3 | # Contents 4 | * Gingerit python module 5 | * Installation of gingerit python module? 6 | * How to use gingerit python? 7 | * Conclusion 8 | 9 | ## Gingerit python module? 10 | So what is gingerit python module? gingerit is a python package that helps you in the grammatical correction of a word according to the context of a sentence. gingerit uses gingersoftware API. gingerapi helps you to check the grammatical mistake in terms, text, and documents and corrects them. 11 | 12 | By using gingerit package you can fix grammatical mistakes and misspelled words and function. so lets move to the next part where we will install ginger python on our computer with the help of python pip. 13 | 14 | ## Installation of gingerit python module? 15 | 16 | >pip install requests 17 | >pip install cloudscraper 18 | >pip install gingerit 19 | 20 | ## How to use gingerit python? 21 | Here is an example code where we will gonna use gingerit package to build a simple grammar checker program. where I will pass a sentence with misspelled words and incorrect grammar. 22 | 23 | `` from gingerit import GingerIt `` 24 | `` text = input("Enter a sentence >>: ") `` 25 | `` corrected_text = GingerIt().parse(text) `` 26 | `` print(corrected_text['result']) `` 27 | 28 | ### OUTPUT 29 | input sentance : my nme are khan. how are your doy? 30 | output correct sentance : My name is Khan. How is your day? 31 | 32 | So as you can see I have shared an example code above where I have done grammatical and spelling mistakes. 33 | 34 | ## Conclusion 35 | 36 | Gengerit package has been not updated for a while by the person who has created it due to which if you install gengerit from pip it will show error and HTML code due to Cloudflare protection on API. so i have fixed that issue and shared that with the new genreit.py file so download it from above link. Make sure you put the gengerit.py file in the same path or folder where you test your code. 37 | -------------------------------------------------------------------------------- /Github repo.md: -------------------------------------------------------------------------------- 1 | ### * Most Star repo on Github "awesome-python" 2 | [URL](https://github.com/vinta/awesome-python) 3 | 4 | ### * Second Most Star repo on Github "request" 5 | [URL](https://github.com/psf/requests) 6 | 7 | ### * Best Match repo in Github "python" 8 | [URL](https://github.com/kubernetes-client/python) 9 | [Website](kubernetes.io/) 10 | 11 | ### * Google Auth Python Library 12 | [URL](https://github.com/googleapis/google-auth-library-python) 13 | [Website](https://googleapis.dev/python/google-auth/latest/) 14 | 15 | ### * Kubernetes Library 16 | [URL](https://github.com/kubernetes-client/python) 17 | 18 | ### * Python Interview Question 19 | [URL](https://github.com/learning-zone/python-interview-questions) 20 | 21 | ### * Python Main Website 22 | [URL](https://github.com/learning-zone/python-interview-questions) 23 | 24 | ### * Python Download 25 | [URL](https://www.python.org/downloads/) 26 | 27 | ### * Some Tutorial on YT 28 | [By Telusko in English](https://www.youtube.com/playlist?list=PLsyeobzWxl7poL9JTVyndKe62ieoN-MZ3) 29 | [By CodeWithHarry in Hindi](https://www.youtube.com/playlist?list=PLu0W_9lII9agICnT8t4iYVSZ3eykIAOME) 30 | [By Harshit vashisth](https://www.youtube.com/playlist?list=PLwgFb6VsUj_lQTpQKDtLXKXElQychT_2j) 31 | 32 | 33 | -------------------------------------------------------------------------------- /GnomeSort.cpp: -------------------------------------------------------------------------------- 1 | static void GnomeSort(int* data, int count) { 2 | for (int i = 1; i < count; ) { 3 | if (data[i - 1] <= data[i]) 4 | ++i; 5 | else { 6 | int tmp = data[i]; 7 | data[i] = data[i - 1]; 8 | data[i - 1] = tmp; 9 | --i; 10 | if (i == 0) 11 | i = 1; 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Greeting.java: -------------------------------------------------------------------------------- 1 | public class Greeting { 2 | public static void main(String[] args) { 3 | greeting(); 4 | } 5 | static void greeting() { 6 | System.out.println("Hello There! "); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /Hello.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/regression1607/HacktoberFest2022/6f7a1b6a6f08a6505f75ae0dad0efd39f7e32cbf/Hello.class -------------------------------------------------------------------------------- /Hello.java: -------------------------------------------------------------------------------- 1 | public class Hello { 2 | public static void main(String[] args) { 3 | hello(); 4 | } 5 | 6 | static void hello() { 7 | System.out.println("Hello World!!! "); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /HelloWorld.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | printf("Hello World"); 6 | 7 | return 0; 8 | } 9 | -------------------------------------------------------------------------------- /HelloWorld.java: -------------------------------------------------------------------------------- 1 | public class HelloWorld 2 | { 3 | public static void main(String[] args) { 4 | System.out.println("Hello World!"); 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /Hospital management/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | char ans=0; 9 | int ok; 10 | int b, valid=0; 11 | 12 | // function declaration 13 | 14 | // Welcome function Declaration 15 | void WelcomeScreen(void); 16 | // Title function declaration 17 | void Title(void); 18 | // Main menu declaration 19 | void MainMenu(void); 20 | // Login screen declaration 21 | void LoginScreen(void); 22 | // Add record function declaration 23 | void Add_rec(void); 24 | // Function list declaration 25 | void func_list(void); 26 | // Search record declaration 27 | void Search_rec(void); 28 | // Edit records declaration 29 | void Edit_rec(void); 30 | // Delete record declaration 31 | void Delete_rec(void); 32 | // Exit record declaration 33 | void Exit_rec(void); 34 | void gotoxy(short x, short y) 35 | 36 | { 37 | COORD pos = {x,y}; 38 | SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),pos); 39 | } 40 | 41 | // List of global variables 42 | struct patient 43 | { 44 | int age; 45 | char Gender; 46 | char First_Name[50]; 47 | char Last_Name[50]; 48 | char Contact_No[50]; 49 | char Address[50]; 50 | char Email[50]; 51 | char Doctor[50]; 52 | char Problem[50]; 53 | }; 54 | struct patient p,temp_c; 55 | void main(void) 56 | { 57 | WelcomeScreen(); 58 | Title(); 59 | LoginScreen(); 60 | } 61 | 62 | /***************************Welcome Screen****************************/ 63 | void WelcomeScreen(void) 64 | //Function for wecome screen 65 | { 66 | printf("\n\n\n\n\n\n\n\n\t\t\t\t\t\t\t###################################"); 67 | printf("\n\t\t\t#\t\tWelcome To\t\t#"); 68 | printf("\n\t\t\t\t\n Alexis Hospital Management System #"); 69 | printf("\n#################################################################"); 70 | printf("\n\n\nPress any key to continue .................\n"); 71 | getch(); 72 | system("cls"); 73 | //use to clear screen 74 | } 75 | /**************************Title Screen****************************/ 76 | void Title(void) 77 | { 78 | printf("\n\n\t\t-------------------------------------------------------"); 79 | printf("\n\t\t\t Alexis Hospital "); 80 | printf("\n\n\t\t-----------------------------------------------"); 81 | } 82 | 83 | 84 | 85 | -------------------------------------------------------------------------------- /Hospital management/readme.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/regression1607/HacktoberFest2022/6f7a1b6a6f08a6505f75ae0dad0efd39f7e32cbf/Hospital management/readme.md -------------------------------------------------------------------------------- /Import turtle: -------------------------------------------------------------------------------- 1 | Plotting using Turtle 2 | 3 | To make use of the turtle methods and functionalities, we need to import turtle.”turtle” comes packed with the standard Python package and need not be installed externally. The roadmap for executing a turtle program follows 4 steps: 4 | 5 | Import the turtle module 6 | Create a turtle to control. 7 | Draw around using the turtle methods. 8 | Run turtle.done(). 9 | So as stated above, before we can use turtle, we need to import it. We import it as : 10 | from turtle import * 11 | 12 | # or 13 | 14 | import turtle 15 | 16 | After importing the turtle library and making all the turtle functionalities available to us, we need to create a new drawing board(window) and a turtle. Let’s call the window as wn and the turtle as skk. So we code as: 17 | 18 | wn = turtle.Screen() 19 | 20 | wn.bgcolor("light green") 21 | 22 | wn.title("Turtle") 23 | 24 | skk = turtle.Turtle() 25 | 26 | Now that we have created the window and the turtle, we need to move the turtle. To move forward 100 pixels in the direction skk is facing, we code: 27 | 28 | skk.forward(100) 29 | 30 | We have moved skk 100 pixels forward, Awesome! Now we complete the program with the done() function and We’re done! 31 | 32 | turtle.done() 33 | 34 | So, we have created a program that draws a line 100 pixels long. We can draw various shapes and fill different colors using turtle methods. There’s plethora of functions and programs to be coded using the turtle library in python. Let’s learn to draw some of the basic shapes. 35 | 36 | 37 | 38 | Shape 1: Square 39 | # Python program to draw square 40 | 41 | # using Turtle Programming 42 | 43 | import turtle 44 | 45 | skk = turtle.Turtle() 46 | 47 | 48 | 49 | for i in range(4): 50 | 51 | skk.forward(50) 52 | 53 | skk.right(90) 54 | 55 | 56 | 57 | turtle.done() 58 | 59 | Shape 2: Star 60 | 61 | # Python program to draw star 62 | # using Turtle Programming 63 | 64 | import turtle 65 | 66 | star = turtle.Turtle() 67 | 68 | 69 | star.right(75) 70 | 71 | star.forward(100) 72 | 73 | 74 | for i in range(4): 75 | 76 | star.right(144) 77 | 78 | star.forward(100) 79 | 80 | 81 | turtle.done() 82 | 83 | 84 | -------------------------------------------------------------------------------- /LCM.py: -------------------------------------------------------------------------------- 1 | # Python Program to find the L.C.M. of two input number 2 | 3 | def compute_lcm(x, y): 4 | 5 | # choose the greater number 6 | if x > y: 7 | greater = x 8 | else: 9 | greater = y 10 | 11 | while(True): 12 | if((greater % x == 0) and (greater % y == 0)): 13 | lcm = greater 14 | break 15 | greater += 1 16 | 17 | return lcm 18 | 19 | num1 = 54 20 | num2 = 24 21 | 22 | print("The L.C.M. is", compute_lcm(num1, num2)) 23 | -------------------------------------------------------------------------------- /Largest.java: -------------------------------------------------------------------------------- 1 | import java.util.Scanner; 2 | 3 | public class Largest { 4 | public static void main(String[] args) { 5 | Scanner in = new Scanner(System.in); 6 | 7 | int a = in.nextInt(); 8 | int b = in.nextInt(); 9 | int c = in.nextInt(); 10 | 11 | int max = Math.max(c, Math.max(a, b)); 12 | 13 | System.out.println(max); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /LeapYear.python: -------------------------------------------------------------------------------- 1 | # Python program to check if year is a leap year or not 2 | 3 | year = 2000 4 | 5 | # To get year (integer input) from the user 6 | # year = int(input("Enter a year: ")) 7 | 8 | # divided by 100 means century year (ending with 00) 9 | # century year divided by 400 is leap year 10 | if (year % 400 == 0) and (year % 100 == 0): 11 | print("{0} is a leap year".format(year)) 12 | 13 | # not divided by 100 means not a century year 14 | # year divided by 4 is a leap year 15 | elif (year % 4 ==0) and (year % 100 != 0): 16 | print("{0} is a leap year".format(year)) 17 | 18 | # if not divided by both 400 (century year) and 4 (not century year) 19 | # year is not leap year 20 | else: 21 | print("{0} is not a leap year".format(year)) 22 | -------------------------------------------------------------------------------- /Login Form/Users.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/regression1607/HacktoberFest2022/6f7a1b6a6f08a6505f75ae0dad0efd39f7e32cbf/Login Form/Users.dat -------------------------------------------------------------------------------- /Login Form/login.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #define ENTER 13 5 | #define TAB 9 6 | #define BCKSPC 8 7 | 8 | struct user{ 9 | char fullName[50]; 10 | char email[50]; 11 | char password[50]; 12 | char username[50]; 13 | char phone[50]; 14 | }; 15 | 16 | void takeinput(char ch[50]){ 17 | fgets(ch,50,stdin); 18 | ch[strlen(ch) - 1] = 0; 19 | } 20 | 21 | char generateUsername(char email[50],char username[50]){ 22 | //abc123@gmail.com 23 | for(int i=0;i0){ 39 | i--; 40 | printf("\b \b"); 41 | } 42 | }else{ 43 | pwd[i++] = ch; 44 | printf("* \b"); 45 | } 46 | } 47 | } 48 | 49 | 50 | int main(){ 51 | system("color 0b"); 52 | FILE *fp; 53 | int opt,usrFound = 0; 54 | struct user user; 55 | char password2[50]; 56 | 57 | printf("\n\t\t\t\t----------Welcome to authentication system----------"); 58 | printf("\nPlease choose your operation"); 59 | printf("\n1.Signup"); 60 | printf("\n2.Login"); 61 | printf("\n3.Exit"); 62 | 63 | printf("\n\nYour choice:\t"); 64 | scanf("%d",&opt); 65 | fgetc(stdin); 66 | 67 | switch(opt){ 68 | case 1: 69 | system("cls"); 70 | printf("\nEnter your full name:\t"); 71 | takeinput(user.fullName); 72 | printf("Enter your email:\t"); 73 | takeinput(user.email); 74 | printf("Enter your contact no:\t"); 75 | takeinput(user.phone); 76 | printf("Enter your password:\t"); 77 | takepassword(user.password); 78 | printf("\nConfirm your password:\t"); 79 | takepassword(password2); 80 | 81 | if(!strcmp(user.password,password2)){ 82 | generateUsername(user.email,user.username); 83 | fp = fopen("Users.dat","a+"); 84 | fwrite(&user,sizeof(struct user),1,fp); 85 | if(fwrite != 0) printf("\n\nUser resgistration success, Your username is %s",user.username); 86 | else printf("\n\nSorry! Something went wrong :("); 87 | fclose(fp); 88 | } 89 | else{ 90 | printf("\n\nPassword donot matched"); 91 | Beep(750,300); 92 | } 93 | break; 94 | 95 | case 2: 96 | 97 | char username[50],pword[50]; 98 | struct user usr; 99 | 100 | printf("\nEnter your username:\t"); 101 | takeinput(username); 102 | printf("Enter your password:\t"); 103 | takepassword(pword); 104 | 105 | fp = fopen("Users.dat","r"); 106 | while(fread(&usr,sizeof(struct user),1,fp)){ 107 | if(!strcmp(usr.username,username)){ 108 | if(!strcmp(usr.password,pword)){ 109 | system("cls"); 110 | printf("\n\t\t\t\t\t\tWelcome %s",usr.fullName); 111 | printf("\n\n|Full Name:\t%s",usr.fullName); 112 | printf("\n|Email:\t\t%s",usr.email); 113 | printf("\n|Username:\t%s",usr.username); 114 | printf("\n|Contact no.:\t%s",usr.phone); 115 | } 116 | else { 117 | printf("\n\nInvalid Password!"); 118 | Beep(800,300); 119 | } 120 | usrFound = 1; 121 | } 122 | } 123 | if(!usrFound){ 124 | printf("\n\nUser is not registered!"); 125 | Beep(800,300); 126 | } 127 | fclose(fp); 128 | break; 129 | 130 | case 3: 131 | printf("\t\t\tBye Bye :)"); 132 | return 0; 133 | 134 | } 135 | 136 | 137 | 138 | return 0; 139 | } 140 | -------------------------------------------------------------------------------- /Login Form/login.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/regression1607/HacktoberFest2022/6f7a1b6a6f08a6505f75ae0dad0efd39f7e32cbf/Login Form/login.exe -------------------------------------------------------------------------------- /Login Form/readme.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/regression1607/HacktoberFest2022/6f7a1b6a6f08a6505f75ae0dad0efd39f7e32cbf/Login Form/readme.md -------------------------------------------------------------------------------- /Longest_palindromic_substring.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | class Solution { 4 | public: 5 | string longestPalindrome(string s) { 6 | int max = 1,max_i=0 ; 7 | for(int i=0;i=0 && r=0 && r Prepare > PythonSets > No Idea! 4 | # url : https://www.hackerrank.com/challenges/no-idea/problem?isFullScreen=true 5 | 6 | 7 | n, m = map(int,input("Enter the size of two sets : ").split()) 8 | arr = [int(i) for i in input("Enter the set you want to check : ").split()] 9 | A = set(int(i) for i in input("Enter the 1st set : ").split()) 10 | B = set(int(i) for i in input("Enter the 2nd set : ").split()) 11 | happiness = 0 12 | for i in arr: 13 | if i in A and i not in B: 14 | happiness += 1 15 | elif i not in A and i in B: 16 | happiness -= 1 17 | print("Your happiness is : ",happiness) 18 | -------------------------------------------------------------------------------- /Palindrome.java: -------------------------------------------------------------------------------- 1 | class Main { 2 | public static void main(String[] args) { 3 | 4 | String str = "Radar", reverseStr = ""; 5 | 6 | int strLength = str.length(); 7 | 8 | for (int i = (strLength - 1); i >=0; --i) { 9 | reverseStr = reverseStr + str.charAt(i); 10 | } 11 | 12 | if (str.toLowerCase().equals(reverseStr.toLowerCase())) { 13 | System.out.println(str + " is a Palindrome String."); 14 | } 15 | else { 16 | System.out.println(str + " is not a Palindrome String."); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Palindrome.python: -------------------------------------------------------------------------------- 1 | n=int(input("Enter number:")) 2 | temp=n 3 | rev=0 4 | while(n>0): 5 | dig=n%10 6 | rev=rev*10+dig 7 | n=n//10 8 | if(temp==rev): 9 | print("The number is a palindrome!") 10 | else: 11 | print("The number isn't a palindrome!") 12 | -------------------------------------------------------------------------------- /Password Generator.py: -------------------------------------------------------------------------------- 1 | /*Based on the length of the password given by user, computer generates a random password*/ 2 | 3 | 4 | 5 | import random 6 | import string 7 | 8 | #string is library in python like random whuch conatains all the string handling operations just like string.h in c/c++ 9 | 10 | if __name__=="__main__": 11 | #search on net how main works 12 | 13 | s1=string.ascii_lowercase 14 | #ascii_lowercase imports all the lower alphabet from string library 15 | 16 | s2=string.ascii_uppercase 17 | #imports all upper alphabet from string library 18 | 19 | s3=string.punctuation 20 | #A string contains letters, whitespace, numbers. And it has punctuation: these characters include commas and periods and semicolons. 21 | 22 | s4=string.digits 23 | #impports digits 24 | 25 | length=int(input("length of your password ")) 26 | s=[] 27 | #this is an empty list that adds whatver we want into it 28 | #now since s is a alist and we can change items in it but we can only add elements of type list to it and so we need to convert all our strings into lists 29 | 30 | s.extend(list(s1)) 31 | s.extend(list(s2)) 32 | s.extend(list(s3)) 33 | s.extend(list(s4)) 34 | #.extend is a function operating on lists that will add a list in the form of elements search on net how extend works 35 | 36 | random.shuffle(s) 37 | #shuffle is a function in random library that just shuffles a list in any order 38 | 39 | print("".join(s[0:length])) 40 | #slicing lists list_name[start:stop] 41 | -------------------------------------------------------------------------------- /QuickSort.java: -------------------------------------------------------------------------------- 1 | // Java implementation of QuickSort 2 | import java.io.*; 3 | 4 | class GFG { 5 | 6 | // A utility function to swap two elements 7 | static void swap(int[] arr, int i, int j) 8 | { 9 | int temp = arr[i]; 10 | arr[i] = arr[j]; 11 | arr[j] = temp; 12 | } 13 | 14 | /* This function takes last element as pivot, places 15 | the pivot element at its correct position in sorted 16 | array, and places all smaller (smaller than pivot) 17 | to left of pivot and all greater elements to right 18 | of pivot */ 19 | static int partition(int[] arr, int low, int high) 20 | { 21 | 22 | // pivot 23 | int pivot = arr[high]; 24 | 25 | // Index of smaller element and 26 | // indicates the right position 27 | // of pivot found so far 28 | int i = (low - 1); 29 | 30 | for (int j = low; j <= high - 1; j++) { 31 | 32 | // If current element is smaller 33 | // than the pivot 34 | if (arr[j] < pivot) { 35 | 36 | // Increment index of 37 | // smaller element 38 | i++; 39 | swap(arr, i, j); 40 | } 41 | } 42 | swap(arr, i + 1, high); 43 | return (i + 1); 44 | } 45 | 46 | /* The main function that implements QuickSort 47 | arr[] --> Array to be sorted, 48 | low --> Starting index, 49 | high --> Ending index 50 | */ 51 | static void quickSort(int[] arr, int low, int high) 52 | { 53 | if (low < high) { 54 | 55 | // pi is partitioning index, arr[p] 56 | // is now at right place 57 | int pi = partition(arr, low, high); 58 | 59 | // Separately sort elements before 60 | // partition and after partition 61 | quickSort(arr, low, pi - 1); 62 | quickSort(arr, pi + 1, high); 63 | } 64 | } 65 | 66 | // Function to print an array 67 | static void printArray(int[] arr, int size) 68 | { 69 | for (int i = 0; i < size; i++) 70 | System.out.print(arr[i] + " "); 71 | 72 | System.out.println(); 73 | } 74 | 75 | // Driver Code 76 | public static void main(String[] args) 77 | { 78 | int[] arr = { 10, 7, 8, 9, 1, 5 }; 79 | int n = arr.length; 80 | 81 | quickSort(arr, 0, n - 1); 82 | System.out.println("Sorted array: "); 83 | printArray(arr, n); 84 | } 85 | } 86 | 87 | // This code is contributed by Ayush Choudhary 88 | -------------------------------------------------------------------------------- /READ ME: -------------------------------------------------------------------------------- 1 | Hacktoberfest Contributor Guide 🎃 2 | Hacktoberfest 2022 is finally here, and we're pretty excited about it. 3 | Open source developers also play a crucial role in making our API's accessible and compatible with different ecosystems. 4 | We think it's a great time to encourage, recognise and reward developers in the community who dedicate their time to creating for others. 5 | 6 | What is Hacktoberfest? 7 | Hacktoberfest is an annual festival hosted by DigitalOcean that takes place in the month of October to celebrate the open source community. 8 | As part of this 31-day celebration, contributors and open source maintainers are encouraged to work on open source projects and win swag to mark the occasion. 9 | Tips for contributors 10 | PRs beyond our open issues are welcome but make sure your contributions are meaningful and beneficial to other users . 11 | otherwise your PR may be closed and marked as ‘invalid’. 12 | Issues before PRs. 13 | If you plan to make a contribution, please make sure there is an issue for it. 14 | You can either find an existing issue or open a new issue if none exists. 15 | 16 | PRs fulfill all the required conditions will be labeled as "hacktoberfest-accepted" before merging. 17 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # HacktoberFest2022 2 | # 🎃 HacktoberFest Starter Project 🎃 3 | 4 | Use this project to make your first contribution to an open source project on GitHub. Practice making your first pull request to a public repository before doing the real thing! 5 | 6 | Celebrate [Hacktoberfest](https://hacktoberfest.digitalocean.com/) by getting involved in the open source community by completing some simple tasks in this project. 7 | 8 | This repository is open to all members of the GitHub community. Any member may contribute to this project without being a collaborator. 9 | 10 | https://github.com/thecodingcenter/HacktoberFest.git 11 | 12 | ## What is Hacktoberfest? 13 | 14 | A month-long celebration from October 1st - 31st sponsored by [Digital Ocean](https://hacktoberfest.com/) and [GitHub](https://dev.to/this-is-learning/hacktoberfest-2022-is-almost-there-get-ready-4ifb) to get people involved in [Open Source](https://github.com/open-source). Create your very first pull request to any public repository on GitHub and contribute to the open source developer community. 15 | 16 | [https://hacktoberfest.com/](https://hacktoberfest.com/) 17 | 18 | ## How to contribute to this project 19 | 20 | Here are 3 quick and painless ways to contribute to this project: 21 | 22 | - Add your name to the `CONTRIBUTING.md` file 23 | - Add a profile page to the `profiles` directory 24 | - Create a simple "Hello, World" script in a language of your choice 25 | 26 | Choose one or all 3, make a pull request for your work and wait for it to be merged! 27 | 28 | ## Getting started 29 | 30 | - Fork this repository (Click the Fork button in the top right of this page, click your Profile Image) 31 | - Clone your fork down to your local machine 32 | 33 | markdown 34 | git clone https://github.com/thecodingcenter/HacktoberFest.git 35 | 36 | 37 | - Create a branch 38 | 39 | markdown 40 | git checkout -b branch-name 41 | 42 | 43 | - Make your changes (choose from any task below) 44 | - Commit and push 45 | 46 | markdown 47 | git add . 48 | git commit -m 'Commit message' 49 | git push origin branch-name 50 | 51 | 52 | - Create a new pull request from your forked repository (Click the `New Pull Request` button located at the top of your repo) 53 | - Wait for your PR review and merge approval! 54 | - *Star this repository* if you had fun! 55 | 56 | ## Choose from these tasks 57 | 58 | ### 1. Add your name 59 | 60 | Add your name to the `CONTRIBUTORS.md` file using the below convention: 61 | 62 | markdown 63 | #### Name: [YOUR NAME](GitHub link) 64 | 65 | - Place: City, State, Country 66 | - Bio: Who are you? 67 | - GitHub: [GitHub account name](GitHub link) 68 | 69 | 70 | ### 2. Add a profile page 71 | 72 | Add a `Your_Name.md` file to the `profiles` directory. Use any combination of content and Markdown you'd like. Here is an example: 73 | 74 | markdown 75 | # Your Name 76 | 77 | ### Location 78 | 79 | Your City/Country 80 | 81 | ### Academics 82 | 83 | Your School 84 | 85 | ### Interests 86 | 87 | - Some Things You Like 88 | 89 | ### Development 90 | 91 | - Inventor of the My Pillow 92 | 93 | ### Projects 94 | 95 | - [My Project](GitHub Link) Short Description 96 | 97 | ### Profile Link 98 | 99 | [Your Name](GitHub Link) 100 | 101 | 102 | ### 3. Create a `Hello, World!` Script 103 | 104 | Add a `hello_world_yourusername.xx` script to the `scripts` directory in any language of your choice! Here is an example: 105 | 106 | Javascript 107 | // LANGUAGE: Javascript 108 | // ENV: Node.js 109 | // AUTHOR: Anmol Agarwal 110 | // GITHUB: https://github.com/fineanmol 111 | 112 | console.log('Hello, World!'); 113 | 114 | 115 | Name the file `hello_world_yourusername.xx`. e.g., `hello_world_anmolagarwal.js` or `hello_world_anmolagarwal.py`. 116 | 117 | Add your scripts to the specific folder for specific languages created. 118 | 119 | Don't forget to include the comments as seen above. Feel free to include additional information about the language you choose in your comments too! Like a link to a helpful introduction or tutorial. 120 | 121 | Here is my `hello_world` example: [hello_world_anmolagarwal.js](https://github.com/fineanmol/hacktoberfest/blob/master/scripts/hello_world_anmol_agarwal.js) 122 | 123 | ## Our Contributors 124 |

125 | 126 |

127 | 128 | ## BONUS! 129 | 130 | - Merging All Pull Requests 131 | - See profiles submitted by fellow coders from around the globe ... from Kathmandu to Copenhagen. 132 | - Discover some obscure to new and trending languages ... from BrainFuck to Groovy. 133 | - Check out some very creative ways to print out a "Hello, World!" string. 134 | 135 | 136 | Keep Your Fork Synced: [https://gist.github.com/fineanmol/f9b8943230e7031ae78cdcd1755bef32](https://github.com/thecodingcenter/HacktoberFest/) 137 | 138 | Checkout this list for README examples - Awesome README [![Awesome](https://cdn.rawgit.com/sindresorhus/awesome/d7305f38d29fed78fa85652e3a63e154dd8e8829/media/badge.svg)](https://github.com/sindresorhus/awesome) 139 | 140 | Github-Flavored Markdown [https://guides.github.com/features/mastering-markdown/](https://guides.github.com/features/mastering-markdown/) 141 | 142 | ## Additional references added by contributors 143 | 144 | GitHub license explained [https://choosealicense.com](https://choosealicense.com) 145 | -------------------------------------------------------------------------------- /Recursive_Sum_Num.java: -------------------------------------------------------------------------------- 1 | import java.util.Scanner; 2 | public class Recursive_Sum_Num { 3 | static int recursive_sum(int n) 4 | { 5 | if(n==1) 6 | return 1; 7 | else 8 | return n+recursive_sum(n-1); 9 | } 10 | public static void main(String[] args) { 11 | Scanner sc=new Scanner(System.in); 12 | int n=sc.nextInt(); 13 | int sum=recursive_sum(n); 14 | System.out.println(sum); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Reverse.java: -------------------------------------------------------------------------------- 1 | public class Reverse { 2 | public static void main(String[] args) { 3 | int num = 123456; 4 | 5 | int ans = 0; 6 | 7 | while (num > 0) { 8 | int rem = num % 10; 9 | num /= 10; 10 | 11 | ans = ans * 10 + rem; 12 | } 13 | 14 | System.out.println(ans); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Stream.java: -------------------------------------------------------------------------------- 1 | public class Stream { 2 | public static void main(String[] args) { 3 | String s = "appleuegwrhapplejhdsappleyapplen"; 4 | System.out.println(skipapple(s)); 5 | } 6 | 7 | static String skipapple(String up) { 8 | if (up.isEmpty()) { 9 | return ""; 10 | } 11 | 12 | char ch = up.charAt(0); 13 | if (up.startsWith("apple")) { 14 | return skipapple(up.substring(5)); 15 | } else { 16 | return ch + skipapple(up.substring(1)); 17 | } 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /String3_Freq: -------------------------------------------------------------------------------- 1 | 2 | import java.util.*; 3 | class String3 4 | { 5 | public static void main(String args[]) 6 | { 7 | Scanner sc=new Scanner (System.in); 8 | System.out.println("Please enter a sentence"); 9 | String str=sc.nextLine(); 10 | int l=str.length(); 11 | String str1=str.toLowerCase(); 12 | int va=0, ve=0,vi=0, vo=0,vu=0; 13 | for(int i=0;i>S; 8 | rev=S; 9 | reverse(rev.begin(),rev.end()); 10 | if(rev==S) 11 | { 12 | cout< 10 | #include 11 | #include 12 | 13 | int Calculator() { 14 | int choice, i, a, b; 15 | float x, y, result; 16 | printf("\n Welcome To Furious Calculator\n\n\n"); 17 | printf("1. Addition 2. Subtraction 3. Multiplication\n\n4. Division "); 18 | printf("5. Square root 6. X ^ Y\n\n7. X ^ 2 8. X ^ 3 "); 19 | printf("9. 1 / X\n\n10. X^(1 / Y) 11. X ^ (1 / 3) "); 20 | printf("12. 10 ^ X\n\n13. X! 14. %% 15. log10(x)\n\n16. Modulus "); 21 | printf("17. Sin(X) 18. Cos(X)\n\n19. Tan(X) 20. Cosec(X) "); 22 | printf("21. Cot(X)\n\n22. Sec(X) 23. About 0. Back\n\n"); 23 | printf("Enter Your Choice: "); 24 | scanf("%d", &choice); 25 | system ("cls"); 26 | if(choice == 0) main(); 27 | switch(choice) { 28 | case 1: 29 | printf("Enter X: "); 30 | scanf("%f", &x); 31 | printf("\nEnter Y: "); 32 | scanf("%f", &y); 33 | result = x + y; 34 | printf("\nResult: %f", result); 35 | mainmenu(); 36 | break; 37 | case 2: 38 | printf("Enter X: "); 39 | scanf("%f", &x); 40 | printf("\nEnter Y: "); 41 | scanf("%f", &y); 42 | result=x-y; 43 | printf("\nResult: %f", result); 44 | mainmenu(); 45 | break; 46 | case 3: 47 | printf("Enter X: "); 48 | scanf("%f", &x); 49 | printf("\nEnter Y: "); 50 | scanf("%f", &y); 51 | result = x * y; 52 | printf("\nResult: %f", result); 53 | mainmenu(); 54 | break; 55 | case 4: 56 | printf("Enter X: "); 57 | scanf("%f", &x); 58 | printf("\nEnter Y: "); 59 | scanf("%f", &y); 60 | result = x / y; 61 | printf("\nResult: %f", result); 62 | mainmenu(); 63 | break; 64 | case 5: 65 | printf("Enter X: "); 66 | scanf("%f", &x); 67 | result = sqrt(x); 68 | printf("\nResult: %f", result); 69 | mainmenu(); 70 | break; 71 | case 6: 72 | printf("Enter X: "); 73 | scanf("%f", &x); 74 | printf("\nEnter Y: "); 75 | scanf("%f", &y); 76 | result = pow(x, y); 77 | printf("\nResult: %f", result); 78 | mainmenu(); 79 | break; 80 | case 7: 81 | printf("Enter X: "); 82 | scanf("%f", &x); 83 | result = pow(x, 2); 84 | printf("\nResult: %f", result); 85 | mainmenu(); 86 | break; 87 | case 8: 88 | printf("Enter X: "); 89 | scanf("%f", &x); 90 | result = pow(x, 3); 91 | printf("\nResult: %f", result); 92 | mainmenu(); 93 | break; 94 | case 9: 95 | printf("Enter X: "); 96 | scanf("%f", &x); 97 | result = pow(x, -1); 98 | printf("\nResult: %f", result); 99 | mainmenu(); 100 | break; 101 | case 10: 102 | printf("Enter X: "); 103 | scanf("%f", &x); 104 | printf("\nEnter Y: "); 105 | scanf("%f", &y); 106 | result = pow(x, (1/y)); 107 | printf("\nResult: %f", result); 108 | mainmenu(); 109 | break; 110 | case 11: 111 | printf("Enter X: "); 112 | scanf("%f", &x); 113 | y = 3; 114 | result = pow(x, (1/y)); 115 | printf("\nResult: %f", result); 116 | mainmenu(); 117 | break; 118 | case 12: 119 | printf("Enter X: "); 120 | scanf("%f", &x); 121 | result = pow(10, x); 122 | printf("\nResult: %f", result); 123 | mainmenu(); 124 | break; 125 | case 13: 126 | printf("Enter X: "); 127 | scanf("%f", &x); 128 | result = 1; 129 | for(i = 1; i <= x; i++) { 130 | result = result * i; 131 | } 132 | printf("\nResult: %.f", result); 133 | mainmenu(); 134 | break; 135 | case 14: 136 | printf("Enter X: "); 137 | scanf("%f", &x); 138 | printf("\nEnter Y: "); 139 | scanf("%f", &y); 140 | result = (x * y) / 100; 141 | printf("\nResult: %.2f", result); 142 | mainmenu(); 143 | break; 144 | case 15: 145 | printf("Enter X: "); 146 | scanf("%f", &x); 147 | result = log10(x); 148 | printf("\nResult: %.2f", result); 149 | mainmenu(); 150 | break; 151 | case 16: 152 | printf("Enter X: "); 153 | scanf("%d", &a); 154 | printf("\nEnter Y: "); 155 | scanf("%d", &b); 156 | result = a % b; 157 | printf("\nResult: %d", result); 158 | mainmenu(); 159 | break; 160 | case 17: 161 | printf("Enter X: "); 162 | scanf("%f", &x); 163 | result = sin(x * 3.14159 / 180); 164 | printf("\nResult: %.2f", result); 165 | mainmenu(); 166 | break; 167 | case 18: 168 | printf("Enter X: "); 169 | scanf("%f", &x); 170 | result = cos(x * 3.14159 / 180); 171 | printf("\nResult: %.2f", result); 172 | mainmenu(); 173 | break; 174 | case 19: 175 | printf("Enter X: "); 176 | scanf("%f", &x); 177 | result = tan(x * 3.14159 / 180); 178 | printf("\nResult: %.2f", result); 179 | mainmenu(); 180 | break; 181 | case 20: 182 | printf("Enter X: "); 183 | scanf("%f", &x); 184 | result = 1 / (sin(x * 3.14159 / 180)); 185 | printf("\nResult: %.2f", result); 186 | mainmenu(); 187 | break; 188 | case 21: 189 | printf("Enter X: "); 190 | scanf("%f", &x); 191 | result = 1 / tan(x * 3.14159 / 180); 192 | printf("\nResult: %.2f", result); 193 | mainmenu(); 194 | break; 195 | case 22: 196 | printf("Enter X: "); 197 | scanf("%f", &x); 198 | result = 1 / cos(x * 3.14159 / 180); 199 | printf("\nResult: %.2f", result); 200 | mainmenu(); 201 | break; 202 | default: 203 | printf("\nInvalid Choice!"); 204 | } 205 | getch(); 206 | mainmenu(); 207 | return 0; 208 | } 209 | -------------------------------------------------------------------------------- /StudentAssistant-master/DemoWallet.c: -------------------------------------------------------------------------------- 1 | /* Project Name: Student Assistant 2 | Developed By: Jameur Rahman Fida 3 | Contact: fida.cse@gmail.com 4 | fb.me/fida97 5 | github.com/fida97 */ 6 | 7 | //Demo Wallet C Code 8 | 9 | #include 10 | #include 11 | #include 12 | 13 | int DemoWallet() 14 | { 15 | int code; 16 | printf("\t\t\tWelcome To Demo Wallet\n\n"); 17 | printf("\t\t\tPlease Enter Your Wallet Pin\n\n\t\t\t"); 18 | scanf("%d",&code); 19 | system ("cls"); 20 | switch(code) 21 | { 22 | case 1234: 23 | { 24 | int code1; 25 | printf("\n\t\t\tLog In Successful\n\n"); 26 | printf("\t\t\tChoose An Option:\n\n\t\t\t1.Send Money\n\t\t\t2.Buy Airtime\n\t\t\t3.Payment\n\t\t\t4.Cash Out\n\t\t\t5.Cheak Balence\n\n\t\t\t"); 27 | scanf("%d",&code1); 28 | system ("cls"); 29 | switch(code1) 30 | 31 | { 32 | case 1: 33 | { 34 | int a,b; 35 | int code2; 36 | printf("\n\t\t\tEnter A Number: "); 37 | scanf("%d",&a); 38 | printf("\n\t\t\tEnter Amount: "); 39 | scanf("%d",&b); 40 | system ("cls"); 41 | printf("\n\t\t\tSend Money Taka %d To %d\n\n\t\t\t1.Confirm\t2.Close\n\n\t\t\t",b,a); 42 | scanf("%d",&code2); 43 | system ("cls"); 44 | switch(code2) 45 | { 46 | case 1: 47 | { 48 | int pin; 49 | printf("\n\t\t\tPlease Enter Your Wallet Pin\n\n\t\t\t"); 50 | scanf("%d",&code); 51 | system ("cls"); 52 | switch(code) 53 | { 54 | case 1234: 55 | { 56 | printf("\n\t\t\tSend Money Taka %d To %d Has Been Successful.\n\n\t\t\t",b,a); 57 | mainmenu(); 58 | break; 59 | } 60 | break; 61 | default: 62 | puts("\n\t\t\tWrong Pin"); 63 | mainmenu(); 64 | break; 65 | } 66 | return(0); 67 | break; 68 | } 69 | } 70 | break; 71 | } 72 | case 2: 73 | { 74 | int a,b; 75 | int code2; 76 | printf("\n\t\t\tEnter Airtime Number: "); 77 | scanf("%d",&a); 78 | printf("\n\t\t\tEnter Amount: "); 79 | scanf("%d",&b); 80 | system ("cls"); 81 | printf("\n\t\t\tBuy Airtime Taka %d To %d\n\n\t\t\t1.Confirm\t2.Close\n\n\t\t\t",b,a); 82 | scanf("%d",&code2); 83 | system ("cls"); 84 | switch(code2) 85 | { 86 | case 1: 87 | { 88 | int pin; 89 | printf("\n\t\t\tPlease Enter Your Wallet Pin\n\n\t\t\t"); 90 | scanf("%d",&code); 91 | system ("cls"); 92 | switch(code) 93 | { 94 | case 1234: 95 | { 96 | printf("\n\t\t\tBuy Airtime Taka %d To %d Has Been Successful.\n\n\t\t\t",b,a); 97 | mainmenu(); 98 | break; 99 | } 100 | break; 101 | default: 102 | puts("\n\t\t\tWrong Pin"); 103 | mainmenu(); 104 | break; 105 | } 106 | break; 107 | } 108 | } 109 | break; 110 | } 111 | case 3: 112 | puts("\n\t\tPlease Contact With Jameur Fida To Activate Your Demo Wallet."); 113 | mainmenu(); 114 | break; 115 | case 4: 116 | { 117 | int a,b; 118 | int code2; 119 | printf("\n\t\t\tEnter Agent Number: "); 120 | scanf("%d",&a); 121 | printf("\n\t\t\tEnter Amount: "); 122 | scanf("%d",&b); 123 | system ("cls"); 124 | printf("\n\t\t\tCash Out Taka %d To %d\n\n\t\t\t1.Confirm\t2.Close\n\n\t\t\t",b,a); 125 | scanf("%d",&code2); 126 | system ("cls"); 127 | switch(code2) 128 | { 129 | case 1: 130 | { 131 | int pin; 132 | printf("\n\t\t\tPlease Enter Your Wallet Pin\n\n\t\t\t"); 133 | scanf("%d",&code); 134 | system ("cls"); 135 | switch(code) 136 | { 137 | case 1234: 138 | { 139 | printf("\n\t\t\tCash Out Taka %d To %d Has Been Successful.\n\n\t\t\t",b,a); 140 | mainmenu(); 141 | break; 142 | } 143 | break; 144 | default: 145 | puts("\n\t\t\tWrong Pin"); 146 | mainmenu(); 147 | break; 148 | } 149 | break; 150 | } 151 | } 152 | break; 153 | } 154 | case 5: 155 | puts("\n\t\tPlease Contact With Jameur Fida To Activate Your Demo Wallet."); 156 | mainmenu(); 157 | break; 158 | } 159 | break; 160 | } 161 | default: 162 | puts("\n\t\t\tWrong Pin"); 163 | mainmenu(); 164 | return(0); 165 | break; 166 | getch(); 167 | return(0); 168 | } 169 | } 170 | -------------------------------------------------------------------------------- /StudentAssistant-master/PersonalDiary.c: -------------------------------------------------------------------------------- 1 | /* Project Name: Student Assistant 2 | Developed By: Jameur Rahman Fida 3 | Contact: fida.cse@gmail.com 4 | fb.me/fida97 5 | github.com/fida97 */ 6 | 7 | //Persoal Diary C Code 8 | 9 | #include 10 | #include 11 | #include //contains delay(),getch(),gotoxy(),etc. 12 | #include 13 | #include 14 | 15 | char notedate[10]; 16 | COORD coord = {0, 0}; // sets coordinates to 0,0 17 | //COORD max_buffer_size = GetLargestConsoleWindowSize(hOut); 18 | COORD max_res,cursor_size; 19 | void gotoxy (int x, int y) 20 | { 21 | coord.X = x; 22 | coord.Y = y; // X and Y coordinates 23 | SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord); 24 | } 25 | void delay(unsigned int mseconds) 26 | { 27 | clock_t goal = mseconds + clock(); 28 | while (goal > clock()); 29 | } 30 | 31 | /* There is some problem with this back menu function.Need to fix this. 32 | 33 | void backnote() 34 | { 35 | int input; 36 | printf("\n\n Press 0 To Go Back To Main Menu: "); 37 | scanf("%d",&input); 38 | if (input==0) 39 | { 40 | system("cls"); 41 | main(); 42 | } 43 | else 44 | { 45 | system("cls"); 46 | printf(" Wrong Input\n\n"); 47 | main(); 48 | } 49 | } */ 50 | 51 | void backnote() 52 | { 53 | int mn; 54 | printf("\n\n\ Press 0 To Go Back Main Menu: "); 55 | scanf("%d",&mn); 56 | if (mn==0) 57 | { 58 | system ("cls"); 59 | notemenu(); 60 | } 61 | else 62 | { 63 | system ("cls"); 64 | printf("\n Wrong Input"); 65 | backnote(); 66 | } 67 | } 68 | 69 | void password(void) //for password option 70 | { 71 | char password[10]= {"1234"}; 72 | system("cls"); 73 | char d[25]=" Password Protected "; 74 | char ch,pass[10]; 75 | int i=0,j; 76 | //textbackground(WHITE); 77 | //textcolor(RED); 78 | gotoxy(8,4); 79 | for(j=0; j<15; j++) 80 | { 81 | delay(20); 82 | printf("!"); 83 | } 84 | for(j=0; j 12 | #include 13 | //Custom Made C Files Are Included As Header Files... 14 | #include "Calculator.c" 15 | #include "DCalculator.c" 16 | #include "EasyMatrix.c" 17 | #include "ClassRoutine.c" 18 | #include "PersonalDiary.c" 19 | #include "PeriodicTable.c" 20 | #include "DemoWallet.c" 21 | #include "Backmenu.h" //Custom Made .h File 22 | 23 | int t(void) //for time 24 | { 25 | time_t t; 26 | time(&t); 27 | printf("Date And Time: %s\n",ctime(&t)); 28 | 29 | return 0 ; 30 | } 31 | 32 | int main() 33 | { 34 | //loaderanim(); 35 | system("cls"); 36 | //textbackground(13); 37 | int input,sta; 38 | char stdast[]="\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2 Student Assistant \xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2"; 39 | char um[]="This Function Is Under Maintanance.Will Add On Next Update"; 40 | gotoxy(18,2); 41 | //printf("\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2 Student Assistant"); 42 | for(sta=0; sta<=strlen(stdast); sta++) 43 | { 44 | delay(20); 45 | printf("%c",stdast[sta]); 46 | } 47 | //printf(" \xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2"); 48 | gotoxy(18,4); 49 | printf("\xDB\xDB\xDB\xDB\xB2 1. Calculator "); 50 | gotoxy(18,6); 51 | printf("\xDB\xDB\xDB\xDB\xB2 2. Easy Matrix"); 52 | gotoxy(18,8); 53 | printf("\xDB\xDB\xDB\xDB\xB2 3. Class Routine"); 54 | gotoxy(18,10); 55 | printf("\xDB\xDB\xDB\xDB\xB2 4. Personal Diary"); 56 | gotoxy(18,12); 57 | printf("\xDB\xDB\xDB\xDB\xB2 5. Periodic Table"); 58 | gotoxy(18,14); 59 | printf("\xDB\xDB\xDB\xDB\xB2 6. Finance Manager"); 60 | gotoxy(18,16); 61 | printf("\xDB\xDB\xDB\xDB\xB2 7. Connect Wallet"); 62 | gotoxy(18,18); 63 | printf("\xDB\xDB\xDB\xDB\xB2 8. Close Application"); 64 | //gotoxy(18,20); 65 | //printf("\xDB\xDB\xDB\xDB\xB2 7. Close Application"); 66 | gotoxy(18,20); 67 | printf("-----------------------------------------"); 68 | gotoxy(18,21); 69 | t(); 70 | gotoxy(18,23); 71 | printf("Enter Your Choice: "); 72 | scanf("%d",&input); 73 | switch(input) 74 | { 75 | case 1: 76 | system("cls"); 77 | printf("\n Calculator\n\n\n 1. Simple Calculator\n\n 2. Dynamic Calcdulator\n\n 0. Main Menu\n\n"); 78 | scanf("%d",&input); 79 | if (input==1) 80 | { 81 | system("cls"); 82 | Calculator(); 83 | } 84 | else if (input==2) 85 | { 86 | system("cls"); 87 | DCalculator(); 88 | } 89 | else if (input==0) 90 | { 91 | main(); 92 | } 93 | else 94 | { 95 | mainmenu(); 96 | } 97 | break; 98 | case 2: 99 | system("cls"); 100 | EasyMatrix(); 101 | break; 102 | case 3: 103 | system("cls"); 104 | ClassRoutine(); 105 | break; 106 | case 4: 107 | system("cls"); 108 | PersonalDiary(); 109 | break; 110 | case 5: 111 | system("cls"); 112 | PeriodicTable(); 113 | break; 114 | case 6: 115 | { 116 | gotoxy(15,2); 117 | //printf("This Function Is Under Maintanance.Will Add On Next Update."); 118 | for(sta=0; sta<=strlen(um); sta++) 119 | { 120 | delay(10); 121 | printf("%c",um[sta]); 122 | } 123 | if(getch()) 124 | main(); 125 | } 126 | case 7: 127 | system("cls"); 128 | DemoWallet(); 129 | break; 130 | case 8: 131 | { 132 | system("cls"); 133 | gotoxy(18,3); 134 | printf("Thanks For Using Student Assistant..."); 135 | gotoxy(20,7); 136 | printf("Exiting In 5 Second..........."); 137 | //flushall(); 138 | delay(5000); 139 | exit(0); 140 | } 141 | default: 142 | { 143 | gotoxy(18,23); 144 | printf("\aWrong Entry!!Please Re-entered Correct Option"); 145 | if(getch()) 146 | main(); 147 | } 148 | 149 | } 150 | } 151 | -------------------------------------------------------------------------------- /StudentAssistant-master/StudentAssistant.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/regression1607/HacktoberFest2022/6f7a1b6a6f08a6505f75ae0dad0efd39f7e32cbf/StudentAssistant-master/StudentAssistant.exe -------------------------------------------------------------------------------- /StudentAssistant-master/StudentAssistant.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/regression1607/HacktoberFest2022/6f7a1b6a6f08a6505f75ae0dad0efd39f7e32cbf/StudentAssistant-master/StudentAssistant.png -------------------------------------------------------------------------------- /Sudoku Solver/Sudoku.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/regression1607/HacktoberFest2022/6f7a1b6a6f08a6505f75ae0dad0efd39f7e32cbf/Sudoku Solver/Sudoku.class -------------------------------------------------------------------------------- /Sudoku Solver/Sudoku.java: -------------------------------------------------------------------------------- 1 | // Java program for above approach 2 | public class Sudoku { 3 | 4 | // N is the size of the 2D matrix N*N 5 | static int N = 9; 6 | 7 | /* Takes a partially filled-in grid and attempts 8 | to assign values to all unassigned locations in 9 | such a way to meet the requirements for 10 | Sudoku solution (non-duplication across rows, 11 | columns, and boxes) */ 12 | static boolean solveSudoku(int grid[][], int row, 13 | int col) 14 | { 15 | 16 | /*if we have reached the 8th 17 | row and 9th column (0 18 | indexed matrix) , 19 | we are returning true to avoid further 20 | backtracking */ 21 | if (row == N - 1 && col == N) 22 | return true; 23 | 24 | // Check if column value becomes 9 , 25 | // we move to next row 26 | // and column start from 0 27 | if (col == N) { 28 | row++; 29 | col = 0; 30 | } 31 | 32 | // Check if the current position 33 | // of the grid already 34 | // contains value >0, we iterate 35 | // for next column 36 | if (grid[row][col] != 0) 37 | return solveSudoku(grid, row, col + 1); 38 | 39 | for (int num = 1; num < 10; num++) { 40 | 41 | // Check if it is safe to place 42 | // the num (1-9) in the 43 | // given row ,col ->we move to next column 44 | if (isSafe(grid, row, col, num)) { 45 | 46 | /* assigning the num in the current 47 | (row,col) position of the grid and 48 | assuming our assigned num in the position 49 | is correct */ 50 | grid[row][col] = num; 51 | 52 | // Checking for next 53 | // possibility with next column 54 | if (solveSudoku(grid, row, col + 1)) 55 | return true; 56 | } 57 | /* removing the assigned num , since our 58 | assumption was wrong , and we go for next 59 | assumption with diff num value */ 60 | grid[row][col] = 0; 61 | } 62 | return false; 63 | } 64 | 65 | /* A utility function to print grid */ 66 | static void print(int[][] grid) 67 | { 68 | for (int i = 0; i < N; i++) { 69 | for (int j = 0; j < N; j++) 70 | System.out.print(grid[i][j] + " "); 71 | System.out.println(); 72 | } 73 | } 74 | 75 | // Check whether it will be legal 76 | // to assign num to the 77 | // given row, col 78 | static boolean isSafe(int[][] grid, int row, int col, 79 | int num) 80 | { 81 | 82 | // Check if we find the same num 83 | // in the similar row , we 84 | // return false 85 | for (int x = 0; x <= 8; x++) 86 | if (grid[row][x] == num) 87 | return false; 88 | 89 | // Check if we find the same num 90 | // in the similar column , 91 | // we return false 92 | for (int x = 0; x <= 8; x++) 93 | if (grid[x][col] == num) 94 | return false; 95 | 96 | // Check if we find the same num 97 | // in the particular 3*3 98 | // matrix, we return false 99 | int startRow = row - row % 3, startCol 100 | = col - col % 3; 101 | for (int i = 0; i < 3; i++) 102 | for (int j = 0; j < 3; j++) 103 | if (grid[i + startRow][j + startCol] == num) 104 | return false; 105 | 106 | return true; 107 | } 108 | 109 | // Driver Code 110 | public static void main(String[] args) 111 | { 112 | int grid[][] = { { 3, 0, 6, 5, 0, 8, 4, 0, 0 }, 113 | { 5, 2, 0, 0, 0, 0, 0, 0, 0 }, 114 | { 0, 8, 7, 0, 0, 0, 0, 3, 1 }, 115 | { 0, 0, 3, 0, 1, 0, 0, 8, 0 }, 116 | { 9, 0, 0, 8, 6, 3, 0, 0, 5 }, 117 | { 0, 5, 0, 0, 9, 0, 6, 0, 0 }, 118 | { 1, 3, 0, 0, 0, 0, 2, 5, 0 }, 119 | { 0, 0, 0, 0, 0, 0, 0, 7, 4 }, 120 | { 0, 0, 5, 2, 0, 6, 3, 0, 0 } }; 121 | 122 | if (solveSudoku(grid, 0, 0)) 123 | print(grid); 124 | else 125 | System.out.println("No Solution exists"); 126 | } 127 | // This is code is contributed by Pradeep Mondal P 128 | } 129 | -------------------------------------------------------------------------------- /TraverseLinkedList.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | void create(int); 4 | void traverse(); 5 | struct node 6 | { 7 | int data; 8 | struct node *next; 9 | }; 10 | struct node *head; 11 | void main () 12 | { 13 | int choice,item; 14 | do 15 | { 16 | printf("\n1.Append List\n2.Traverse\n3.Exit\n4.Enter your choice?"); 17 | scanf("%d",&choice); 18 | switch(choice) 19 | { 20 | case 1: 21 | printf("\nEnter the item\n"); 22 | scanf("%d",&item); 23 | create(item); 24 | break; 25 | case 2: 26 | traverse(); 27 | break; 28 | case 3: 29 | exit(0); 30 | break; 31 | default: 32 | printf("\nPlease enter valid choice\n"); 33 | } 34 | 35 | }while(choice != 3); 36 | } 37 | void create(int item) 38 | { 39 | struct node *ptr = (struct node *)malloc(sizeof(struct node *)); 40 | if(ptr == NULL) 41 | { 42 | printf("\nOVERFLOW\n"); 43 | } 44 | else 45 | { 46 | ptr->data = item; 47 | ptr->next = head; 48 | head = ptr; 49 | printf("\nNode inserted\n"); 50 | } 51 | 52 | } 53 | void traverse() 54 | { 55 | struct node *ptr; 56 | ptr = head; 57 | if(ptr == NULL) 58 | { 59 | printf("Empty list.."); 60 | } 61 | else 62 | { 63 | printf("printing values . . . . .\n"); 64 | while (ptr!=NULL) 65 | { 66 | printf("\n%d",ptr->data); 67 | ptr = ptr -> next; 68 | } 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /Unique_Paths.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | int uniquePaths(int m, int n) { 4 | vector> dp(m,vector (n,1)); // 2d array with all values 1 5 | for(int i=1;i bool: 3 | start=0 4 | end=len(s)-1 5 | 6 | while start=0) return false; 20 | 21 | // if m has some character but n is empty 22 | 23 | if (n<0 && m>=0) { 24 | /* 25 | if str = "" && pattern = "***" then return true; 26 | because we can neglect the * also 27 | else str = "" && pattern = "sd**" return false; 28 | because after neglecting the * pattern has some more character 29 | 30 | */ 31 | for (int i=0;i<=m;i++){ 32 | if (p.charAt(i) != '*') return false; 33 | } 34 | return true; 35 | } 36 | 37 | //Memorisation 38 | if (dp[m][n] != null) return dp[m][n]; 39 | 40 | //if both the character is equal || patern[m] == ? 41 | if (p.charAt(m) == s.charAt(n) || p.charAt(m) == '?'){ 42 | return dp[m][n] = is_match(m-1,n-1,p,s); 43 | } 44 | 45 | // if p has '*' 46 | if (p.charAt(m) == '*'){ 47 | return dp[m][n] = is_match(m-1,n,p,s) || is_match(m,n-1,p,s); 48 | } 49 | // if both the character is not equal 50 | return false; 51 | 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /amazon-price-scraper/main.py: -------------------------------------------------------------------------------- 1 | from bs4 import BeautifulSoup 2 | import requests 3 | 4 | PRODUCT_URI = input("Enter product url: ") 5 | price = 0 6 | 7 | 8 | def get_product_price(url): 9 | response = requests.get( 10 | url, 11 | headers={ 12 | "User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.45 Safari/537.36" 13 | }, 14 | ) 15 | soup = BeautifulSoup(response.text, "lxml") 16 | available = soup.find("div", {"id": "availability"}) 17 | if available is not None: 18 | if "Currently unavailable." in available.text: 19 | print("Product is currently unavailable.") 20 | return False 21 | price_parent = soup.find( 22 | "span", {"class": "a-price a-text-price a-size-medium apexPriceToPay"} 23 | ) 24 | if price_parent is not None: 25 | price = price_parent.text.split("₹")[1] 26 | print("Price: ₹", price) 27 | return True 28 | 29 | 30 | get_product_price(PRODUCT_URI) 31 | -------------------------------------------------------------------------------- /amazon-price-scraper/randomPassGen.py: -------------------------------------------------------------------------------- 1 | # generate random password 2 | import random 3 | import string 4 | def randPassGen(length): 5 | password = '' 6 | for i in range(length): 7 | password += random.choice(string.ascii_letters + string.digits) 8 | return password 9 | 10 | print(randPassGen(8)) -------------------------------------------------------------------------------- /amazon-price-scraper/requirements.txt: -------------------------------------------------------------------------------- 1 | beautifulsoup4==4.10.0 2 | certifi==2021.10.8 3 | charset-normalizer==2.0.10 4 | idna==3.3 5 | lxml==4.7.1 6 | requests==2.27.1 7 | soupsieve==2.3.1 8 | urllib3==1.26.7 9 | -------------------------------------------------------------------------------- /armstrong number.md: -------------------------------------------------------------------------------- 1 | Armstrong Number 2 | An Armstrong number is a positive m-digit number that is equal to the sum of the mth powers of their digits. It is also known as pluperfect, or Plus Perfect, or Narcissistic number. It is an OEIS sequence A005188. Let’s understand it through an example. 3 | 4 | Armstrong Number Example 5 | 1: 11 = 1 6 | 7 | 2: 21 = 2 8 | 3: 31 = 3 9 | 10 | 153: 13 + 53 + 33 = 1 + 125+ 27 = 153 11 | 12 | 125: 13 + 23 + 53 = 1 + 8 + 125 = 134 (Not an Armstrong Number) 13 | 14 | 1634: 14 + 64 + 34 + 44 = 1 + 1296 + 81 + 256 = 1643 15 | 16 | Similarly, we can check other number also. 17 | 18 | The first few Armstrong numbers between 0 to 999 are 1, 2, 3, 4, 5, 6, 7, 8, 9, 153, 370, 371, 407. Some other Armstrong numbers are 1634, 8208, 9474, 54748, 92727, 93084, 548834, 1741725, 4210818, 9800817, 9926315, 24678050, 24678051, 88593477, 146511208, 472335975, 534494836, 912985153, 4679307774, 32164049650, 32164049651. 19 | -------------------------------------------------------------------------------- /binarySearch.cpp: -------------------------------------------------------------------------------- 1 | // C++ program to implement recursive Binary Search 2 | #include 3 | using namespace std; 4 | 5 | // A recursive binary search function. It returns 6 | // location of x in given array arr[l..r] is present, 7 | // otherwise -1 8 | int binarySearch(int arr[], int l, int r, int x) 9 | { 10 | if (r >= l) { 11 | int mid = l + (r - l) / 2; 12 | 13 | // If the element is present at the middle 14 | // itself 15 | if (arr[mid] == x) 16 | return mid; 17 | 18 | // If element is smaller than mid, then 19 | // it can only be present in left subarray 20 | if (arr[mid] > x) 21 | return binarySearch(arr, l, mid - 1, x); 22 | 23 | // Else the element can only be present 24 | // in right subarray 25 | return binarySearch(arr, mid + 1, r, x); 26 | } 27 | 28 | // We reach here when element is not 29 | // present in array 30 | return -1; 31 | } 32 | 33 | int main(void) 34 | { 35 | int arr[] = { 2, 3, 4, 10, 40 }; 36 | int x = 10; 37 | int n = sizeof(arr) / sizeof(arr[0]); 38 | int result = binarySearch(arr, 0, n - 1, x); 39 | (result == -1) 40 | ? cout << "Element is not present in array" 41 | : cout << "Element is present at index " << result; 42 | return 0; 43 | } 44 | -------------------------------------------------------------------------------- /binarysearchtree.py: -------------------------------------------------------------------------------- 1 | # Returns index of x in arr if present, else -1 2 | def binary_search(arr, low, high, x): 3 | # Check base case 4 | if high >= low: 5 | 6 | mid = (high + low) // 2 7 | 8 | # If element is present at the middle itself 9 | if arr[mid] == x: 10 | return mid 11 | 12 | # If element is smaller than mid, then it can only 13 | # be present in left subarray 14 | elif arr[mid] > x: 15 | return binary_search(arr, low, mid - 1, x) 16 | 17 | # Else the element can only be present in right subarray 18 | else: 19 | return binary_search(arr, mid + 1, high, x) 20 | 21 | else: 22 | # Element is not present in the array 23 | return -1 24 | 25 | 26 | # Test array 27 | arr = list(map(int, input().split())) 28 | x = int(input()) 29 | 30 | # Function call 31 | result = binary_search(arr, 0, len(arr) - 1, x) 32 | 33 | if result != -1: 34 | print("Element is present at index", str(result)) 35 | else: 36 | print("Element is not present in array") 37 | -------------------------------------------------------------------------------- /c.md: -------------------------------------------------------------------------------- 1 | With this Python project, we will be making a drowsiness detection system. A countless number of people drive on the highway day and night. Taxi drivers, bus drivers, truck drivers and people traveling long-distance suffer from lack of sleep. Due to which it becomes very dangerous to drive when feeling sleepy. 2 | 3 | The majority of accidents happen due to the drowsiness of the driver. So, to prevent these accidents we will build a system using Python, OpenCV, and Keras which will alert the driver when he feels sleepy. 4 | 5 | DataFlair has also published other machine learning project ideas with source code. You can check them from this ml projects list: 6 | 7 | Fake News Detection Python Project 8 | Parkinson’s Disease Detection Python Project 9 | Color Detection Python Project 10 | Speech Emotion Recognition Python Project 11 | Breast Cancer Classification Python Project 12 | Age and Gender Detection Python Project 13 | Handwritten Digit Recognition Python Project 14 | Chatbot Python Project 15 | Drowsy Driver Safety Alert System Python Project 16 | Traffic Signs Recognition Python Project 17 | Image Caption Generator Python Project 18 | -------------------------------------------------------------------------------- /celebrityprob.java: -------------------------------------------------------------------------------- 1 | //username: DishaKhanapurkar 2 | 3 | class Solution 4 | { 5 | //Function to find if there is a celebrity in the party or not. 6 | int celebrity(int M[][], int n) 7 | { 8 | // code here 9 | Stack st=new Stack<>(); 10 | 11 | for(int i=0; i=2) 20 | 21 | { 22 | 23 | int v1=st.pop(); 24 | 25 | int v2=st.pop(); 26 | 27 | if(M[v1][v2]==1) 28 | 29 | { 30 | 31 | st.push(v2); 32 | 33 | } 34 | 35 | else 36 | 37 | { 38 | 39 | st.push(v1); 40 | 41 | } 42 | 43 | } 44 | 45 | int last=st.pop(); 46 | 47 | for(int i=0; i 0) { 7 | int rem = n % 10; 8 | if (rem == 5) { 9 | count++; 10 | } 11 | n = n / 10; // n /= 10 12 | } 13 | 14 | System.out.println(count); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /countallpossiblepaths.cpp: -------------------------------------------------------------------------------- 1 | //username DishaKhanapurkar 2 | 3 | 4 | class Solution { 5 | public: 6 | long long int numberOfPaths(int m, int n){ 7 | // code here 8 | vectorans(n,1); 9 | for(int i=1;i 2 | long int multiplyNumbers(int n); 3 | int main() 4 | { 5 | int n; 6 | printf("Enter a positive integer: "); 7 | scanf("%d",&n); 8 | printf("Factorial of %d = %ld", n, multiplyNumbers(n)); 9 | return 0; 10 | } 11 | 12 | long int multiplyNumbers(int n) 13 | { 14 | if (n>=1) 15 | return n*multiplyNumbers(n-1); 16 | else 17 | return 1; 18 | } 19 | -------------------------------------------------------------------------------- /fibonacci series: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int n, t1 = 0, t2 = 1, nextTerm = 0; 6 | 7 | cout << "Enter the number of terms: "; 8 | cin >> n; 9 | 10 | cout << "Fibonacci Series: "; 11 | 12 | for (int i = 1; i <= n; ++i) { 13 | // Prints the first two terms. 14 | if(i == 1) { 15 | cout << t1 << ", "; 16 | continue; 17 | } 18 | if(i == 2) { 19 | cout << t2 << ", "; 20 | continue; 21 | } 22 | nextTerm = t1 + t2; 23 | t1 = t2; 24 | t2 = nextTerm; 25 | 26 | cout << nextTerm << ", "; 27 | } 28 | return 0; 29 | } 30 | -------------------------------------------------------------------------------- /fibonaccirecursion.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void fibonacci(int n) 4 | { 5 | static int n1=0,n2=1,n3; 6 | if(n>0) 7 | { 8 | n3=n1+n2; 9 | n1=n2; 10 | n2=n3; 11 | printf("%d ",n3); 12 | fibonacci(n-1); 13 | } 14 | } 15 | 16 | int main() 17 | { 18 | int n, n1=0,n2=1; 19 | printf("Enter the last digit\n"); 20 | scanf("%d", &n); 21 | printf("Fibonacci Series\n"); 22 | printf("%d %d ", n1, n2); 23 | fibonacci(n-2); 24 | return 0; 25 | } 26 | -------------------------------------------------------------------------------- /findAllDuplicates.java: -------------------------------------------------------------------------------- 1 | import java.util.ArrayList; 2 | import java.util.Arrays; 3 | import java.util.List; 4 | 5 | public class findAllDuplicates { 6 | public static void main(String[] args) { 7 | int[] arr = {1, 3, 2, 8, 4, 7, 6, 5, 4, 2, 8}; 8 | System.out.println(cycle(arr)); 9 | } 10 | 11 | public static List cycle(int[] arr) { 12 | List list = new ArrayList<>(); 13 | int i = 0; 14 | while (i < arr.length) { 15 | int correct = arr[i] - 1; 16 | if (arr[i] != arr[correct]) { 17 | swap(arr, i, correct); 18 | } else i++; 19 | } 20 | for (int j = 0; j < arr.length; j++) { 21 | if (arr[j] != j + 1) { 22 | list.add(arr[j]); 23 | } 24 | } 25 | return list; 26 | } 27 | 28 | public static void swap(int[] arr, int first, int second) { 29 | int temp = arr[first]; 30 | arr[first] = arr[second]; 31 | arr[second] = temp; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /guiCalculator.java: -------------------------------------------------------------------------------- 1 | // Java program to create a simple calculator 2 | // with basic +, -, /, * using java swing elements 3 | 4 | import java.awt.event.*; 5 | import javax.swing.*; 6 | import java.awt.*; 7 | class calculator extends JFrame implements ActionListener { 8 | // create a frame 9 | static JFrame f; 10 | 11 | // create a textfield 12 | static JTextField l; 13 | 14 | // store operator and operands 15 | String s0, s1, s2; 16 | 17 | // default constructor 18 | calculator() 19 | { 20 | s0 = s1 = s2 = ""; 21 | } 22 | 23 | // main function 24 | public static void main(String args[]) 25 | { 26 | // create a frame 27 | f = new JFrame("calculator"); 28 | 29 | try { 30 | // set look and feel 31 | UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); 32 | } 33 | catch (Exception e) { 34 | System.err.println(e.getMessage()); 35 | } 36 | 37 | // create a object of class 38 | calculator c = new calculator(); 39 | 40 | // create a textfield 41 | l = new JTextField(16); 42 | 43 | // set the textfield to non editable 44 | l.setEditable(false); 45 | 46 | // create number buttons and some operators 47 | JButton b0, b1, b2, b3, b4, b5, b6, b7, b8, b9, ba, bs, bd, bm, be, beq, beq1; 48 | 49 | // create number buttons 50 | b0 = new JButton("0"); 51 | b1 = new JButton("1"); 52 | b2 = new JButton("2"); 53 | b3 = new JButton("3"); 54 | b4 = new JButton("4"); 55 | b5 = new JButton("5"); 56 | b6 = new JButton("6"); 57 | b7 = new JButton("7"); 58 | b8 = new JButton("8"); 59 | b9 = new JButton("9"); 60 | 61 | // equals button 62 | beq1 = new JButton("="); 63 | 64 | // create operator buttons 65 | ba = new JButton("+"); 66 | bs = new JButton("-"); 67 | bd = new JButton("/"); 68 | bm = new JButton("*"); 69 | beq = new JButton("C"); 70 | 71 | // create . button 72 | be = new JButton("."); 73 | 74 | // create a panel 75 | JPanel p = new JPanel(); 76 | 77 | // add action listeners 78 | bm.addActionListener(c); 79 | bd.addActionListener(c); 80 | bs.addActionListener(c); 81 | ba.addActionListener(c); 82 | b9.addActionListener(c); 83 | b8.addActionListener(c); 84 | b7.addActionListener(c); 85 | b6.addActionListener(c); 86 | b5.addActionListener(c); 87 | b4.addActionListener(c); 88 | b3.addActionListener(c); 89 | b2.addActionListener(c); 90 | b1.addActionListener(c); 91 | b0.addActionListener(c); 92 | be.addActionListener(c); 93 | beq.addActionListener(c); 94 | beq1.addActionListener(c); 95 | 96 | // add elements to panel 97 | p.add(l); 98 | p.add(ba); 99 | p.add(b1); 100 | p.add(b2); 101 | p.add(b3); 102 | p.add(bs); 103 | p.add(b4); 104 | p.add(b5); 105 | p.add(b6); 106 | p.add(bm); 107 | p.add(b7); 108 | p.add(b8); 109 | p.add(b9); 110 | p.add(bd); 111 | p.add(be); 112 | p.add(b0); 113 | p.add(beq); 114 | p.add(beq1); 115 | 116 | // set Background of panel 117 | p.setBackground(Color.blue); 118 | 119 | // add panel to frame 120 | f.add(p); 121 | 122 | f.setSize(200, 220); 123 | f.show(); 124 | } 125 | public void actionPerformed(ActionEvent e) 126 | { 127 | String s = e.getActionCommand(); 128 | 129 | // if the value is a number 130 | if ((s.charAt(0) >= '0' && s.charAt(0) <= '9') || s.charAt(0) == '.') { 131 | // if operand is present then add to second no 132 | if (!s1.equals("")) 133 | s2 = s2 + s; 134 | else 135 | s0 = s0 + s; 136 | 137 | // set the value of text 138 | l.setText(s0 + s1 + s2); 139 | } 140 | else if (s.charAt(0) == 'C') { 141 | // clear the one letter 142 | s0 = s1 = s2 = ""; 143 | 144 | // set the value of text 145 | l.setText(s0 + s1 + s2); 146 | } 147 | else if (s.charAt(0) == '=') { 148 | 149 | double te; 150 | 151 | // store the value in 1st 152 | if (s1.equals("+")) 153 | te = (Double.parseDouble(s0) + Double.parseDouble(s2)); 154 | else if (s1.equals("-")) 155 | te = (Double.parseDouble(s0) - Double.parseDouble(s2)); 156 | else if (s1.equals("/")) 157 | te = (Double.parseDouble(s0) / Double.parseDouble(s2)); 158 | else 159 | te = (Double.parseDouble(s0) * Double.parseDouble(s2)); 160 | 161 | // set the value of text 162 | l.setText(s0 + s1 + s2 + "=" + te); 163 | 164 | // convert it to string 165 | s0 = Double.toString(te); 166 | 167 | s1 = s2 = ""; 168 | } 169 | else { 170 | // if there was no operand 171 | if (s1.equals("") || s2.equals("")) 172 | s1 = s; 173 | // else evaluate 174 | else { 175 | double te; 176 | 177 | // store the value in 1st 178 | if (s1.equals("+")) 179 | te = (Double.parseDouble(s0) + Double.parseDouble(s2)); 180 | else if (s1.equals("-")) 181 | te = (Double.parseDouble(s0) - Double.parseDouble(s2)); 182 | else if (s1.equals("/")) 183 | te = (Double.parseDouble(s0) / Double.parseDouble(s2)); 184 | else 185 | te = (Double.parseDouble(s0) * Double.parseDouble(s2)); 186 | 187 | // convert it to string 188 | s0 = Double.toString(te); 189 | 190 | // place the operator 191 | s1 = s; 192 | 193 | // make the operand blank 194 | s2 = ""; 195 | } 196 | 197 | // set the value of text 198 | l.setText(s0 + s1 + s2); 199 | } 200 | } 201 | } 202 | -------------------------------------------------------------------------------- /hamiltonprob.java: -------------------------------------------------------------------------------- 1 | //username DishaKhanapurkar 2 | class Solution 3 | { 4 | public static int[][] printAdjacency(int n, int m, int[][] edges) { 5 | 6 | // n - > number of nodes 7 | // m - > number of edges 8 | // adjacence list of type - for node 0 - the list is 1 ,4 5, 6 and not 0 , 1 , 4 ,5,6 9 | int[][] adjlist = new int[n][]; 10 | ArrayList[] arraylist = new ArrayList[n]; 11 | 12 | for (int i = 0; i < n; i++) { 13 | arraylist[i] = new ArrayList(); 14 | } 15 | for (int i = 0; i < m; i++) { 16 | arraylist[edges[i][0]].add(edges[i][1]); 17 | arraylist[edges[i][1]].add(edges[i][0]); 18 | } 19 | 20 | for (int i = 0; i < n; i++) { 21 | int temp[] = new int[arraylist[i].size()]; 22 | //temp[0] = i; 23 | 24 | arraylist[i].sort(Comparator.naturalOrder()); 25 | for (int j = 0; j < arraylist[i].size(); j++) { 26 | temp[j] = arraylist[i].get(j); 27 | } 28 | 29 | adjlist[i] = temp; 30 | } 31 | 32 | return adjlist; 33 | } 34 | boolean meth(int N, int cur, int[][] adjlist, boolean[] visited, int count) { 35 | visited[cur] = true; 36 | count++; 37 | 38 | if (N == count) { 39 | return true; 40 | } 41 | for (int i = 0; i < adjlist[cur].length; i++) { 42 | if (!visited[adjlist[cur][i]]) { 43 | 44 | 45 | if (meth(N, adjlist[cur][i], adjlist, visited, count)) { 46 | 47 | return true; 48 | } 49 | } 50 | } 51 | visited[cur] = false; 52 | 53 | 54 | return false; 55 | 56 | } 57 | 58 | 59 | boolean check(int N, int M, ArrayList> Edges) 60 | { 61 | 62 | // code here 63 | int count = 0; 64 | boolean[] visited = new boolean[N + 1]; 65 | 66 | int[][] edges = new int[Edges.size()][]; 67 | for (int i = 0; i < Edges.size(); i++) { 68 | int[] temp = new int[Edges.get(i).size()]; 69 | for (int j = 0; j < Edges.get(i).size(); j++) { 70 | temp[j] = Edges.get(i).get(j); 71 | } 72 | edges[i] = temp; 73 | } 74 | int[][] adjlist = printAdjacency(N + 1, M, edges); 75 | 76 | for (int i = 1; i <= N; i++) { 77 | if (meth(N , i, adjlist, visited, count)) return true; 78 | 79 | } 80 | 81 | 82 | return false; 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /hellloworld.c: -------------------------------------------------------------------------------- 1 | // Header file for input output functions 2 | #include 3 | 4 | // main function - 5 | int main() 6 | { 7 | 8 | // prints hello world 9 | printf("Hello World"); 10 | 11 | return 0; 12 | } -------------------------------------------------------------------------------- /hello.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | fmt.Println("Hello World") 7 | } 8 | -------------------------------------------------------------------------------- /hello.java: -------------------------------------------------------------------------------- 1 | public class Greeting { 2 | public static void main(String[] args) { 3 | greeting(); 4 | } 5 | static void greeting() { 6 | System.out.println("Hello There! "); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /hello_world_shubham.md: -------------------------------------------------------------------------------- 1 | Location: GHAZIABAD 2 | 3 | Academics: UNDERGRAD. [DTU] 4 | 5 | Interests: FOOTBALL 6 | 7 | Some Things You Like:Development 8 | 9 | [SHUBHAM RANJAN](GitHub Link: https://github.com/shubhamranjan0206) -------------------------------------------------------------------------------- /img_show.cpp: -------------------------------------------------------------------------------- 1 | // C++ program for the above approach 2 | #include 3 | #include 4 | using namespace cv; 5 | using namespace std; 6 | 7 | // Driver code 8 | int main(int argc, char** argv) 9 | { 10 | // Read the image file as 11 | // imread("default.jpg"); 12 | Mat image = imread("Enter the Address" 13 | "of Input Image", 14 | IMREAD_GRAYSCALE); 15 | 16 | // Error Handling 17 | if (image.empty()) { 18 | cout << "Image File " 19 | << "Not Found" << endl; 20 | 21 | // wait for any key press 22 | cin.get(); 23 | return -1; 24 | } 25 | 26 | // Show Image inside a window with 27 | // the name provided 28 | imshow("Window Name", image); 29 | 30 | // Wait for any keystroke 31 | waitKey(0); 32 | return 0; 33 | } 34 | -------------------------------------------------------------------------------- /import_turtle.md: -------------------------------------------------------------------------------- 1 | from turtle import * 2 | # or 3 | import turtle 4 | After importing the turtle library and making all the turtle functionalities available to us, we need to create a new drawing board(window) and a turtle. Let’s call the window as wn and the turtle as skk. So we code as: 5 | 6 | wn = turtle.Screen() 7 | wn.bgcolor("light green") 8 | wn.title("Turtle") 9 | skk = turtle.Turtle() 10 | Now that we have created the window and the turtle, we need to move the turtle. To move forward 100 pixels in the direction skk is facing, we code: 11 | 12 | skk.forward(100) 13 | We have moved skk 100 pixels forward, Awesome! Now we complete the program with the done() function and We’re done! 14 | 15 | turtle.done() 16 | So, we have created a program that draws a line 100 pixels long. We can draw various shapes and fill different colors using turtle methods. There’s plethora of functions and programs to be coded using the turtle library in python. Let’s learn to draw some of the basic shapes. 17 | 18 | Shape 1: Square 19 | 20 | 21 | # Python program to draw square 22 | # using Turtle Programming 23 | import turtle 24 | skk = turtle.Turtle() 25 | 26 | for i in range(4): 27 | skk.forward(50) 28 | skk.right(90) 29 | 30 | turtle.done() 31 | Output: 32 | 33 | ![image](https://user-images.githubusercontent.com/84392923/194618574-40363e1c-972b-407b-b023-258af2dc5764.png) 34 | -------------------------------------------------------------------------------- /iplmatch.java: -------------------------------------------------------------------------------- 1 | //username : DishaKhanapurkar 2 | class Solution 3 | { 4 | public int findOccurrence(char mat[][], String target) 5 | { 6 | 7 | int n=mat.length; 8 | int m=mat[0].length; 9 | 10 | int count=0; 11 | for(int i=0;i=mat.length||j>=mat[0].length||i<0||j<0||mat[i][j]=='*'||target.charAt(ind)!=mat[i][j]) 28 | return 0; 29 | 30 | 31 | if(ind==target.length()-1) 32 | return 1; 33 | 34 | 35 | 36 | 37 | 38 | char temp=mat[i][j]; 39 | mat[i][j]='*'; 40 | 41 | int u=dfs(mat,target,i+1,j,ind+1); 42 | int d=dfs(mat,target,i-1,j,ind+1); 43 | int r=dfs(mat,target,i,j+1,ind+1); 44 | int l=dfs(mat,target,i,j-1,ind+1); 45 | mat[i][j]=temp; 46 | 47 | 48 | return u+d+r+l; 49 | 50 | 51 | 52 | 53 | 54 | }} 55 | -------------------------------------------------------------------------------- /maths.cpp: -------------------------------------------------------------------------------- 1 | # include 2 | int main(){ 3 | int a,b,c ; 4 | 5 | scanf("%d",&a); 6 | scanf("%d",&b); 7 | scanf("%d",&c); 8 | 9 | printf("answer is %d \n ",a-b+c) ; 10 | 11 | } -------------------------------------------------------------------------------- /minchara.java: -------------------------------------------------------------------------------- 1 | class Solution { 2 | 3 | public static int minChar(String str) { 4 | int c=0; 5 | 6 | int low=0; 7 | 8 | int high = str.length()-1; 9 | 10 | while(low=mat.length||j>=mat[0].length||i<0||j<0||mat[i][j]=='*'||target.charAt(ind)!=mat[i][j]) 28 | return 0; 29 | 30 | 31 | if(ind==target.length()-1) 32 | return 1; 33 | 34 | 35 | 36 | 37 | 38 | char temp=mat[i][j]; 39 | mat[i][j]='*'; 40 | 41 | int u=dfs(mat,target,i+1,j,ind+1); 42 | int d=dfs(mat,target,i-1,j,ind+1); 43 | int r=dfs(mat,target,i,j+1,ind+1); 44 | int l=dfs(mat,target,i,j-1,ind+1); 45 | mat[i][j]=temp; 46 | 47 | 48 | return u+d+r+l; 49 | 50 | 51 | 52 | 53 | 54 | }} 55 | -------------------------------------------------------------------------------- /printArray.java: -------------------------------------------------------------------------------- 1 | public class printArray{ 2 | public static void main(String[] args) { 3 | String[] arr = { "BMW", "Toyota", "Mercedes Benz", "Daihatsu" }; 4 | for (int i = 0; i < arr.length; i++) { 5 | System.out.println((i + 1) + ". Car Brand : " + arr[i]); 6 | } 7 | } 8 | } -------------------------------------------------------------------------------- /quickSort.cpp: -------------------------------------------------------------------------------- 1 | //TUSHAR PANJETA 2 | //Quicksort with two pivots 3 | #include 4 | #define size 100 5 | using namespace std; 6 | 7 | class QuickSort 8 | { 9 | public : 10 | 11 | int array[size] , n , leftpivot , rightpivot; 12 | 13 | void createArray(); 14 | 15 | void DualPivotQuickSort(int low, int high); 16 | 17 | void partition(int low, int high); 18 | 19 | }; 20 | 21 | void QuickSort::createArray() 22 | { 23 | cout<<"\nEnter no. of elements in array : "; 24 | cin>>n; 25 | while(n<=0) 26 | { 27 | cout<<"\n[ERROR] Invalid input , TRY AGAIN"; 28 | cout<<"\nEnter no. of elements in array : "; 29 | cin>>n; 30 | } 31 | 32 | cout<<"\nEnter the "<>array[i]; 36 | } 37 | } 38 | 39 | void QuickSort::DualPivotQuickSort(int low, int high) 40 | { 41 | if (low < high) 42 | { 43 | partition(low, high);//provide left and right pivots 44 | DualPivotQuickSort(low, leftpivot - 1); 45 | DualPivotQuickSort(leftpivot + 1, rightpivot - 1); 46 | DualPivotQuickSort(rightpivot + 1, high); 47 | } 48 | } 49 | 50 | void QuickSort::partition(int low, int high) 51 | { 52 | if(array[low] > array[high])//checking that left pivot is greater than right pivot if yes than swap them 53 | { 54 | swap(array[low], array[high]); 55 | } 56 | 57 | int j = low + 1, g = high - 1, k = low + 1, leftpiv = array[low], rightpiv = array[high]; 58 | while (k <= g) 59 | { 60 | if (array[k] < leftpiv) // if elements are less than the left pivot 61 | { 62 | swap(array[k], array[j]); 63 | j++; 64 | } 65 | 66 | else if (array[k] >= rightpiv) // if elements are greater than or equal to right pivot 67 | { 68 | while (array[g] > rightpiv && k < g) 69 | { 70 | g--; 71 | } 72 | 73 | swap(array[k], array[g]); 74 | g--; 75 | 76 | if (array[k] < leftpiv) //checking after swaping that if element is less than left pivot 77 | { 78 | swap(array[k], array[j]); 79 | j++; 80 | } 81 | } 82 | k++; 83 | } 84 | j--; 85 | g++; 86 | 87 | // bring pivots to their appropriate positions. 88 | swap(array[low], array[j]); 89 | swap(array[high], array[g]); 90 | 91 | leftpivot = j; 92 | rightpivot = g; 93 | } 94 | 95 | int main() 96 | { 97 | QuickSort q1; 98 | 99 | q1.createArray(); 100 | q1.DualPivotQuickSort(0,q1.n-1); 101 | 102 | cout<<"\nSorted array : "; 103 | for(int i=0 ; i findLeastGreater(int n, int[] arr) { 4 | // code here 5 | TreeSet set = new TreeSet<>(); 6 | 7 | ArrayList ans = new ArrayList<>(); 8 | 9 | for(int i = n-1; i>=0;i--){ 10 | 11 | set.add(arr[i]); 12 | 13 | if(set.higher(arr[i])==null) ans.add(-1); 14 | 15 | else{ 16 | 17 | ans.add(set.higher(arr[i])); 18 | 19 | } 20 | 21 | } 22 | 23 | Collections.reverse(ans); 24 | 25 | return ans; 26 | 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /rockpaperscissor.py: -------------------------------------------------------------------------------- 1 | import random 2 | 3 | player1 = input("Select Rock, Paper, or Scissor :").lower() 4 | player2 = random.choice(["Rock", "Paper", "Scissor"]).lower() 5 | print("Player 2 selected: ", player2) 6 | 7 | if player1 == "rock" and player2 == "paper": 8 | print("Player 2 Won") 9 | elif player1 == "paper" and player2 == "scissor": 10 | print("Player 2 Won") 11 | elif player1 == "scissor" and player2 == "rock": 12 | print("Player 2 Won") 13 | elif player1 == player2: 14 | print("Tie") 15 | else: 16 | print("Player 1 Won") -------------------------------------------------------------------------------- /set_operations.py: -------------------------------------------------------------------------------- 1 | ls = [] 2 | elements = 0 3 | while(1): 4 | print("a.Create Empty Set \nb.Insert \nc.Delete \nd.Search \ne.Print \nf.Union \ng.Intersection \nh.Set Difference \ni.Symmetric Difference \nj.Exit") 5 | print("Enter your choice: ") 6 | c = input() 7 | if (c == 'a'): 8 | s = set() 9 | ls.append(s) 10 | print(f"Set number of new set is: {elements}") 11 | elements += 1 12 | elif(c == 'b'): 13 | print(f"Enter the set number less than {elements} to insert Elemnts: ") 14 | setnum = int(input()) 15 | if(setnum >= 0 and setnum < elements): 16 | print("Enter the elements of the set to insert: ") 17 | ele = set(input().strip().split()) 18 | ls[setnum].update(ele) 19 | print(ls[setnum]) 20 | else: 21 | print("Invalid set number") 22 | elif(c == 'c'): 23 | print(f"Enter the set number less than {elements} to delete Elemnts: ") 24 | setnum = int(input()) 25 | if(setnum >= 0 and setnum < elements): 26 | print("Enter the Element you want to delete from the set:") 27 | ele = input() 28 | if ele in ls[setnum]: 29 | ls[setnum].discard(ele) 30 | print("Element is successfully deleted.") 31 | else: 32 | print("Element is not in set.") 33 | else: 34 | print("Invalid set number") 35 | elif(c == 'd'): 36 | print(f"Enter the set number less than {elements} to search Elemnts: ") 37 | setnum = int(input()) 38 | if(setnum >= 0 and setnum < elements): 39 | print(f"Enter the element to search in set: ") 40 | ele = input() 41 | if ele in ls[setnum]: 42 | print("Element found.") 43 | else: 44 | print("Element not found.") 45 | else: 46 | print("Invalid set number") 47 | elif(c == 'e'): 48 | print(f"Enter the set number less than {elements} to print Elemnts: ") 49 | setnum = int(input()) 50 | if(setnum >= 0 and setnum < elements): 51 | print(ls[setnum]) 52 | else: 53 | print("Invalid set number") 54 | elif(c == 'f'): 55 | print(f"Enter the 1st set number less than {elements} for union: ") 56 | setnum = int(input()) 57 | print(f"Enter the 2nd set number less than {elements} for union: ") 58 | setnum2 = int(input()) 59 | if(setnum >= 0 and setnum < elements and setnum2 >= 0 and setnum2 < elements): 60 | s = ls[setnum].union(ls[setnum2]) 61 | ls.append(s) 62 | print(s) 63 | print("Union set is added to list.") 64 | elements += 1 65 | else: 66 | print("Invalid set number") 67 | elif(c == 'g'): 68 | print( 69 | f"Enter the 1st set number less than {elements} for Intersection: ") 70 | setnum = int(input()) 71 | print( 72 | f"Enter the 2nd set number less than {elements} for Intersection: ") 73 | setnum2 = int(input()) 74 | if(setnum >= 0 and setnum < elements and setnum2 >= 0 and setnum2 < elements): 75 | s = ls[setnum].intersection(ls[setnum2]) 76 | ls.append(s) 77 | print(s) 78 | print("Intersection set is added to list.") 79 | elements += 1 80 | else: 81 | print("Invalid set number") 82 | elif(c == 'h'): 83 | print( 84 | f"Enter the 1st set number less than {elements} for Set_difference: ") 85 | setnum = int(input()) 86 | print( 87 | f"Enter the 2nd set number less than {elements} for Set_difference: ") 88 | setnum2 = int(input()) 89 | if(setnum >= 0 and setnum < elements and setnum2 >= 0 and setnum2 < elements): 90 | s = ls[setnum].difference(ls[setnum2]) 91 | ls.append(s) 92 | print(s) 93 | print("Set_difference set is added to list.") 94 | elements += 1 95 | else: 96 | print("Invalid set number") 97 | elif(c == 'i'): 98 | print( 99 | f"Enter the 1st set number less than {elements} for Symmetric_difference: ") 100 | setnum = int(input()) 101 | print( 102 | f"Enter the 2nd set number less than {elements} for Symmetric_difference: ") 103 | setnum2 = int(input()) 104 | if(setnum >= 0 and setnum < elements and setnum2 >= 0 and setnum2 < elements): 105 | s = ls[setnum].symmetric_difference(ls[setnum2]) 106 | ls.append(s) 107 | print(s) 108 | print("Symmetric_difference set is added to list.") 109 | elements += 1 110 | else: 111 | print("Invalid set number") 112 | elif(c == 'j'): 113 | break 114 | else: 115 | print("Invalid input") 116 | -------------------------------------------------------------------------------- /snakeWaterGunGame.js: -------------------------------------------------------------------------------- 1 | const prompt=require("prompt-sync")({sigint:true}); 2 | const character ='SWG'; 3 | 4 | function SWG(){ 5 | return character[Math.floor(Math.random()*3)]; 6 | } 7 | let rounds=parseInt(prompt("Enter no of rounds you want to play : ")) 8 | console.log("===SNAKE WATER GUN==="); 9 | console.log("Enter S for Snake | W for Water | G for Gun"); 10 | let userPoints=0 , computerPoints=0; 11 | while(rounds) 12 | { 13 | user=prompt("Enter your choice : "); 14 | 15 | computer=SWG(); 16 | console.log("computer ->"+computer); 17 | 18 | if(user=="S"||user=="s" && computer=="W" ) 19 | { 20 | console.log("You win this round"); 21 | userPoints++; 22 | } 23 | else if(user=="G"||user=="g" && computer=="W") 24 | { 25 | console.log("You loss this round"); 26 | computerPoints++; 27 | } 28 | else if(user=="W"||user=="w" && computer=="S") 29 | { 30 | console.log("You loss this round"); 31 | computerPoints++; 32 | } 33 | else if(user=="W"||user=="w" && computer=="G") 34 | { 35 | console.log("You win this round"); 36 | userPoints++; 37 | } 38 | else if(user=="S"||user=="s" && computer=="G") 39 | { 40 | console.log("You loss this round"); 41 | computerPoints++; 42 | } 43 | else if(user=="G"||user=="g" && computer=="S") 44 | { 45 | console.log("You win this round"); 46 | userPoints++; 47 | } 48 | else 49 | { 50 | console.log("Round tie"); 51 | } 52 | rounds--; 53 | 54 | 55 | } 56 | if(userPoints>computerPoints) 57 | { 58 | console.log("\nYOU WIN 🎉🎉") 59 | } 60 | else if(computerPoints>userPoints) 61 | { 62 | console.log("\nYOU LOSS 😭") 63 | } 64 | else 65 | { 66 | console.log("\nGAME TIE 😑") 67 | } 68 | -------------------------------------------------------------------------------- /spriallmatrix.cpp: -------------------------------------------------------------------------------- 1 | //username DishaKhanapurkar 2 | class Solution { 3 | public: 4 | vector spiralOrder(vector>& matrix) { 5 | int m = matrix.size(); 6 | int n = matrix[0].size(); 7 | 8 | int top = 0, down = m-1; 9 | int left = 0, right = n-1; 10 | int dir = 0; 11 | vector ans; 12 | 13 | 14 | while(top <= down and left <= right){ 15 | if(dir==0){ 16 | for(int i=left; i<=right; i++){ 17 | ans.push_back(matrix[top][i]); 18 | } 19 | top += 1; 20 | } 21 | else if(dir==1){ 22 | for(int i=top; i<=down; i++){ 23 | ans.push_back(matrix[i][right]); 24 | } 25 | right -= 1; 26 | } 27 | else if(dir==2){ 28 | for(int i=right; i>=left; i--){ 29 | ans.push_back(matrix[down][i]); 30 | } 31 | down -= 1; 32 | } 33 | else{ 34 | for(int i=down; i>=top; i--){ 35 | ans.push_back(matrix[i][left]); 36 | } 37 | left += 1; 38 | } 39 | dir = (dir+1)%4; 40 | } 41 | 42 | return ans; 43 | } 44 | }; 45 | -------------------------------------------------------------------------------- /sum.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | int main(){ 3 | int n; 4 | printf("enter number \n"); 5 | scanf("%d",&n); 6 | 7 | 8 | 9 | //numbers in reverse order and their sum. 10 | int sum =0; 11 | for(int i=1,j=n;i<=n&&j>=1; i++,j--){ 12 | sum=sum + i; 13 | printf("%d \n",j); 14 | } 15 | 16 | printf("sum is %d \n",sum); 17 | 18 | 19 | 20 | 21 | 22 | 23 | } -------------------------------------------------------------------------------- /thanks.py: -------------------------------------------------------------------------------- 1 | public class LinkedList { 2 | public static class Node{ 3 | int data; 4 | Node next; 5 | 6 | public Node(int data){ 7 | this.data = data; 8 | this.next = null; 9 | } 10 | } 11 | 12 | public static Node head; 13 | public static Node tail; 14 | public static int size; 15 | 16 | public void addFirst(int data){ 17 | Node newNode = new Node(data); 18 | size++; 19 | if(head == null){ 20 | head = tail = newNode; 21 | return; 22 | } 23 | 24 | newNode.next = head; 25 | head = newNode; 26 | } 27 | 28 | public void addLast(int data){ 29 | Node newNode = new Node(data); 30 | size++; 31 | if(head == null){ 32 | head = tail = newNode; 33 | return; 34 | } 35 | 36 | tail.next = newNode; 37 | 38 | tail = newNode; 39 | } 40 | 41 | public void addMidd(int idx, int data) { 42 | if(idx == 0){ 43 | addFirst(data); 44 | return; 45 | } 46 | Node newNode = new Node(data); 47 | size++; 48 | Node temp = head; 49 | int i = 0; 50 | while (i < idx) { 51 | temp = temp.next; 52 | i++; 53 | } 54 | 55 | newNode.next = temp.next; 56 | temp.next = newNode; 57 | } 58 | 59 | public int removeFirst() { 60 | if(head == null){ 61 | System.out.println("LL is empty"); 62 | return Integer.MIN_VALUE; 63 | } 64 | 65 | int val = head.data; 66 | size--; 67 | if(head == tail){ 68 | head = tail = null; 69 | return val; 70 | } 71 | head = head.next; 72 | return val; 73 | } 74 | 75 | public int removeLast() { 76 | if(head == null){ 77 | System.out.println("LL is empty"); 78 | return Integer.MIN_VALUE; 79 | } 80 | 81 | int val = head.data; 82 | size--; 83 | if(head == tail){ 84 | head = tail = null; 85 | 86 | return val; 87 | } 88 | Node prev = head; 89 | 90 | while(prev.next!=tail){ 91 | prev = prev.next; 92 | } 93 | val = prev.next.data; 94 | prev.next = tail; 95 | tail = prev; 96 | 97 | return val; 98 | } 99 | 100 | public void print() { 101 | Node temp = head; 102 | 103 | while (temp!=null) { 104 | System.out.print(temp.data + "->"); 105 | temp = temp.next; 106 | } 107 | System.out.print("null"); 108 | System.out.println(); 109 | } 110 | 111 | // Searching In linked list 112 | 113 | public int itrSearch(int key) { 114 | if(head == null){ 115 | return -1; 116 | } 117 | 118 | int i = 0; 119 | Node temp = head; 120 | 121 | while(temp!=null){ 122 | if(temp.data == key) 123 | return i; 124 | i++; 125 | temp = temp.next; 126 | } 127 | 128 | return -1; 129 | } 130 | 131 | // Searching Using recursion 132 | 133 | // public int recSearch(int key, Node start) { 134 | 135 | // } 136 | 137 | public static void main(String[] args) { 138 | LinkedList ll = new LinkedList(); 139 | 140 | ll.addFirst(1); 141 | ll.print(); 142 | ll.addLast(2); 143 | ll.print(); 144 | ll.addLast(4); 145 | ll.print(); 146 | ll.addMidd(2, 3); 147 | ll.print(); 148 | } 149 | } 150 | -------------------------------------------------------------------------------- /turtle.py: -------------------------------------------------------------------------------- 1 | # Python program to draw star 2 | # using Turtle Programming 3 | import turtle 4 | star = turtle.Turtle() 5 | 6 | star.right(75) 7 | star.forward(100) 8 | 9 | for i in range(4): 10 | star.right(144) 11 | star.forward(100) 12 | 13 | turtle.done() 14 | -------------------------------------------------------------------------------- /turtle_pattern.py: -------------------------------------------------------------------------------- 1 | # Python program to draw 2 | # Spiral Helix Pattern 3 | # using Turtle Programming 4 | 5 | import turtle 6 | loadWindow = turtle.Screen() 7 | turtle.speed(2) 8 | 9 | for i in range(100): 10 | turtle.circle(5*i) 11 | turtle.circle(-5*i) 12 | turtle.left(i) 13 | 14 | turtle.exitonclick() 15 | -------------------------------------------------------------------------------- /tweepy.md: -------------------------------------------------------------------------------- 1 | Tweepy supports accessing Twitter via Basic Authentication and the newer method, OAuth. Twitter has stopped accepting Basic Authentication so OAuth is now the only way to use the Twitter API. 2 | --------------------------------------------------------------------------------