├── .vscode ├── c_cpp_properties.json ├── settings.json └── tasks.json ├── lect1 └── index.c ├── lect10 ├── hello └── hello.c ├── lect11 ├── hello └── hello.c ├── lect12 ├── hello └── hello.c ├── lect13 └── hello.c ├── lect14 ├── hello └── hello.c ├── lect15 ├── hello └── hello.c ├── lect16 └── hello.c ├── lect17 ├── hello ├── hello.c └── tempCodeRunnerFile.c ├── lect18 ├── hello └── hello.c ├── lect19 ├── hello └── hello.c ├── lect2 ├── hello ├── hello.c └── hello.dSYM │ └── Contents │ ├── Info.plist │ └── Resources │ ├── DWARF │ └── hello │ └── Relocations │ └── aarch64 │ └── hello.yml ├── lect20 ├── hello ├── hello.c └── tempCodeRunnerFile.c ├── lect21 ├── hello └── hello.c ├── lect22 ├── hello └── hello.c ├── lect24 ├── hello └── hello.c ├── lect25 ├── hello └── hello.c ├── lect3 ├── hello ├── hello.c ├── hello.dSYM │ └── Contents │ │ ├── Info.plist │ │ └── Resources │ │ ├── DWARF │ │ └── hello │ │ └── Relocations │ │ └── aarch64 │ │ └── hello.yml ├── index └── index.dSYM │ └── Contents │ ├── Info.plist │ └── Resources │ ├── DWARF │ └── index │ └── Relocations │ └── aarch64 │ └── index.yml ├── lect4 ├── hello └── hello.c ├── lect5 ├── hello └── hello.c ├── lect6 ├── hello └── hello.c ├── lect7 ├── hello └── hello.c ├── lect8 ├── hello └── hello.c └── lect9 ├── hello └── hello.c /.vscode/c_cpp_properties.json: -------------------------------------------------------------------------------- 1 | { 2 | "configurations": [ 3 | { 4 | "name": "Mac", 5 | "includePath": [ 6 | "${workspaceFolder}/**" 7 | ], 8 | "defines": [], 9 | "compilerPath": "/usr/bin/clang", 10 | "cStandard": "c17", 11 | "cppStandard": "c++17", 12 | "intelliSenseMode": "macos-clang-arm64" 13 | } 14 | ], 15 | "version": 4 16 | } -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "files.associations": { 3 | "*.html": "html", 4 | "stdio.h": "c" 5 | } 6 | } -------------------------------------------------------------------------------- /.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | "tasks": [ 3 | { 4 | "type": "cppbuild", 5 | "label": "C/C++: clang build active file", 6 | "command": "/usr/bin/clang", 7 | "args": [ 8 | "-fcolor-diagnostics", 9 | "-fansi-escape-codes", 10 | "-g", 11 | "${file}", 12 | "-o", 13 | "${fileDirname}/${fileBasenameNoExtension}" 14 | ], 15 | "options": { 16 | "cwd": "${fileDirname}" 17 | }, 18 | "problemMatcher": [ 19 | "$gcc" 20 | ], 21 | "group": { 22 | "kind": "build", 23 | "isDefault": true 24 | }, 25 | "detail": "Task generated by Debugger." 26 | } 27 | ], 28 | "version": "2.0.0" 29 | } -------------------------------------------------------------------------------- /lect1/index.c: -------------------------------------------------------------------------------- 1 | #include // Header file (standard input-output) 2 | 3 | int main() { 4 | // Variable create karna 5 | int age = 20; // integer variable (sirf numbers store karega) 6 | float pi = 3.14; // decimal value ke liye 7 | char grade = 'A'; // ek single character ke liye 8 | 9 | // Print karna 10 | printf("Hello Students!\n"); // simple text print 11 | printf("Age = %d\n", age); // %d integer ke liye 12 | printf("Pi = %f\n", pi); // %f float ke liye 13 | printf("Grade = %c\n", grade); // %c character ke liye 14 | 15 | return 0; 16 | } 17 | -------------------------------------------------------------------------------- /lect10/hello: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rupesh155/3rd_SemG/ab5c5429a2fa1f2471462149ecd3ab8f897ed517/lect10/hello -------------------------------------------------------------------------------- /lect10/hello.c: -------------------------------------------------------------------------------- 1 | // #include 2 | 3 | 4 | // int main(){ 5 | // int n=5; 6 | // for(int i=1;i<=n;i++){ 7 | // for(int j=1;j<=n;j++){ 8 | // // printf("*"); 9 | // if(i==1 || i==n || j==1 || j==n){ 10 | // printf("*"); 11 | // }else{ 12 | // printf(" "); 13 | // } 14 | // } 15 | // printf("\n"); 16 | // } 17 | 18 | 19 | // } 20 | 21 | 22 | #include 23 | 24 | int main() { 25 | int n = 3; // 3x3 magic square 26 | int magic[3][3] = {0}; 27 | 28 | int i = 0, j = n / 2; // start position: first row, middle column 29 | 30 | for (int num = 1; num <= n * n; num++) { 31 | magic[i][j] = num; // number place karo 32 | 33 | // next position calculate karo 34 | int newi = (i - 1 + n) % n; // upar jao (wrap around) 35 | int newj = (j + 1) % n; // right jao (wrap around) 36 | 37 | if (magic[newi][newj] != 0) { 38 | // agar already filled hai to neeche jao 39 | i = (i + 1) % n; 40 | } else { 41 | i = newi; 42 | j = newj; 43 | } 44 | } 45 | 46 | // print magic square 47 | printf("Magic Square of size 3:\n"); 48 | for (int r = 0; r < n; r++) { 49 | for (int c = 0; c < n; c++) { 50 | printf("%3d ", magic[r][c]); 51 | } 52 | printf("\n"); 53 | } 54 | 55 | return 0; 56 | } 57 | 58 | 59 | // for(int i=0;i<4;i++){ 60 | // for(int j=0;j<=i;j++){ 61 | // printf("*"); 62 | // } 63 | 64 | // for(int k=3;k>i;k--){ 65 | // printf(" "); 66 | // } 67 | // for(int k=3;k>i;k--){ 68 | // printf(" "); 69 | // } 70 | // for(int p=0;p<=i;p++){ 71 | // printf("*"); 72 | // } 73 | // printf("\n"); 74 | 75 | 76 | 77 | // } 78 | 79 | 80 | // for(int i=0;i<4;i++){ 81 | // for(int j=3;j>i;j--){ 82 | // printf("*"); 83 | // } 84 | // for(int k=0;k<=i;k++){ 85 | // printf(" "); 86 | // } 87 | // for(int k=0;k<=i;k++){ 88 | // printf(" "); 89 | // } 90 | // for(int j=3;j>i;j--){ 91 | // printf("*"); 92 | // } 93 | // printf("\n"); 94 | 95 | // } 96 | 97 | 98 | 99 | // } 100 | /*int a,b=0,c; 101 | printf("Enter Number to check:"); 102 | scanf("%d",&a); 103 | if(a==1){ 104 | printf("Not prime"); 105 | } 106 | else{} 107 | for(int i=2; i0;n=n/10) 138 | // { 139 | // int ld= n%10; 140 | // int num=10*ld; 141 | // } 142 | 143 | // (n==b)?printf("is palindrome"):printf("not"); 144 | 145 | // } 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | // int n=5; 154 | // for(int i =1;i<=n;i++){ 155 | // for(int j=1;j<=n;j++){ 156 | // // printf("*"); 157 | // if(i==1 || i==n || j==1|| j==n){ 158 | // printf("*"); 159 | // }else{ 160 | // printf(" "); 161 | // } 162 | // } 163 | // printf("\n"); 164 | // } 165 | // } 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | // int main(){ 175 | // for(int i =0;i<4;i++){ 176 | // for(int j=0;j<=i;j++){ 177 | // printf("*"); 178 | // } 179 | // for(int k=3;k>i;k--){ 180 | // printf(" "); 181 | // } 182 | // for(int p=3;p>i;p--){ 183 | // printf(" "); 184 | // } 185 | // for(int z=0;z<=i;z++){ 186 | // printf("*"); 187 | // } 188 | // printf("\n"); 189 | // } 190 | 191 | // for(int i=0;i<4;i++){ 192 | // for(int j=3;j>i;j--){ 193 | // printf("*"); 194 | // } 195 | // for(int k=0;k<=i;k++){ 196 | // printf(" "); 197 | // } 198 | // for(int k=0;k<=i;k++){ 199 | // printf(" "); 200 | // } 201 | // for(int j=3;j>i;j--){ 202 | // printf("*"); 203 | // } 204 | // printf("\n"); 205 | 206 | // } 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | -------------------------------------------------------------------------------- /lect11/hello: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rupesh155/3rd_SemG/ab5c5429a2fa1f2471462149ecd3ab8f897ed517/lect11/hello -------------------------------------------------------------------------------- /lect11/hello.c: -------------------------------------------------------------------------------- 1 | // #include 2 | // void odd_even( ){ 3 | // // if(a%2==0){ 4 | // // printf("even"); 5 | // // }else{ 6 | // // printf("oddd"); 7 | // // } 8 | // printf("hello"); 9 | // return 10 10 | 11 | // } 12 | // // int sum(){ 13 | // // int a=5; 14 | // // int b=5; 15 | // // printf("%d",a+b); 16 | // // } 17 | // int main(){ 18 | // // int a; 19 | // // scanf("%d",&a); 20 | // // odd_even(a); 21 | // // odd_even(a); 22 | // // odd_even(); 23 | // odd_even(); 24 | 25 | // return 0; 26 | // // printf("hello"); 27 | 28 | 29 | // } 30 | 31 | 32 | // /or(int i=0;i<=4;i++){ 33 | // for(int j=0;j<=4;j++){ 34 | // if(i==j|| j==(4-i)){ 35 | // printf("*"); 36 | // }else{ 37 | // printf(" "); 38 | // } 39 | // }printf("\n"); 40 | // } 41 | 42 | // #include 43 | // int sum(){ 44 | // int a=5; 45 | // int b=10; 46 | // int c=a+b; 47 | // return c; 48 | // // printf("%d",a+b); 49 | // } 50 | // int main(){ 51 | // int data= sum(); 52 | // printf("%d",data); 53 | 54 | // } 55 | 56 | 57 | // //1234 => 1+2+3+4=10=> 1+0=1 58 | 59 | // #include 60 | 61 | // int sum(a){ 62 | // // if(a%2==0){ 63 | // // printf("even"); 64 | // // }else{ 65 | // // printf("oddd"); 66 | // // } 67 | 68 | 69 | // // printf("hello"); 70 | // // return 0; 71 | // // printf("hiiii"); 72 | // // int a=5; 73 | // // int b=10; 74 | // // int c=a+b; 75 | // // printf("%d",c); 76 | // } 77 | 78 | // int main(){ 79 | // int a; 80 | // scanf("%d",&a); 81 | 82 | // sum(a); 83 | 84 | 85 | 86 | 87 | // } 88 | 89 | // // for(int i 90 | // // =0;i<=4;i++){ 91 | // // for(int j=0;j<=4;j++){ 92 | // // // printf("*"); 93 | // // if(i==j || j==(4-i)){ 94 | // // printf("*"); 95 | // // }else{ 96 | // // printf(" "); 97 | // // } 98 | // }printf("\n"); 99 | // } 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | // #include 108 | // int sum(){ 109 | 110 | // // int a=5; 111 | // // int b=10; 112 | // // int c=a+b; 113 | // // return c; 114 | // // } 115 | // // int main(){ 116 | // // int data= sum(); 117 | // // printf("%d",data); 118 | 119 | // } 120 | 121 | 122 | 123 | // 1234=> 1+2+3+4=10=> 1+0=1 124 | // 12345 125 | 126 | 127 | // #include 128 | // int main() { 129 | // int arr[5] = {1, 2, 3, 4, 5}; 130 | // int n = sizeof(arr) / sizeof(arr[0]); 131 | 132 | // for (int i = 0; i < n; i++) { 133 | // // printf("%d ", arr[i]); 134 | // } 135 | 136 | // return 0; 137 | // } 138 | 139 | 140 | 141 | 142 | 143 | 144 | -------------------------------------------------------------------------------- /lect12/hello: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rupesh155/3rd_SemG/ab5c5429a2fa1f2471462149ecd3ab8f897ed517/lect12/hello -------------------------------------------------------------------------------- /lect12/hello.c: -------------------------------------------------------------------------------- 1 | // #include 2 | // int main(){ 3 | // // int a=100; 4 | // // int b=101; 5 | // int arr[5]={1}; 6 | // int max=arr[0]; 7 | // for(int i=0;i<4;i++){ 8 | // if(arr[i]>max){ 9 | // max=arr[i]; 10 | // } 11 | 12 | // } 13 | // printf("%d",max); 14 | // // printf("%d",arr[45]); 15 | // // for(int i=2;i>=0;i--){ 16 | // // printf("%d",arr[i]); 17 | // // } 18 | 19 | // } 20 | 21 | // int a=5 22 | 23 | 24 | #include 25 | 26 | int main(){ 27 | 28 | int arr[5]={3,12,52,34,5}; 29 | int target=3; 30 | for(int i =0;i<5;i++){ 31 | if(arr[i]==target){ 32 | printf("%d",arr[i]); 33 | break; 34 | } 35 | } 36 | 37 | // int max =arr[0]; 38 | // int a=5; 39 | // for(int i=1;i<5;i++){ 40 | // if(arr[i]>max){ 41 | // max=arr[i]; 42 | // } 43 | // } 44 | 45 | // int a=101; 46 | // int b=102; 47 | // int c=103 48 | // int arr[5]={1,1,3,4,5}; 49 | // int sum=0; 50 | // for(int i =0;i<5;i++){ 51 | // sum= sum+arr[i]; 52 | 53 | // } 54 | 55 | 56 | // for(int i=4;i>=0;i--){ 57 | // printf("%d",arr[i]); 58 | // } 59 | 60 | // printf("%d",arr[1]); 61 | 62 | 63 | } 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | -------------------------------------------------------------------------------- /lect13/hello.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main(){ 3 | int arr[5]={-10,20,30,-40,50}; 4 | int f=arr[0]; 5 | for(int i =0;i<5;i++){ 6 | arr[i]=arr[i+1]; 7 | } 8 | arr[4]=f; 9 | 10 | 11 | // int check=1; 12 | // for(int i =0;i<5/2;i++){ 13 | // if(arr[i]!=arr[5-1-i]){ 14 | // check=0; 15 | // break; 16 | // } 17 | // } 18 | // if(check==1){ 19 | // printf("haiiii"); 20 | 21 | // }else 22 | // { 23 | // printf("aisa kuch bhi nhi hai "); 24 | // } 25 | 26 | 27 | 28 | // int k=7; 29 | // for(int i=0;i<7;i++){ 30 | // for(int j=i+1;j<7;j++){ 31 | // if(arr[i]+ arr[j]==k){ 32 | // printf("%d %d",i,j); 33 | // break; 34 | // } 35 | // } 36 | // } 37 | 38 | 39 | 40 | } 41 | 42 | 43 | -------------------------------------------------------------------------------- /lect14/hello: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rupesh155/3rd_SemG/ab5c5429a2fa1f2471462149ecd3ab8f897ed517/lect14/hello -------------------------------------------------------------------------------- /lect14/hello.c: -------------------------------------------------------------------------------- 1 | // // i66 2 | 3 | // // [1,2,3,45,6,89,-6] 4 | // // k=4 5 | 6 | // #include 7 | // #include 8 | 9 | // int maxArraySum(int arr[] ,int n,int k){ 10 | // int wSum=0; 11 | // // int arr[7]={-1,2,4,5,4,3,7}; 12 | // for( int i=0;imaxSum){ 19 | // maxSum=wSum; 20 | // } 21 | // } 22 | // return maxSum; 23 | 24 | // // int maxSum=INT_MIN; 25 | // // // int arr[7]={-1,2,4,5,-4,3,-7}; 26 | // // for(int i=0;i<=n-k;i++){ 27 | // // int currSum=0; 28 | // // for(int j=i;jmaxSum){ 33 | // // maxSum=currSum; 34 | // // } 35 | // // } 36 | // // return maxSum; 37 | 38 | 39 | // } 40 | // int main(){ 41 | // int arr[7]={-1,2,4,5,4,3,7}; 42 | // int k=3; 43 | // int n= sizeof(arr)/sizeof(arr[0]); 44 | // int data= maxArraySum(arr,n,k); 45 | // printf("%d",data); 46 | 47 | 48 | 49 | // } 50 | 51 | 52 | // // int arr[7]={1,2,4,5,4,3,7}; 53 | // // int k=3 54 | 55 | #include 56 | 57 | int main(){ 58 | int arr[7]={1,2,3,5,6,5,4}; 59 | int k=3; 60 | int n= sizeof(arr)/sizeof(arr[0]); 61 | int windowSum=0; 62 | for(int i=0;imaxSum){ 71 | maxSum=windowSum; 72 | } 73 | 74 | } 75 | printf("%d",maxSum); 76 | 77 | // int maxSum=0; 78 | 79 | // for(int i=0;imaxSum){ 86 | // maxSum=currSum; 87 | // } 88 | // } 89 | // printf("%d",maxSum); 90 | 91 | // // for(int i) 92 | // // int target=5; 93 | 94 | 95 | 96 | 97 | 98 | // for(int i=0;i<5;i++){ 99 | // for(int j=i+1;j<5;j++){ 100 | // if(arr[i] +arr[j]==target){ 101 | 102 | // } 103 | // } 104 | // } 105 | // for(int i=0;i<5;i++){ 106 | // if(arr[i]==target){ 107 | // printf("%d",i); 108 | // break; 109 | // } 110 | // } 111 | 112 | 113 | 114 | 115 | } 116 | 117 | 118 | // {1,2,3,4,5,9} 119 | // k=3 120 | 121 | 122 | 123 | 124 | // {1,2,4} 1+2+4=7 125 | 126 | // 1+2+3+4=10-7=3 127 | // 360 => 101=> 102 128 | 129 | 130 | 131 | // {1,2,3,3,2,1} 132 | 133 | // { } 134 | 135 | 136 | 137 | -------------------------------------------------------------------------------- /lect15/hello: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rupesh155/3rd_SemG/ab5c5429a2fa1f2471462149ecd3ab8f897ed517/lect15/hello -------------------------------------------------------------------------------- /lect15/hello.c: -------------------------------------------------------------------------------- 1 | // // [10,20,30,40,50]=> [20,30,40,50,10] 2 | // #include 3 | // #include 4 | 5 | // int main(){ 6 | // int arr[6]={0,5,-5,3,-4,-5,-7}; 7 | // int maxSum=INT_MIN; 8 | 9 | // for(int i=0;i<6;i++){ 10 | // int currSum=0; 11 | // for(int j=i;j<6;j++){ 12 | // currSum=currSum+arr[j]; 13 | // if(currSum>maxSum){ 14 | // maxSum=currSum; 15 | // } 16 | // } 17 | 18 | // } 19 | // printf("%d",maxSum); 20 | // } 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | // int arr[5]={1,2,3,2,2}; 31 | // int isTrue=1; 32 | // for(int i=0;i<5/2;i++){ 33 | // if(arr[i]!=arr[5-i-1]){ 34 | // isTrue=0; 35 | // } 36 | // } 37 | // if(isTrue==1){ 38 | // printf("haiii"); 39 | // }else{ 40 | // printf("nhi haiiii"); 41 | 42 | // int arr[5]={10,20,30,40,50}; 43 | // int first=arr[0]; 44 | // for(int i =0;i<5;i++){ 45 | // arr[i]=arr[i+1]; 46 | // } 47 | // arr[4]=first; 48 | 49 | 50 | // for(int k=0;k<5;k++){ 51 | // printf("%d",arr[k]); 52 | 53 | // } 54 | 55 | 56 | 57 | 58 | 59 | #include 60 | #include 61 | 62 | int BSearch(){ 63 | int arr[6]={1,2,3,4,5,6}; 64 | int target=11; 65 | int s=0; 66 | int end=5; 67 | while(s<=end) 68 | { 69 | int mid=(s+end)/2; 70 | if(arr[mid]==target){ 71 | return mid; 72 | // printf("%d",mid); 73 | } 74 | else if(arr[mid]maxSum){ 148 | // maxSum=currSum; 149 | // } 150 | // if(currSum<0){ 151 | // currSum=0; 152 | // } 153 | // } 154 | 155 | 156 | 157 | // for(int i=0;i<5;i++){ 158 | // int curSum=0; 159 | // for(int j=i;j<5;j++){ 160 | // curSum= curSum+arr[j]; 161 | // if(curSum>maxSum){ 162 | // maxSum=curSum; 163 | // } 164 | // } 165 | // } 166 | // printf("%d",maxSum); 167 | } 168 | // int a[3]={1,2,3} 169 | // int b[3]={4,5,6} 170 | // int c[6]=[1,2,3,4,5,6] 171 | 172 | // #include 173 | // using namespace std; 174 | // int main() 175 | // { 176 | // for(int i=0;i<5;i++) 177 | // { 178 | // cout<<" "; 179 | // } 180 | // for(int j=0;j>5;j--) 181 | // { 182 | // cout<<"*"; 183 | // } 184 | // return 0; 185 | // } -------------------------------------------------------------------------------- /lect16/hello.c: -------------------------------------------------------------------------------- 1 | 2 | 3 | // * * * * 4 | // * * * 5 | // * * 6 | // * 7 | } 8 | 9 | // int arr[5]={1,4,5,65,3}; 10 | // int n=sizeof(arr)/sizeof(int); 11 | // for(int i=0;iarr[j+1]){ 14 | // int temp=arr[j]; 15 | // arr[j]=arr[j+1]; 16 | // arr[j+1]=temp; 17 | // } 18 | 19 | // } 20 | // } 21 | 22 | // } 23 | -------------------------------------------------------------------------------- /lect17/hello: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rupesh155/3rd_SemG/ab5c5429a2fa1f2471462149ecd3ab8f897ed517/lect17/hello -------------------------------------------------------------------------------- /lect17/hello.c: -------------------------------------------------------------------------------- 1 | 2 | // // // { 2,4,1,6,5} 3 | 4 | // #include 5 | 6 | // int Bsearch(int arr[5]){ 7 | // int s=0; 8 | // int end=4; 9 | // int t=4; 10 | // while (s<=end) 11 | // { 12 | // int mid=(s+end)/2; 13 | // if(arr[mid]==t){ 14 | // return mid; 15 | // }else if(arr[mid]arr[j+1]){ 44 | // int temp=arr[j]; 45 | // arr[j]=arr[j+1]; 46 | // arr[j+1]=temp; 47 | // } 48 | // } 49 | // } 50 | 51 | // for(int k=0;k 68 | // int sum(int *a,int *b){ 69 | // *a=20; 70 | // *b=10; 71 | // int sum=(*a)+(*b); 72 | // return sum; 73 | 74 | // } 75 | // int main(){ 76 | // int a=5; 77 | // int b=10; 78 | // int data= sum(&a,&b); 79 | // printf("%d",data); 80 | // printf("%d",a+b); 81 | 82 | // // int x=5; 83 | // // int *a=&x; 84 | 85 | // // printf("%d",x); 86 | // // printf("%d",&x); 87 | // // printf("%d",a); 88 | // // printf("%d",*a); 89 | 90 | 91 | // } 92 | 93 | #include 94 | // int sum(int *x,int *y){ 95 | // *x=50; 96 | // *y=50; 97 | // int c=(*x)+(*y); 98 | // return c; 99 | // } 100 | 101 | // int swap(int *x,int *y){ 102 | // int temp=*x; 103 | // *x=*y; 104 | // *y=temp; 105 | // printf("%d %d" ,*x,*y); 106 | 107 | // } 108 | int main(){ 109 | 110 | // int n =-1; 111 | // for(int i=2;imaxsum) 130 | // maxsum=currentsum; 131 | // } 132 | 133 | 134 | // } 135 | // printf("%d",maxsum); 136 | // int x=10; 137 | // int y=20; 138 | // swap(&x,&y); 139 | 140 | // int arr[4]={1,2,3,4}; 141 | // int *p=arr; 142 | // // printf("%d",*(p+2)); 143 | // for(int i=0;i<4;i++){ 144 | // printf("%d",*(p+i)); 145 | // } 146 | 147 | 148 | // printf("%d",arr[i][j]); 149 | // }printf(" "); 150 | } 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | // int *p =&x; 160 | // int **k=&p; 161 | // int arr1[5]={1,2,3,4,5}; 162 | // int arr2[5]={1,2,3,4,5}; 163 | // int *p1=arr1; 164 | // int *p2=arr2; 165 | // int flag=1; 166 | // for(int i=0;i<5;i++){ 167 | // if(*(p1+i)!= *(p2+i)){ 168 | // flag=0; 169 | // break; 170 | // } 171 | // } 172 | // if(flag==1){ 173 | 174 | // } 175 | 176 | 177 | 178 | 179 | // printf() 180 | 181 | 182 | 183 | 184 | 185 | 186 | // int y=20; 187 | // swap(&x,&y); 188 | 189 | 190 | // int data= sum(&x,&y); 191 | 192 | // printf("%d",data); 193 | // printf("%d",x+y); 194 | 195 | 196 | // int arr[5]={1,2,3,45,6}; 197 | // int *p=arr; 198 | // printf("%d",*(p)); 199 | // printf("%d",*(p+1)); 200 | // printf("%d",*(p+2)); 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | // int a= &x; 209 | 210 | // printf("%d",a); 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | -------------------------------------------------------------------------------- /lect17/tempCodeRunnerFile.c: -------------------------------------------------------------------------------- 1 | printf("%d",data); -------------------------------------------------------------------------------- /lect18/hello: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rupesh155/3rd_SemG/ab5c5429a2fa1f2471462149ecd3ab8f897ed517/lect18/hello -------------------------------------------------------------------------------- /lect18/hello.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main(){ 3 | 4 | int arr[3][3]={{1,2,3},{4,5,6},{7,8,9} }; 5 | int arr1[9]; 6 | 7 | for(int i=0;i<3;i++){ 8 | for(int j=0;j<3;j++){ 9 | 10 | if(i==j){ 11 | printf("%d ",arr[i][j]); 12 | } 13 | } 14 | } 15 | // for(int i=0;i<3;i++){ 16 | // int sum=0; 17 | 18 | // for(int j=0;j<3;j++){ 19 | // sum=sum+arr[j][i]; 20 | // } 21 | // printf("%d ",sum); 22 | // } 23 | } -------------------------------------------------------------------------------- /lect19/hello: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rupesh155/3rd_SemG/ab5c5429a2fa1f2471462149ecd3ab8f897ed517/lect19/hello -------------------------------------------------------------------------------- /lect19/hello.c: -------------------------------------------------------------------------------- 1 | 2 | // #include 3 | 4 | // int main() 5 | // { 6 | // int arr[3][3] = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9} 7 | 8 | // }; 9 | 10 | // int t = 0, b = 2; 11 | // int left = 0, right = 2; 12 | 13 | // while (t <= b && left <= right) 14 | // { 15 | // for (int i = left; i <= right; i++) 16 | // { 17 | // printf("%d ", arr[t][i]); 18 | // } 19 | // t++; 20 | 21 | // for (int i = t; i <= b; i++) 22 | // printf("%d ", arr[i][right]); 23 | // right--; 24 | 25 | // for (int i = right; i >= left; i--) 26 | // printf("%d ", arr[b][i]); 27 | // b--; 28 | 29 | // for (int i = b; i >= t; i--) 30 | // printf("%d ", arr[i][left]); 31 | // left++; 32 | // } 33 | 34 | // return 0; 35 | // } 36 | 37 | 38 | // #include 39 | // int main(){ 40 | // int arr[3][3]={{1,2,3},{4,5,6},{7,8,9}}; 41 | // for(int i =0;i<3;i++){ 42 | // for(int j=0;j<3;j++){ 43 | // if(i==0 || i==2){ 44 | // printf("%d ",arr[i][j]); 45 | // }else if (j==3-i-1){ 46 | // printf("%d ",arr[i][j]); 47 | // }else{ 48 | // printf(" "); 49 | // } 50 | // }printf("\n"); 51 | // } 52 | // } 53 | 54 | #include 55 | int main(){ 56 | 57 | int arr[5]={1,-4,6,7,3}; 58 | int k=3; 59 | int wSum=0; 60 | for(int i=0;imaxSum){ 67 | maxSum=wSum; 68 | } 69 | } 70 | 71 | 72 | 73 | // git add . 74 | // git commit -m "msg" 75 | // git push 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | // int arr[2][2]={{1,2},{3,4}}; 85 | // int arr1[4]; 86 | // int k=0; 87 | // for(int i=0;i<2;i++){ 88 | // for(int j=0;j<2;j++){ 89 | // arr1[k]= arr[i][j]; 90 | // k++; 91 | // } 92 | // } 93 | // for(int i=0;i<4;i++){ 94 | // printf("%d",arr1[i]); 95 | // } 96 | 97 | 98 | 99 | 100 | 101 | 102 | // int arr[3][3]={{1,2,3},{4,5,6},{7,8,9}}; 103 | // for(int i =0;i<3;i++){ 104 | // for(int j=0;j<3;j++){ 105 | // if(i==0 || i==2){ 106 | // printf("%d ",arr[i][j]); 107 | // }else if( j==i){ 108 | // printf("%d ",arr[i][j]); 109 | // } 110 | // else 111 | // { 112 | // printf(" "); 113 | // } 114 | 115 | // }printf("\n"); 116 | // } 117 | 118 | } 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | -------------------------------------------------------------------------------- /lect2/hello: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rupesh155/3rd_SemG/ab5c5429a2fa1f2471462149ecd3ab8f897ed517/lect2/hello -------------------------------------------------------------------------------- /lect2/hello.c: -------------------------------------------------------------------------------- 1 | // Lecture 2 - C Programming 2 | // Topics: Variables, Operators, Type Casting, Increment-Decrement, If-Else 3 | // Author: Rupesh Kumar 4 | // Date: 26-Aug-2025 5 | 6 | #include 7 | 8 | int main() { 9 | 10 | // 1. Variables and Data Types 11 | int age = 20; // integer variable 12 | float pi = 3.14; // float variable 13 | char grade = 'A'; // character variable 14 | 15 | printf("Age = %d\n", age); 16 | printf("Pi = %.2f\n", pi); 17 | printf("Grade = %c\n\n", grade); 18 | 19 | // 2. Taking input from user 20 | int a; 21 | printf("Enter a number: "); 22 | scanf("%d", &a); 23 | printf("You entered: %d\n\n", a); 24 | 25 | // 3. Arithmetic Operators 26 | int x = 10, y = 3; 27 | printf("x + y = %d\n", x + y); // Addition 28 | printf("x - y = %d\n", x - y); // Subtraction 29 | printf("x * y = %d\n", x * y); // Multiplication 30 | printf("x / y = %d\n", x / y); // Division (integer) 31 | printf("x %% y = %d\n\n", x % y); // Modulus (remainder) 32 | 33 | // 4. Type Casting (to get decimal result in division) 34 | float result = (float)x / y; // explicit type casting 35 | printf("Type casted division: %.2f\n\n", result); 36 | 37 | // 5. Increment and Decrement 38 | int num = 5; 39 | printf("num = %d\n", num); 40 | printf("num++ = %d (post-increment)\n", num++); // print first, then increase 41 | printf("Now num = %d\n", num); 42 | printf("++num = %d (pre-increment)\n", ++num); // increase first, then print 43 | printf("Now num = %d\n\n", num); 44 | 45 | // 6. If-Else Example 46 | int marks = 73; 47 | if (marks >= 75) { 48 | printf("Grade: A\n"); 49 | } else if (marks >= 60) { 50 | printf("Grade: B\n"); 51 | } else { 52 | printf("Fail\n"); 53 | } 54 | 55 | // 7. sizeof operator 56 | printf("\nSize of int = %zu bytes\n", sizeof(int)); 57 | printf("Size of float = %zu bytes\n", sizeof(float)); 58 | printf("Size of char = %zu bytes\n\n", sizeof(char)); 59 | 60 | // 8. ASCII Example 61 | int ascii = 65; 62 | char ch = ascii; // converting int to char 63 | printf("ASCII value %d = character '%c'\n", ascii, ch); 64 | 65 | return 0; 66 | } 67 | 68 | 69 | 70 | // "helllo" 71 | 72 | // gcc hello.c -o hello && chmod +x hello && ./hello 73 | 74 | 75 | 76 | -------------------------------------------------------------------------------- /lect2/hello.dSYM/Contents/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleIdentifier 8 | com.apple.xcode.dsym.hello 9 | CFBundleInfoDictionaryVersion 10 | 6.0 11 | CFBundlePackageType 12 | dSYM 13 | CFBundleSignature 14 | ???? 15 | CFBundleShortVersionString 16 | 1.0 17 | CFBundleVersion 18 | 1 19 | 20 | 21 | -------------------------------------------------------------------------------- /lect2/hello.dSYM/Contents/Resources/DWARF/hello: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rupesh155/3rd_SemG/ab5c5429a2fa1f2471462149ecd3ab8f897ed517/lect2/hello.dSYM/Contents/Resources/DWARF/hello -------------------------------------------------------------------------------- /lect2/hello.dSYM/Contents/Resources/Relocations/aarch64/hello.yml: -------------------------------------------------------------------------------- 1 | --- 2 | triple: 'arm64-apple-darwin' 3 | binary-path: '/Users/rupesh/Downloads/C/lect2/hello' 4 | relocations: 5 | - { offsetInCU: 0x26, offset: 0x26, size: 0x8, addend: 0x0, symName: _main, symObjAddr: 0x0, symBinAddr: 0x100003A9C, symSize: 0x364 } 6 | - { offsetInCU: 0x48, offset: 0x48, size: 0x8, addend: 0x0, symName: _main, symObjAddr: 0x0, symBinAddr: 0x100003A9C, symSize: 0x364 } 7 | ... 8 | -------------------------------------------------------------------------------- /lect20/hello: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rupesh155/3rd_SemG/ab5c5429a2fa1f2471462149ecd3ab8f897ed517/lect20/hello -------------------------------------------------------------------------------- /lect20/hello.c: -------------------------------------------------------------------------------- 1 | 2 | 3 | // #include 4 | 5 | // int main() { 6 | // char name[] = "hiii"; // '\0' automatically add hota hai 7 | // printf("Name: %c", name[0]); 8 | // return 0; 9 | // } 10 | 11 | // #include 12 | // #include 13 | 14 | // int main() { 15 | // char name[] = "madam"; // 'h','i','i','\0' 16 | // int ln= strlen(name); 17 | // int isTrue=1; 18 | // for(int i=0;i 47 | 48 | // int main() { 49 | // char name[50];\0 50 | // printf("Enter your name: "); 51 | // scanf("%s", name); // space tak hi input leta hai 52 | // printf("You entered: %s\n", name); 53 | // return 0; 54 | // } 55 | 56 | // #include 57 | 58 | // int main() { 59 | // char name[50]; 60 | // printf("Enter your full name: "); 61 | // gets(name); // pure line le lega, space ke sath 62 | // printf("You entered: %s\n", name); 63 | // return 0; 64 | // } 65 | // String 66 | 67 | // #include 68 | // #include 69 | 70 | // int main() 71 | // { 72 | // char str[] = "hello"; 73 | // int freq[100]={0}; 74 | // int ln=strlen(str); 75 | // for(int i=0;i0){ 80 | // printf("%c: %d\n",i ,freq[i]); 81 | // } 82 | // } 83 | // int vCount=0; 84 | // int cCount=0; 85 | 86 | // for(int i=0;i 133 | // #include 134 | // int main(){ 135 | // char str[]="hello"; 136 | // int count; 137 | // int ln= strlen(str); 138 | // for(int i=0;i 160 | #include 161 | 162 | int main() 163 | { 164 | char str[] = "abc"; 165 | int freq[256] = {0}; 166 | int ln = strlen(str); 167 | 168 | for (int i = 0; i < ln; i++) { 169 | freq[str[i]]++; 170 | } 171 | 172 | for (int i = 0; i < 256; i++) { 173 | if (freq[i] > 0) { 174 | printf("%c: %d\n", i, freq[i]); 175 | } 176 | } 177 | 178 | return 0; 179 | } 180 | 181 | 182 | 183 | 184 | -------------------------------------------------------------------------------- /lect20/tempCodeRunnerFile.c: -------------------------------------------------------------------------------- 1 | i!=j && -------------------------------------------------------------------------------- /lect21/hello: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rupesh155/3rd_SemG/ab5c5429a2fa1f2471462149ecd3ab8f897ed517/lect21/hello -------------------------------------------------------------------------------- /lect21/hello.c: -------------------------------------------------------------------------------- 1 | // #include 2 | // #include 3 | // int main(){ 4 | // char str[]="hello"; 5 | // // char target='e'; 6 | // char newStr[100]; 7 | // int j=0; 8 | // int ln= strlen(str); 9 | 10 | // // for(int i=0;i0){ 36 | // // printf("%c: %d",i,freq[i]); 37 | // // } 38 | // // } 39 | // } -------------------------------------------------------------------------------- /lect22/hello: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rupesh155/3rd_SemG/ab5c5429a2fa1f2471462149ecd3ab8f897ed517/lect22/hello -------------------------------------------------------------------------------- /lect22/hello.c: -------------------------------------------------------------------------------- 1 | // #include 2 | // #include 3 | // int main(){ 4 | 5 | // char str[]="abc"; 6 | // int ln= strlen(str); 7 | // int freq[256]={0}; 8 | // for(int i=0;i 46 | #include 47 | int main(){ 48 | char str[]="bca"; 49 | int ln= strlen(str); 50 | 51 | for(int i=0;istr[j]){ 54 | char temp=str[i]; 55 | str[i]=str[j]; 56 | str[j]=temp; 57 | } 58 | } 59 | } 60 | printf("%s",str); 61 | // char subStr[]="abc"; 62 | // if(strstr(str,subStr)!=NULL){ 63 | // printf("true"); 64 | // }else{ 65 | // printf("false"); 66 | // } 67 | 68 | // target="abc" 69 | 70 | 71 | 72 | 73 | 74 | // int ln= strlen(str); 75 | // int freq[256]={0}; 76 | // char result; 77 | // int max=0; 78 | // for(int i=0;imax){ 83 | // max=freq[str[i]]; 84 | // result=str[i]; 85 | 86 | // } 87 | // } 88 | // printf("%c -> %d",result,max); 89 | 90 | 91 | } -------------------------------------------------------------------------------- /lect24/hello: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rupesh155/3rd_SemG/ab5c5429a2fa1f2471462149ecd3ab8f897ed517/lect24/hello -------------------------------------------------------------------------------- /lect24/hello.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | struct Addressss 5 | { 6 | int pinCode; 7 | }; 8 | 9 | struct Student { 10 | char name[50]; 11 | int RollNo; 12 | int age; 13 | struct Addressss s2; 14 | { 15 | /* data */ 16 | }; 17 | 18 | }; 19 | 20 | int main() { 21 | struct Student s1; 22 | 23 | s1.age = 15; 24 | s1.s2.pinCode=482001 25 | 26 | strcpy(s1.name,"hello"); 27 | 28 | // printf("Enter name: "); 29 | // scanf("%s", s1.name); 30 | 31 | printf("Age: %d\n", s1.age); 32 | printf("Name: %s\n", s1.name); 33 | 34 | return 0; 35 | } 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /lect25/hello: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rupesh155/3rd_SemG/ab5c5429a2fa1f2471462149ecd3ab8f897ed517/lect25/hello -------------------------------------------------------------------------------- /lect25/hello.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main(){ 3 | int letMax[6]; 4 | // int height[12]={0,1,0,2,1,0,1,3,2,1,2}; 5 | int height[6]= {4,2,0,3,2,5}; 6 | int rightMax[6]; 7 | int water=0; 8 | letMax[0]=height[0]; 9 | for(int i =1;i<6;i++){ 10 | if(height[i]>letMax[i-1]){ 11 | letMax[i]=height[i]; 12 | }else{ 13 | letMax[i]=letMax[i-1]; 14 | } 15 | } 16 | rightMax[5]=height[5]; 17 | for(int i =3;i>=0;i--){ 18 | if(height[i]>rightMax[i+1]){ 19 | rightMax[i]=height[i]; 20 | }else{ 21 | rightMax[i]=rightMax[i+1]; 22 | } 23 | } 24 | 25 | 26 | for(int i=0;i<6;i++){ 27 | int minHieght; 28 | if(letMax[i] 4 | // int main(){ 5 | 6 | // int a ; 7 | // scanf("%d",&a); 8 | // switch (a) 9 | // { 10 | // case 1: 11 | // printf("hello"); 12 | // break; 13 | 14 | // case 2: 15 | // printf("hiii"); 16 | // default: 17 | // printf("heheh"); 18 | // break; 19 | 20 | // } 21 | // return 0; 22 | // } 23 | -------------------------------------------------------------------------------- /lect3/hello.dSYM/Contents/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleIdentifier 8 | com.apple.xcode.dsym.hello 9 | CFBundleInfoDictionaryVersion 10 | 6.0 11 | CFBundlePackageType 12 | dSYM 13 | CFBundleSignature 14 | ???? 15 | CFBundleShortVersionString 16 | 1.0 17 | CFBundleVersion 18 | 1 19 | 20 | 21 | -------------------------------------------------------------------------------- /lect3/hello.dSYM/Contents/Resources/DWARF/hello: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rupesh155/3rd_SemG/ab5c5429a2fa1f2471462149ecd3ab8f897ed517/lect3/hello.dSYM/Contents/Resources/DWARF/hello -------------------------------------------------------------------------------- /lect3/hello.dSYM/Contents/Resources/Relocations/aarch64/hello.yml: -------------------------------------------------------------------------------- 1 | --- 2 | triple: 'arm64-apple-darwin' 3 | binary-path: '/Users/rupesh/Downloads/C/lect3/hello' 4 | relocations: 5 | - { offsetInCU: 0x26, offset: 0x26, size: 0x8, addend: 0x0, symName: _main, symObjAddr: 0x0, symBinAddr: 0x100003EF8, symSize: 0x88 } 6 | - { offsetInCU: 0x41, offset: 0x41, size: 0x8, addend: 0x0, symName: _main, symObjAddr: 0x0, symBinAddr: 0x100003EF8, symSize: 0x88 } 7 | ... 8 | -------------------------------------------------------------------------------- /lect3/index: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rupesh155/3rd_SemG/ab5c5429a2fa1f2471462149ecd3ab8f897ed517/lect3/index -------------------------------------------------------------------------------- /lect3/index.dSYM/Contents/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleIdentifier 8 | com.apple.xcode.dsym.index 9 | CFBundleInfoDictionaryVersion 10 | 6.0 11 | CFBundlePackageType 12 | dSYM 13 | CFBundleSignature 14 | ???? 15 | CFBundleShortVersionString 16 | 1.0 17 | CFBundleVersion 18 | 1 19 | 20 | 21 | -------------------------------------------------------------------------------- /lect3/index.dSYM/Contents/Resources/DWARF/index: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rupesh155/3rd_SemG/ab5c5429a2fa1f2471462149ecd3ab8f897ed517/lect3/index.dSYM/Contents/Resources/DWARF/index -------------------------------------------------------------------------------- /lect3/index.dSYM/Contents/Resources/Relocations/aarch64/index.yml: -------------------------------------------------------------------------------- 1 | --- 2 | triple: 'arm64-apple-darwin' 3 | binary-path: '/Users/rupesh/Downloads/C/lect3/index' 4 | relocations: 5 | - { offsetInCU: 0x26, offset: 0x26, size: 0x8, addend: 0x0, symName: _main, symObjAddr: 0x0, symBinAddr: 0x100003F30, symSize: 0x68 } 6 | - { offsetInCU: 0x41, offset: 0x41, size: 0x8, addend: 0x0, symName: _main, symObjAddr: 0x0, symBinAddr: 0x100003F30, symSize: 0x68 } 7 | ... 8 | -------------------------------------------------------------------------------- /lect4/hello: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rupesh155/3rd_SemG/ab5c5429a2fa1f2471462149ecd3ab8f897ed517/lect4/hello -------------------------------------------------------------------------------- /lect4/hello.c: -------------------------------------------------------------------------------- 1 | // #include 2 | 3 | // int main(){ 4 | 5 | // int amount; 6 | 7 | // printf("Enter a amount in indian .."); 8 | // scanf("%d",&amount); 9 | 10 | // char ch; 11 | // printf("which you want to convert"); 12 | // scanf("%c",&ch); 13 | 14 | // switch (ch) 15 | // { 16 | // case '$': 17 | // printf("%f",(float)amount/87); 18 | // break; 19 | 20 | // case '' 21 | 22 | // // 0.87 ==1/87 23 | 24 | // default: 25 | // break; 26 | // } 27 | 28 | // int a=4; 29 | // switch (a) 30 | // { 31 | // case 1: 32 | // printf("hello"); 33 | // break; 34 | // case 2: 35 | // printf("hiii"); 36 | // break; 37 | 38 | // default: 39 | // printf("kuch nhi mila"); 40 | // break; 41 | // } 42 | 43 | // a<5?printf("hello"):printf("hiii"); 44 | // int a=5; 45 | 46 | // if(a<5){ 47 | // printf("hello"); 48 | // printf("byee"); 49 | // } 50 | // else 51 | // printf("hiii"); 52 | 53 | // int a; 54 | // int b; 55 | // char ch; 56 | // printf("Enter your choice"); 57 | // scanf("%d %d %c" ,&a,&b,&ch); 58 | // printf("%d %d %c", a,b,ch); 59 | // if(ch=='/'){ 60 | // if(b!=0){ 61 | // }else{ 62 | // printf("") 63 | // } 64 | // printf("%d",a/b); 65 | // } 66 | // } 67 | 68 | // int a=5; 69 | // int b=0 70 | 71 | #include 72 | 73 | int main() 74 | { 75 | // int a=1; 76 | int amt,bal=1000,ch; 77 | printf("\nChoices : "); 78 | printf("\n1.check balance "); 79 | printf("\n2.deposit"); 80 | printf("\n3.withdraw"); 81 | printf("\nEnter choice : "); 82 | scanf("%d",&ch); 83 | switch(ch) 84 | { 85 | case 1: printf("\nThe Balance : %d",bal); 86 | break; 87 | case 2 : printf("\nEnter amount : "); 88 | scanf("%d",&amt); 89 | bal+=amt; 90 | printf("\nCurrent Balance : %d",bal); 91 | break; 92 | case 3 : printf("\nEnter amount: "); 93 | scanf("%d",&amt); 94 | if(amt<=bal) 95 | { 96 | bal=bal-amt; 97 | printf("\nWithdrawl successful\n current Balance : %d",bal); 98 | 99 | } 100 | else 101 | { 102 | printf("\nInsufficient Amount !!"); 103 | } 104 | } 105 | 106 | // int amount; 107 | // // int b; 108 | // char s; 109 | // scanf("%d %c", &amount, &s); 110 | // switch (s) 111 | // { 112 | // case 'd': 113 | // printf() 114 | // if (b != 0) 115 | // printf("%f", (float)a / b); 116 | // else 117 | // printf(""); 118 | 119 | // break; 120 | case 'Y': 121 | printf(amount/12); 122 | break; 123 | 124 | default: 125 | printf("hehehe"); 126 | break; 127 | } 128 | } 129 | -------------------------------------------------------------------------------- /lect5/hello: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rupesh155/3rd_SemG/ab5c5429a2fa1f2471462149ecd3ab8f897ed517/lect5/hello -------------------------------------------------------------------------------- /lect5/hello.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | int main(){ 5 | 6 | int num=2456; 7 | int sum=0; 8 | while (num>0) 9 | { int lastDigit=num%10; 10 | sum=sum+lastDigit; 11 | num=num/10; 12 | 13 | } 14 | printf("%d",sum); 15 | 16 | 17 | // int i=0; 18 | // while (i<2) 19 | // { 20 | // printf("hello"); 21 | // i++; 22 | // } 23 | 24 | 25 | 26 | 27 | // int num=256; 28 | 29 | // printf("hello"); 30 | // printf("hello"); 31 | // printf("hello"); 32 | // printf("hello"); 33 | // for(int i =0;i<=5;i++){ 34 | // // printf("hello\n"); 35 | // printf("%d\n",i); 36 | // } 37 | // for(int i =10;i>0;i--){ 38 | // // printf("%d\n",i); 39 | // if(i%2==1){ 40 | // printf("%d\n",i); 41 | // } 42 | // } 43 | // int sum=0; 44 | // for(int i =1;i<=5;i++){ 45 | // sum=sum+i; 46 | // // sum+=i; 47 | 48 | 49 | // } 50 | // printf("%d\n",sum); 51 | 52 | // int i=0; 53 | // while (i<4) 54 | // { 55 | // printf("%d",i); 56 | // i++; 57 | // /* code */ 58 | // } 59 | // int num=123; 60 | // int sum=0; 61 | // while (num>0) 62 | // { 63 | // int lastDigit=num%10; 64 | // sum=sum+lastDigit; 65 | // num=num/10; 66 | // } 67 | // printf("%d",sum); 68 | // loop 69 | 70 | // printf("hello"); 71 | // printf("hello"); 72 | // printf("hello"); 73 | // int sum=0; 74 | // for(int i=1;i<5;i++){ 75 | // sum=sum+i; 76 | 77 | 78 | // printf("%d\n",i); 79 | 80 | // printf("hello\n"); 81 | // printf("%d\n",i*2); 82 | // if(i%2==1){ 83 | // printf("%d\n",i); 84 | // } 85 | 86 | } 87 | // printf("%d",sum); 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | -------------------------------------------------------------------------------- /lect6/hello: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rupesh155/3rd_SemG/ab5c5429a2fa1f2471462149ecd3ab8f897ed517/lect6/hello -------------------------------------------------------------------------------- /lect6/hello.c: -------------------------------------------------------------------------------- 1 | // #include 2 | // int main() 3 | // { 4 | // // int n = 6; 5 | // // int i; 6 | // // if (n <= 1) 7 | // // { 8 | // // printf("not prime\n"); 9 | // // } 10 | // // for (i = 2; i < n; i++) 11 | // // { 12 | // // if (n % i == 0) 13 | // // { 14 | // // printf("ye nhi haii\n"); 15 | // // } 16 | // // else 17 | // // { 18 | 19 | // // printf("primee haiiii"); 20 | // // } 21 | // // } 22 | 23 | // // int num; 24 | // // scanf("%d",&num); 25 | // // int original=num; 26 | // // int res=0; 27 | // // while (num!=0) 28 | // // { 29 | // // int lastDigit=num%10; 30 | // // res= res*10+ lastDigit; 31 | // // num=num/10; 32 | 33 | // // } 34 | // // if(original==res){ 35 | // // printf("p"); 36 | // // }else{ 37 | // // printf("not"); 38 | // // } 39 | 40 | // // int i , n , fact=1; 41 | // // printf("number:"); 42 | // // scanf("%d",&n); 43 | // // for (i=1;i<=n;i++) 44 | 45 | // // { 46 | // // fact=fact*i; 47 | // // } 48 | // // printf("Factorial=%d",fact); 49 | 50 | 51 | // // int num=121; 52 | // // int original=num; 53 | // // int res=0; 54 | // // while (num!=0) 55 | // // { 56 | // // int lastD= num%10; 57 | // // res= res*10+ lastD; 58 | // // num= num/10; 59 | 60 | // // } 61 | // // if(original==res){ 62 | // // printf("palindronnnnnnn"); 63 | // // }else{ 64 | // // printf("not "); 65 | // // } 66 | 67 | 68 | 69 | 70 | // for (int i = 1; i <= 5; i++) { 71 | // if (i == 3) break;; // i = 3 pe skip 72 | // printf("%d ", i); 73 | // } 74 | // for (int i = 1; i <= 5; i++) { 75 | // if (i == 3) continue;;; // i = 3 pe skip 76 | // printf("%d ", i); 77 | // } 78 | 79 | 80 | // } 81 | 82 | 83 | #include 84 | 85 | int main() { 86 | int n; 87 | printf("Enter a number: "); 88 | scanf("%d", &n); 89 | 90 | int candidate = n + 1; // input ke baad ka number se start 91 | 92 | while (1) { 93 | int isPrime = 1; // assume prime 94 | 95 | for (int i = 2; i * i <= candidate; i++) { 96 | if (candidate % i == 0) { 97 | isPrime = 0; // factor mil gaya 98 | break; 99 | } 100 | } 101 | 102 | if (isPrime) { 103 | printf("Next prime after %d is %d\n", n, candidate); 104 | break; // prime mil gaya → loop khatam 105 | } 106 | 107 | candidate++; // warna next number check karo 108 | } 109 | 110 | return 0; 111 | } 112 | -------------------------------------------------------------------------------- /lect7/hello: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rupesh155/3rd_SemG/ab5c5429a2fa1f2471462149ecd3ab8f897ed517/lect7/hello -------------------------------------------------------------------------------- /lect7/hello.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main(){ 3 | 4 | 5 | int n=234;//=> 2*3*4 6 | int count=0; 7 | if(n==0){ 8 | count=1; 9 | 10 | } 11 | while (n>0) 12 | { 13 | count++; 14 | n=n/10; 15 | 16 | } 17 | 18 | 19 | 20 | 21 | // 1 to 100 22 | 23 | 24 | 25 | 26 | // int n=123 => 3 27 | // 45666 28 | 29 | 30 | // 123 31 | 32 | // for(int i=0;i<=10;i++){ 33 | // // printf("%d",i); 34 | // if(i%2==0){ 35 | // // break; 36 | // continue; 37 | // } 38 | // printf("%d",i); 39 | // } 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | // int n=11 48 | 49 | // int isPrime=1; 50 | // if(n<=1){ 51 | // printf("prime no nhi hai"); 52 | // return 0; 53 | // } 54 | // for(int i=2;i 0,1,1,2,3,5 71 | // for(int i =0;i<5;i++){ 72 | // if(i==3){ 73 | // // break; 74 | // continue; 75 | // } 76 | // printf("%d",i); 77 | // } 78 | 79 | // int n=11; 80 | // int count =0; 81 | // if(n==0){ 82 | // count=1; 83 | // } 84 | // while (n>0) 85 | // { count++; 86 | // n=n/10; 87 | 88 | // /* code */ 89 | // } 90 | 91 | // // int t1=0; 92 | // // int t2=1; 93 | // // int next; 94 | // // for(int i=1;i<=n;i++){ 95 | // // printf("%d",t1); 96 | // // next=t1+t2; 97 | // // t1=t2; 98 | // // t2=next; 99 | // // } 100 | 101 | // 0 1 1 102 | // int n=6; 103 | // int t1=0; 104 | // int t2=1; 105 | // int next; 106 | // for(int i=1;i<=n;i++){ 107 | // printf("%d",t1); 108 | // next=t1+t2; 109 | // t1=t2; 110 | // t2=next; 111 | } 112 | 113 | // return 0; 114 | // } -------------------------------------------------------------------------------- /lect8/hello: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rupesh155/3rd_SemG/ab5c5429a2fa1f2471462149ecd3ab8f897ed517/lect8/hello -------------------------------------------------------------------------------- /lect8/hello.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | // for(int i=0;i<3;i++){ 6 | // for(int j=0;j<=i;j++){ 7 | // printf(" "); 8 | // } 9 | // for(int k=3;k>i;k--){ 10 | // printf("*"); 11 | // } 12 | 13 | // printf("\n"); 14 | // } 15 | 16 | // for(int i=0;i<2;i++){ 17 | // // printf("%d",i); 18 | // for(int j=0;j<2;j++){ 19 | // printf("%d",j); 20 | // } 21 | // } 22 | 23 | // int num = 65; 24 | // for (int i = 0; i < 4; i++) 25 | // { 26 | // for (int j = 0; j <=i; j++) 27 | // { 28 | // printf(" "); 29 | // } 30 | // for(int k=3;k>i;k--){ 31 | // printf("🙁"); 32 | // } 33 | 34 | // for(int p=3;p>=i;p--){ 35 | // printf("🙁"); 36 | // } 37 | 38 | // // printf("\n*"); 39 | // // for (int j = 4; j >i; j--) 40 | // // { 41 | // printf(" "); 42 | // } 43 | // for (int k = 0; k <= i; k++) 44 | // { 45 | // printf("*"); 46 | // } 47 | // for (int p = 1; p <= i; p++) 48 | // { 49 | // printf("*"); 50 | // } 51 | // for (int p = 4; p > i; p--) 52 | // { 53 | // printf("*"); 54 | // } 55 | // for(int k =3;k>i;k--){ 56 | // printf("*"); 57 | // } 58 | // printf("\n"); 59 | 60 | } 61 | } -------------------------------------------------------------------------------- /lect9/hello: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rupesh155/3rd_SemG/ab5c5429a2fa1f2471462149ecd3ab8f897ed517/lect9/hello -------------------------------------------------------------------------------- /lect9/hello.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | // for(int i=1;i<=4;i++){ 5 | // for(int j=1;j<=2*(4-i);j++){ 6 | // printf("*"); 7 | // } 8 | // printf("\n"); 9 | // } 10 | 11 | // for (int i = 0; i < 4; i++) 12 | // { 13 | // for (int j = 0; j <= i; j++) 14 | // { 15 | // printf("*"); 16 | // } 17 | // for (int k = 4; k > i; k--) 18 | // { 19 | // printf(" "); 20 | 21 | 22 | // } 23 | // for (int p = 4; p > i; p--) 24 | // { 25 | // printf(" "); 26 | // } 27 | // for(int r=0;r<=i;r++){ 28 | // printf("*"); 29 | // } 30 | // printf("\n"); 31 | // } 32 | 33 | // for(int i=0;i<4;i++){ 34 | 35 | // for(int j=0;j<=i;j++){ 36 | // printf(" "); 37 | // } 38 | // for(int k=3;k>i;k--){ 39 | // printf("*"); 40 | // } 41 | // for(int p=3;p>=i;p--){ 42 | // printf("*"); 43 | // } 44 | // printf("\n"); 45 | 46 | // } 47 | // } 48 | 49 | // 1 3 4 10 50 | // 2 5 9 11 51 | // 6 8 12 15 52 | // 7 13 14 16 53 | 54 | // #include 55 | 56 | // int main() { 57 | // int n = 4; 58 | // int arr[n][n]; 59 | // int num = 1; 60 | 61 | // // Fill diagonal-wise 62 | // for (int d = 0; d < 2*n-1; d++) { 63 | // if (d % 2 == 0) { 64 | // // Even diagonal -> top to bottom 65 | // for (int i = 0; i <= d; i++) { 66 | // int j = d - i; 67 | // if (i < n && j < n) { 68 | // arr[i][j] = num++; 69 | // } 70 | // } 71 | // } else { 72 | // // Odd diagonal -> bottom to top 73 | // for (int i = d; i >= 0; i--) { 74 | // int j = d - i; 75 | // if (i < n && j < n) { 76 | // arr[i][j] = num++; 77 | // } 78 | // } 79 | // } 80 | // } 81 | 82 | // // Print matrix 83 | // for (int i = 0; i < n; i++) { 84 | // for (int j = 0; j < n; j++) { 85 | // printf("%3d ", arr[i][j]); 86 | // } 87 | // printf("\n"); 88 | // } 89 | 90 | // return 0; 91 | // } 92 | 93 | // #include 94 | 95 | // int main() { 96 | // int n = 4; 97 | // int num = 1; 98 | 99 | // for (int row = 0; row < n; row++) { 100 | // for (int col = 0; col < n; col++) { 101 | // // diagonal traversal formula 102 | // int d = row + col; 103 | // int val; 104 | 105 | // // agar diagonal even hai (upar se neeche bharna) 106 | // if (d % 2 == 0) { 107 | // int i = row; 108 | // int j = col; 109 | // val = 0; 110 | // for (int x = 0; x <= d; x++) { 111 | // int a = x; 112 | // int b = d - x; 113 | // if (a < n && b < n) val++; 114 | // } 115 | // num += val; 116 | // printf("%3d ", num - val); 117 | // num -= (val - 1); 118 | // } 119 | // // agar diagonal odd hai (neeche se upar bharna) 120 | // else { 121 | // int i = row; 122 | // int j = col; 123 | // val = 0; 124 | // for (int x = d; x >= 0; x--) { 125 | // int a = x; 126 | // int b = d - x; 127 | // if (a < n && b < n) val++; 128 | // } 129 | // num += val; 130 | // printf("%3d ", num - val); 131 | // num -= (val - 1); 132 | // } 133 | // } 134 | // printf("\n"); 135 | // } 136 | 137 | // return 0; 138 | } 139 | --------------------------------------------------------------------------------