├── PROJECT REPORT.docx ├── PO3.cpp ├── PO1.cpp └── PO2.cpp /PROJECT REPORT.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Mustafa-Hassan2001/Discrete-Structures-Programming-Project-/HEAD/PROJECT REPORT.docx -------------------------------------------------------------------------------- /PO3.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | //Function of conjunction 4 | void conjunction(int arr1[],int arr2[]){ 5 | int i; 6 | cout<<"[ "; 7 | for(i=0;i<4;i++){ 8 | if(arr1[i]==1 && arr2[i]==1){ //conjunction logic 9 | cout<<"1 , "; 10 | }else{ 11 | cout<<"0 , "; 12 | }} 13 | cout<<" ]"<>size; 70 | cout<<"Enter the elements of array p:"<>p[index]; 73 | 74 | } 75 | cout<<"Enter the size of array q:"; 76 | cin>>size; 77 | cout<<"Enter the elements of array q:"<>p[index]; 80 | } 81 | do{ 82 | system("cls"); 83 | cout<>choice; 88 | system("cls"); 89 | if(choice==1){ 90 | cout< 2 | using namespace std; 3 | //Function for symmatric 4 | void symmatric(){ 5 | int A[10][10], i, j, m, n, x = 0, y = 0; 6 | cout << "Enter the number of rows and columns : "; 7 | cin >> m >> n; 8 | cout << "Enter the matrix elements : "; 9 | for (i = 0; i < m; i++) 10 | for (j = 0; j < n; j++) 11 | cin >> A[i][j]; 12 | for (i = 0; i < m; i++){ 13 | for( j = 0; j < n; j++){ //symmatric logic 14 | if (A[i][j] != A[j][i]) 15 | x = 1; 16 | else if (A[i][j] == -A[j][i]) 17 | y = 1; 18 | }} 19 | if (x == 0) 20 | cout << "The matrix is symmetric.\n "; 21 | else if (x == 1) 22 | cout << "The matrix is Anti-symmetric.\n "; 23 | for (i = 0; i < m; i++){ 24 | for (j = 0; j < n; j++) 25 | cout << A[i][j] << " "; 26 | cout << "\n "; 27 | }} 28 | 29 | // Function for reflexive 30 | void reflexi(){ 31 | int A[10][10], i, j, m, n, x = 0, y = 0; 32 | cout << "Enter the number of rows and columns : "; 33 | cin >> m >> n; 34 | cout << "Enter the matrix elements : "; 35 | for (i = 0; i < m; i++) 36 | for (j = 0; j < n; j++) 37 | cin >> A[i][j]; 38 | for (i = 0; i < m; i++){ 39 | for( j = 0; j < n; j++){ //reflexive logic 40 | if(i==j & A[i][j] != 1){ 41 | x=1; 42 | }} 43 | } 44 | if(x==0) 45 | cout<<"\nMatrix is reflexive.\n"; 46 | if(x==1) 47 | cout<<"\nMatrix is irreflexive.\n"; 48 | for (i = 0; i < m; i++) 49 | { 50 | for (j = 0; j < n; j++) 51 | cout << A[i][j] << " "; 52 | cout << "\n "; 53 | } 54 | } 55 | 56 | //Function for Transitive 57 | void Transitive(){ 58 | int A[10][10], i, j, m, n, x = 0, y = 0; 59 | bool check=true; 60 | cout << "Enter the number of rows and columns : "; 61 | cin >> m >> n; 62 | cout << "Enter the matrix elements : "; 63 | for (i = 0; i < m; i++) 64 | for (j = 0; j < n; j++) 65 | cin >> A[i][j]; 66 | 67 | for(int i=0;iSymmatric\n2->reflexive\n3->Transitive\n4->Exit\n"; 95 | cout<<"Enter your choice : "; 96 | cin>>ch; 97 | system("cls"); 98 | if(ch==1) 99 | symmatric(); 100 | if(ch==2) 101 | reflexi(); 102 | if(ch==3) 103 | Transitive(); 104 | if(ch==4){ 105 | cout<<"\nYour are exit form this program"; 106 | } 107 | }while(ch!=4); 108 | 109 | return 0; 110 | } 111 | 112 | -------------------------------------------------------------------------------- /PO2.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | //Function for Union 5 | void Union(int arr1[], int arr2[], int len1, int len2) { 6 | int f, i, j, k = 0; 7 | int arr3[100]; 8 | for (i = 0; i < len1; i++) { 9 | arr3[k] = arr1[i]; 10 | k++; 11 | } 12 | for (i = 0; i < len2; i++) { //Union logic in this for loop 13 | f = 0; 14 | for (j = 0; j < len1; j++) { 15 | if (arr2[i] == arr1[j]) { 16 | f = 1; 17 | }} 18 | if (f == 0) { 19 | arr3[k] = arr2[i]; 20 | k++; 21 | } } 22 | cout << "Union of two array is:"; 23 | for (i = 0; i < k; i++) { 24 | cout << arr3[i] << " "; 25 | } 26 | } 27 | 28 | //Function for Intersection 29 | void Intersection(int arr1[], int arr2[], int len1, int len2) { 30 | int arr3[100]; 31 | int i, j, k = 0; 32 | for (i = 0; i < len1; i++) { //Intersection logic 33 | for (j = 0; j < len2; j++) { 34 | if (arr1[i] == arr2[j]) { 35 | arr3[k] = arr1[i]; 36 | k++; 37 | } 38 | } 39 | } 40 | cout << "\nIntersection of two array is:"; 41 | for (i = 0; i < k; i++) { 42 | cout << arr3[i] << " "; 43 | } 44 | } 45 | 46 | //Funnctiom fro A-B 47 | void diference(int a[10],int b[10], int n1, int n2){ 48 | int c[10],d[10],m=0,k=0,l,i,j; 49 | for( i=0;i>len1; 107 | 108 | cout << "Enter 1st array elements:"; 109 | for (i = 0; i < len1; i++) { 110 | cin >> arr1[i]; 111 | } 112 | cout << "Enter size of 2nd array:"; 113 | cin>>len2; 114 | 115 | cout << "Enter 2nd array elements:"; 116 | for (i = 0; i < len2; i++) { 117 | cin >> arr2[i]; 118 | } 119 | system("cls"); 120 | do{ 121 | //main menu 122 | cout<<"\n\n1->Union\n2->Intersection\n3->A-B\n4->A+B\n5->Exit"<>ch; 125 | if(ch==1){ 126 | // system("cls"); 127 | Union(arr1, arr2, len1, len2);} 128 | if(ch==2){ 129 | // system("cls"); 130 | Intersection(arr1, arr2, len1, len2); 131 | } 132 | if(ch==3){ 133 | // system("cls"); 134 | diference(arr1, arr2, len1, len2); 135 | } 136 | if(ch==4){ 137 | // system("cls"); 138 | last(arr1, arr2, len1, len2); 139 | } 140 | if(ch==5){ 141 | cout<<"\n\nYou are exit to this program.."; 142 | exit(0); 143 | } 144 | }while(ch!=5); 145 | 146 | } 147 | 148 | int main() { 149 | get(); 150 | return 0; 151 | } 152 | 153 | --------------------------------------------------------------------------------