├── .gitignore ├── .vscode ├── c_cpp_properties.json ├── launch.json └── settings.json ├── Allocation dynamique de la mémoire ├── AllocationExercice.c └── allocationStruct.c ├── C Functions └── function.c ├── C Introduction └── variables_Constants.c ├── C Progamming Enums └── enums.c ├── C Programming Arrays └── array.c ├── C Programming Files ├── file.c ├── youcode.txt └── youcode1.txt ├── C Programming Pointers ├── calc_avg_sum_table_pointer.c ├── min_max.c ├── pointer.c └── tables_pointer.c ├── C Programming Strings └── string.c ├── Exercices ├── Exercice1.c ├── Exercice2.c ├── Exercice3.c └── Exercice4.c ├── LICENSE ├── ProjetGestionClasse └── gestionClasse.c ├── ProjetSAS └── GestionBancaire.c ├── Structure And Union ├── person.c └── structure.c ├── bank ├── console_bank.c └── main.c ├── clock └── Dclock.c ├── downloadeffect └── download.c ├── practice ├── ControlFlow.c ├── Youcode.c ├── calc.c ├── calcAvg.c ├── calcSwitch.c ├── goto.c ├── lang.c ├── loops.c ├── main.c ├── prefectNumber.c └── static.c ├── readme.md ├── recursion └── recursion.c ├── searching algorithms ├── LinearSearch.c └── binarysearch.c ├── shapes └── triangle.c ├── simple Library └── source │ └── youcodePrinter.c ├── sorting algorithms ├── bubbleSort.c ├── insertionSort.c └── selectionSort.c ├── string └── toUpperCase.c └── testYouCode └── fibonacciSequence.c /.gitignore: -------------------------------------------------------------------------------- 1 | # gitignore the complited version 2 | *.exe 3 | /public/static/**/*.exe 4 | /pointers/*.exe 5 | /.vscode 6 | ../*.exe 7 | /*.exe 8 | 9 | /.vscode -------------------------------------------------------------------------------- /.vscode/c_cpp_properties.json: -------------------------------------------------------------------------------- 1 | { 2 | "configurations": [ 3 | { 4 | "name": "windows-gcc-x64", 5 | "includePath": [ 6 | "${workspaceFolder}/**" 7 | ], 8 | "compilerPath": "C:/msys64/mingw64/bin/gcc.exe", 9 | "cStandard": "${default}", 10 | "cppStandard": "${default}", 11 | "intelliSenseMode": "windows-gcc-x64", 12 | "compilerArgs": [ 13 | "" 14 | ] 15 | } 16 | ], 17 | "version": 4 18 | } -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.2.0", 3 | "configurations": [ 4 | { 5 | "name": "C/C++ Runner: Debug Session", 6 | "type": "cppdbg", 7 | "request": "launch", 8 | "args": [], 9 | "stopAtEntry": false, 10 | "externalConsole": true, 11 | "cwd": "c:/Users/elhaj/OneDrive/Desktop/youcode/youcode projects/basic de c vscode", 12 | "program": "c:/Users/elhaj/OneDrive/Desktop/youcode/youcode projects/basic de c vscode/build/Debug/outDebug", 13 | "MIMode": "gdb", 14 | "miDebuggerPath": "gdb", 15 | "setupCommands": [ 16 | { 17 | "description": "Enable pretty-printing for gdb", 18 | "text": "-enable-pretty-printing", 19 | "ignoreFailures": true 20 | } 21 | ] 22 | } 23 | ] 24 | } -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "C_Cpp_Runner.cCompilerPath": "gcc", 3 | "C_Cpp_Runner.cppCompilerPath": "g++", 4 | "C_Cpp_Runner.debuggerPath": "gdb", 5 | "C_Cpp_Runner.cStandard": "", 6 | "C_Cpp_Runner.cppStandard": "", 7 | "C_Cpp_Runner.msvcBatchPath": "", 8 | "C_Cpp_Runner.useMsvc": false, 9 | "C_Cpp_Runner.warnings": [ 10 | "-Wall", 11 | "-Wextra", 12 | "-Wpedantic" 13 | ], 14 | "C_Cpp_Runner.enableWarnings": true, 15 | "C_Cpp_Runner.warningsAsError": false, 16 | "C_Cpp_Runner.compilerArgs": [], 17 | "C_Cpp_Runner.linkerArgs": [], 18 | "C_Cpp_Runner.includePaths": [], 19 | "C_Cpp_Runner.includeSearch": [ 20 | "*", 21 | "**/*" 22 | ], 23 | "C_Cpp_Runner.excludeSearch": [ 24 | "**/build", 25 | "**/build/**", 26 | "**/.*", 27 | "**/.*/**", 28 | "**/.vscode", 29 | "**/.vscode/**" 30 | ] 31 | } -------------------------------------------------------------------------------- /Allocation dynamique de la mémoire/AllocationExercice.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main(){ 5 | int n ; 6 | printf("please entre the size of elements in your table"); 7 | scanf("%d",&n); 8 | int *table = calloc(n,sizeof(int)); 9 | if(table==NULL){ 10 | printf("les memoire n'est pas allouee .\n"); 11 | exit(0); 12 | }else 13 | { 14 | for (int i = 0; i < n; i++) 15 | { 16 | int note; 17 | printf("entre element %d : ",i+1); 18 | scanf("%d",¬e); 19 | *(table+i)= note; 20 | } 21 | int sum =0; 22 | for (int i = 0; i < n; i++) 23 | { 24 | 25 | 26 | sum += *(table+i); 27 | } 28 | double avg = sum/n; 29 | printf("avg of the table is = %lf",avg); 30 | } 31 | 32 | } -------------------------------------------------------------------------------- /Allocation dynamique de la mémoire/allocationStruct.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | int main(int argc, char** argv) 4 | { 5 | typedef struct 6 | { 7 | char* firstName; 8 | char* lastName; 9 | int rollNumber; 10 | 11 | } STUDENT; 12 | 13 | int numStudents=2; 14 | int x; 15 | STUDENT* students = malloc(numStudents * sizeof *students); 16 | //function 17 | for (x = 0; x < numStudents; x++) 18 | { 19 | students[x].firstName=(char*)malloc(sizeof(char*)); 20 | 21 | printf("Enter first name :"); 22 | scanf("%s",students[x].firstName); 23 | 24 | students[x].lastName=(char*)malloc(sizeof(char*)); 25 | printf("Enter last name :"); 26 | scanf("%s",students[x].lastName); 27 | printf("Enter roll number :"); 28 | scanf("%d",&students[x].rollNumber); 29 | 30 | } 31 | 32 | for (x = 0; x < numStudents; x++) 33 | printf("First Name: %s, Last Name: %s, Roll number: %d\n",students[x].firstName,students[x].lastName,students[x].rollNumber); 34 | 35 | return (0); 36 | } -------------------------------------------------------------------------------- /C Functions/function.c: -------------------------------------------------------------------------------- 1 | #include 2 | //print start with pattern 3 | 4 | double pi=3.14; 5 | void printname(){ 6 | for (int i = 0; i < 10; i++) 7 | { 8 | // printf("\n* \t"); 9 | if(i==5){ 10 | printf("\n*"); 11 | }else{ 12 | printf("* \t"); 13 | } 14 | 15 | for (int j= 0; j < 10; j++) 16 | { 17 | 18 | printf("* \t"); 19 | } 20 | } 21 | 22 | } 23 | 24 | void printInformation(int age,char name[]){ 25 | printf("welcome %s and your age is %d",name,age); 26 | 27 | }; 28 | 29 | void PrintNameWithShapeInTheConsole(char name[]){ 30 | for (int i = 0; i < 10; i++) 31 | { 32 | 33 | for (int j = 0; j < 10; j++) 34 | { 35 | if(j==0||j==9){ 36 | printf("*"); 37 | }else if(i==5 && j==5){ 38 | printf("%s",name); 39 | // printf("\t"); 40 | }else if(i==0||i==9){ 41 | for (int n = 0; n < 8; n++) 42 | { 43 | printf("*"); 44 | } 45 | 46 | } 47 | else{ 48 | printf("\t"); 49 | } 50 | } 51 | 52 | printf("\n"); 53 | 54 | } 55 | 56 | } 57 | 58 | //todo :BUILD TRIANGLE IN C NEED TO FIND ABOUT PATTERN IN SHAPES 59 | int printTriangle(){ 60 | 61 | } 62 | 63 | 64 | int main(void){ 65 | // printname(); 66 | // char name[20] 67 | // printInformation(22,"mehdi elhjuojy"); 68 | PrintNameWithShapeInTheConsole("mehdi "); 69 | return 0 ; 70 | } 71 | -------------------------------------------------------------------------------- /C Introduction/variables_Constants.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | 4 | int main(){ 5 | 6 | int a; 7 | float b; 8 | double c; 9 | char d; 10 | const int pi = 3.14; 11 | return 0 ; 12 | } -------------------------------------------------------------------------------- /C Progamming Enums/enums.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | enum week {Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday}; 4 | 5 | int main() 6 | { 7 | // creating today variable of enum week type 8 | enum week today; 9 | today = Wednesday; 10 | printf("Day %d",today+1); 11 | 12 | return 0; 13 | } -------------------------------------------------------------------------------- /C Programming Arrays/array.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | 4 | void main(){ 5 | // printf("arr"); 6 | // dataType arrayName[arraySize]; 7 | // int mark[5] = {19, 10, 8, 17, 9}; 8 | // int mark[] = {19, 10, 8, 17, 9}; 9 | } -------------------------------------------------------------------------------- /C Programming Files/file.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | 6 | 7 | 8 | int main(){ 9 | 10 | FILE* fptr; 11 | FILE* fptr1; 12 | //modes :r=> read 13 | fptr = fopen("youcode.txt","r"); 14 | fptr1 = fopen("youcode1.txt","w"); 15 | 16 | char content [1000]; 17 | 18 | if(fptr !=NULL){ 19 | // printf("File Open Successful"); 20 | // read file content 21 | fgets(content,1000,fptr); 22 | printf("==> %s",content); 23 | }else{ 24 | printf("File Open Unsuccessful"); 25 | } 26 | 27 | 28 | //write into file 29 | //* if the file doesn't exist"s it will be created 30 | 31 | fputs("I love c Progamming\n",fptr1); 32 | fputs("C progamming series by elhjuojy is the best",fptr1); 33 | 34 | 35 | 36 | 37 | fclose(fptr1); 38 | fclose(fptr); 39 | return 0; 40 | } 41 | 42 | -------------------------------------------------------------------------------- /C Programming Files/youcode.txt: -------------------------------------------------------------------------------- 1 | Hello everyone i am mehdi 22 years old studant in youcode -------------------------------------------------------------------------------- /C Programming Files/youcode1.txt: -------------------------------------------------------------------------------- 1 | I love c Progamming 2 | C progamming series by elhjuojy is the best -------------------------------------------------------------------------------- /C Programming Pointers/calc_avg_sum_table_pointer.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main (){ 4 | 5 | int t[6]= {133,34,22,34,99,12}; 6 | return 0; 7 | } -------------------------------------------------------------------------------- /C Programming Pointers/min_max.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void maxnumber(); 4 | 5 | //apple par refercnes 6 | 7 | int main(){ 8 | int a,b ,max; 9 | 10 | printf("Veuillez saisir la valeur de a :"); 11 | scanf("%d",&a); 12 | printf("Veuillez saisir la valeur de b :"); 13 | scanf("%d",&b); 14 | maxnumber(&a,&b,&max); 15 | printf("le maximum des deux valeurs est : %d",max); 16 | return 0; 17 | 18 | } 19 | 20 | void maxnumber(int *x,int *y, int *m){ 21 | 22 | if(*x>*y){ 23 | *m = *x; 24 | }else{ 25 | *m = *y; 26 | } 27 | 28 | 29 | 30 | } -------------------------------------------------------------------------------- /C Programming Pointers/pointer.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(){ 4 | //simple pointer 5 | // int a =3; 6 | // printf("%d \n",&a); 7 | // int *b =&a; 8 | // printf("%d",*b); 9 | 10 | int a =2; 11 | printf("a=%d\n",a); 12 | int *p; 13 | p = &a; 14 | int *p1; 15 | p1=&a; 16 | printf("la valeur de *p %d \n",*p); 17 | printf("la value de *p1 = %d\n",*p1); 18 | 19 | //we change a because *p 20 | *p=85; 21 | printf("la valeur de *p %d \n",*p); 22 | printf("la value de *p1 = %d\n",*p1); 23 | 24 | 25 | // -- 26 | printf("la valeur de a = %d\n",a); 27 | printf("la valeur de &a = %d\n",&a); 28 | // -- 29 | printf("la valeur de *p = %d\n",*p); 30 | printf("la valeur de p = %d\n",p); 31 | printf("la valeur de &p = %d\n",&p); 32 | // --- 33 | printf("la value de &p1 = %d\n",&p1); 34 | printf("la value de p1 = %d\n",p1); 35 | printf("la value de *p1 = %d\n",*p1); 36 | 37 | 38 | 39 | 40 | 41 | return 0; 42 | 43 | 44 | } -------------------------------------------------------------------------------- /C Programming Pointers/tables_pointer.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(){ 4 | int T[5] = {3,-6,14,8,24}; 5 | int *p ; 6 | p=T ; 7 | printf("%d",T[0]); 8 | //output is 3 9 | printf("%d",*p); 10 | //output is 3 11 | 12 | p++; 13 | printf("%d",*p); 14 | //output is -6 15 | p=p+3; 16 | 17 | 18 | 19 | } -------------------------------------------------------------------------------- /C Programming Strings/string.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | char name[30]; 5 | printf("Enter name: "); 6 | fgets(name, sizeof(name), stdin); // read string 7 | printf("Name: "); 8 | puts(name); // display string 9 | return 0; 10 | } -------------------------------------------------------------------------------- /Exercices/Exercice1.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(){ 4 | char name[20]; 5 | printf("S'il vous plaît entrez votre nom \n"); 6 | scanf("%s",&name); 7 | // int year=2022; 8 | int age ; 9 | printf("please enter your age "); 10 | scanf("%d",&age); 11 | int res = 2022-age +100; 12 | printf("you will reach the 100 age in %d , mr %s",res,name); 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | getchar(); 21 | return 0; 22 | 23 | 24 | } -------------------------------------------------------------------------------- /Exercices/Exercice2.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(){ 4 | int num ,num2; 5 | printf("please entre a number"); 6 | 7 | if(num%num2==0){ 8 | printf("the number is odd"); 9 | } 10 | else{ 11 | printf("the number is even"); 12 | } 13 | 14 | scanf("%d",&num); 15 | if (num % 4 == 0){ 16 | printf("the number is multiple by 4"); 17 | } 18 | else if(num % 2 != 0){ 19 | printf("the number is odd"); 20 | } 21 | 22 | else{ 23 | printf("the number is even"); 24 | } 25 | getchar(); 26 | return 0; 27 | 28 | } -------------------------------------------------------------------------------- /Exercices/Exercice3.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(){ 4 | //method 1 5 | int arr[10]; 6 | arr[0]=1; 7 | arr[1]=2; 8 | arr[2]=3; 9 | arr[3]=4; 10 | arr[4]=5; 11 | arr[5]=6; 12 | arr[6]=7; 13 | arr[7]=8; 14 | arr[8]=9; 15 | arr[9]=10; 16 | 17 | 18 | int arr1[] = {1,2,3,4,5,6,7,8,9,0}; 19 | int i ; 20 | for (i=0;i<10;i++){ 21 | if(arr1[i]<=5){ 22 | printf("%d \t ",arr1[i]); 23 | } 24 | 25 | } 26 | return 0; 27 | } -------------------------------------------------------------------------------- /Exercices/Exercice4.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(){ 4 | float note1,note2,note3,moynne; 5 | printf("please entre your note n1"); 6 | scanf("%f",¬e1); 7 | printf("please entre your note n1"); 8 | scanf("%f",¬e2); 9 | printf("please entre your note n1"); 10 | scanf("%f",¬e3); 11 | 12 | moynne = (note1+note2+note3)/3; 13 | printf("moynne : %f",moynne); 14 | 15 | 16 | return 0; 17 | 18 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 ELMAHDI ELHJUOJY 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /ProjetGestionClasse/gestionClasse.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | // date struct 6 | 7 | typedef struct 8 | { 9 | int jour; 10 | int mois; 11 | int annee; 12 | 13 | } dateNais; 14 | 15 | // studant struct 16 | 17 | typedef struct 18 | { 19 | char *nom; 20 | char *prenom; 21 | dateNais *date; 22 | 23 | } StudentsStruct; 24 | 25 | int numStudents = 0; 26 | StudentsStruct *students; 27 | 28 | enum sort {ascending , descending}; 29 | 30 | void triEtudiant(enum sort sortwith); 31 | 32 | int countAge(dateNais userdateNais){ 33 | time_t currentTime ; 34 | char *currentTimeInString; 35 | 36 | currentTime = time(NULL); 37 | 38 | 39 | } 40 | 41 | int avgAge(){ 42 | //sum 43 | printf("avg age function strat \n"); 44 | 45 | 46 | int sum ; 47 | for (int i = 0; i < numStudents; i++) 48 | { 49 | 50 | int age =students[i].date->annee; 51 | printf("%d",age); 52 | sum += age; 53 | } 54 | 55 | int avgAge = sum/numStudents; 56 | 57 | return avgAge-2022; 58 | 59 | } 60 | 61 | 62 | //AJouter etudiant 63 | int AjouterEtudiant(int nbrEtudiant) 64 | { 65 | students = realloc(students, numStudents + nbrEtudiant); 66 | if (students == NULL) 67 | { 68 | printf("there no space enough "); 69 | } 70 | else 71 | { 72 | for (int x = numStudents; x < numStudents + nbrEtudiant; x++) 73 | { 74 | students[x].nom = (char *)malloc(sizeof(char *)); 75 | students[x].prenom = (char *)malloc(sizeof(char *)); 76 | students[x].date = (dateNais *)malloc(sizeof(dateNais *)); 77 | printf("Ajouter un Etudiant %d \n",x); 78 | printf("Enter votre nom :"); 79 | scanf("%s", students[x].nom); 80 | 81 | printf("Enter votre prenom :"); 82 | scanf("%s", students[x].prenom); 83 | printf("Enter votre age number :"); 84 | printf(" => jour :"); 85 | scanf("%d", &students[x].date->jour); 86 | printf(" => mois :"); 87 | scanf("%d", &students[x].date->mois); 88 | printf(" => annee :"); 89 | scanf("%d", &students[x].date->annee); 90 | printf("@@ Done @@"); 91 | printf("\n"); 92 | } 93 | } 94 | printf("\n"); 95 | numStudents += nbrEtudiant; 96 | } 97 | //affiche etudiant 98 | void printEdutaint(int pos){ 99 | printf("start printing======"); 100 | printf("\n"); 101 | printf("nom : %s, prenom : %s, date de nassaine : %i/%i/%i,", 102 | students[pos].nom,students[pos].prenom, students[pos].date->jour, students[pos].date->mois, students[pos].date->annee); 103 | printf("\n"); 104 | printf("end printing====== \n"); 105 | } 106 | 107 | int main() 108 | { 109 | 110 | students = malloc(numStudents * sizeof *students); 111 | 112 | printf("=================Gestion Classe=================\n"); 113 | printf("= =\n"); 114 | printf("= 1-Ajouter un Etudiant =\n"); 115 | printf("= 2-Ajouter plusieur etudiant =\n"); 116 | printf("= 3-tri par age(ASC/DESC) =\n"); 117 | printf("= 4-statistque =\n"); 118 | printf("= =\n"); 119 | printf("================================================\n"); 120 | 121 | int choice; 122 | printf("votre choix :"); 123 | scanf("%d", &choice); 124 | switch (choice) 125 | { 126 | case 1: 127 | 128 | AjouterEtudiant(1); 129 | //TODO : 1 in is not working 130 | printEdutaint(1); 131 | main(); 132 | break; 133 | case 2: 134 | 135 | printf(" combien de compte voulez-vous creer :"); 136 | int n ; 137 | scanf("%d",&n); 138 | //ajouter Etudiant function take n as number of how many account will be created 139 | AjouterEtudiant(n); 140 | for (int i = numStudents-n; i %d",avg_age); 196 | } 197 | else 198 | { 199 | main(); 200 | } 201 | 202 | break; 203 | default: 204 | printf("break the app "); 205 | exit(0); 206 | break; 207 | } 208 | } 209 | 210 | 211 | 212 | //account sort function 213 | void triEtudiant(enum sort sortwith){ 214 | sortwith==0?printf("asending \n"):printf("desnding \n"); 215 | int posmin = 0; 216 | StudentsStruct temp ; 217 | if (sortwith == 0) 218 | { 219 | 220 | for (int j = 0; j < numStudents; j++) 221 | { 222 | for (int i = 1; i < numStudents; i++) 223 | { 224 | if (students[i].date->anneeannee) 225 | { 226 | temp = students[i]; 227 | students[i]= students[i-1]; 228 | students[i-1] = temp; 229 | } 230 | } 231 | } 232 | 233 | printf("============================================\n"); 234 | printf("length of the list is %d \n",numStudents); 235 | for (int i = 0; i < numStudents; i++) 236 | { 237 | printf("value of i is %d",i); 238 | printEdutaint(i); 239 | } 240 | printf("============================================\n"); 241 | 242 | } 243 | else{ 244 | for (int j = 0; j < numStudents; j++) 245 | { 246 | for (int i = 1; i < numStudents; i++) 247 | { 248 | if (students[i].date->annee>students[i-1].date->annee) 249 | { 250 | temp = students[i]; 251 | students[i]= students[i-1]; 252 | students[i-1] = temp; 253 | } 254 | } 255 | } 256 | printf("============================================"); 257 | for (int i = 0; i < numStudents; i++) 258 | { 259 | printEdutaint(0); 260 | } 261 | printf("============================================"); 262 | 263 | } 264 | 265 | } 266 | -------------------------------------------------------------------------------- /ProjetSAS/GestionBancaire.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | //our Client 10 | struct Client { 11 | char CIN[10]; 12 | char Nom[20]; 13 | char Prenom[20]; 14 | double Montant; 15 | }ClientList[1000]; 16 | 17 | int length = 0; 18 | 19 | void fidelisationFunc(); 20 | void rechercheparCIN(char cinClient[]){ 21 | int found = 0; 22 | for (int i = 0; i < length; i++) 23 | { 24 | printf("i value is =>%d ----> %s=%s \n",i,ClientList[i].CIN,cinClient); 25 | if (strcmp(ClientList[i].CIN,cinClient)==0) 26 | { 27 | 28 | printf("🧑‍💻🧑‍💻 user information : by CIN =>%s 🤖🤖 \n",cinClient); 29 | printf(" %s =>%s => %s => %lf",ClientList[i].CIN,ClientList[i].Prenom,ClientList[i].Nom,ClientList[i].Montant); 30 | printf("\n"); 31 | found = 1; 32 | break; 33 | } 34 | 35 | } 36 | 37 | if (found==0) 38 | { 39 | printf("the user does not exist"); 40 | } 41 | 42 | 43 | } 44 | 45 | enum sort {ascending , descending}; 46 | 47 | void triAccount(enum sort sortwith); 48 | 49 | 50 | void createAccount(int accountNbr){ 51 | accountNbr==0? accountNbr=0 : printf("🧑‍🦰 => create accont %d \n",accountNbr); 52 | char cin[10]; 53 | char nom[20]; 54 | char prenom[20]; 55 | double montant; 56 | struct Client c1 ; 57 | printf("veuillez entrer votre cin :"); 58 | scanf("%s",&cin); 59 | strcpy(c1.CIN,cin); 60 | // printf("%s",c1.CIN); 61 | printf("veuillez entrer votre prenom : "); 62 | scanf("%s",&prenom); 63 | strcpy(c1.Prenom,prenom); 64 | // printf("%s",c1.Prenom); 65 | printf("veuillez entrer votre nom : "); 66 | scanf("%s",&nom); 67 | strcpy(c1.Nom,nom); 68 | // printf("%s",c1.Prenom); 69 | do 70 | { 71 | printf("veuillez entrer votre montant : "); 72 | scanf("%lf",&montant); 73 | 74 | } while (montant<0); 75 | printf("%lf",montant); 76 | c1.Montant=montant; 77 | printf("\n\n\n"); 78 | //====================== 79 | printf(" 🎁🎁 your account is successfully created \n"); 80 | printf("🧑‍💻🧑‍💻 user information : 🤖🤖 \n"); 81 | ClientList[length] =c1; 82 | printf(" %s =>%s => %s => %lf",ClientList[length].CIN,ClientList[length].Prenom,ClientList[length].Nom,ClientList[length].Montant); 83 | printf("\n"); 84 | length++; 85 | } 86 | 87 | int main(void){ 88 | //menu principal 89 | int choice ; 90 | printf("\n"); 91 | printf("🏦🏦Console bank 🏦🏦 \n"); 92 | printf("1-Introduire un compte bancaire \n"); 93 | printf("2-Introduire plusieurs comptes bancaires \n"); 94 | printf("3-Opérations \n"); 95 | printf("4- Affichage \n" ); 96 | printf("5- Fidélisation \n"); 97 | printf("6- Quitter l'application \n"); 98 | printf("entre votre choix :"); 99 | scanf("%d",&choice); 100 | 101 | switch (choice) 102 | { 103 | case 1: 104 | printf("your choice is => 1\n"); 105 | createAccount(0); 106 | printf("\n\n"); 107 | int c = 0; 108 | while (c != 10) 109 | { 110 | printf("🔃🔃"); 111 | c++; 112 | Sleep(1000); 113 | } 114 | 115 | printf("\n\n"); 116 | main(); 117 | break; 118 | case 2: 119 | printf("your choice is =>2\n"); 120 | int nbrAccount; 121 | printf("combien de compte vous voulez créer :"); 122 | scanf("%d",&nbrAccount); 123 | for (int i = 0; i < nbrAccount; i++) 124 | { 125 | createAccount(i+1); 126 | } 127 | printf("========"); 128 | main(); 129 | break; 130 | //Opérations : 131 | case 3: 132 | printf("your choice is =>3 \n"); 133 | //Opérations :- Retrait - Dépôt 134 | printf("veuillez choisir votre opération :\n"); 135 | printf("\t 1-Retrait \n"); 136 | printf("\t 2-Dépôt \n"); 137 | int opp; 138 | //ask about the type of operation he want to do 139 | printf("=> "); 140 | scanf("%d",&opp); 141 | //! operation 142 | if(opp==1){ 143 | printf("Retrait"); 144 | double montantRetrait; 145 | char cin[20]; 146 | printf("s'il vous plait entrez votre cin :"); 147 | scanf("%s",&cin); 148 | printf("s'il vous plait entrez votre montant : "); 149 | scanf("%lf",&montantRetrait); 150 | for (int j = 0; j < length; j++) 151 | { 152 | if(strcmp(ClientList[j].CIN,cin)==0){ 153 | printf("the user is exsit in the database "); 154 | if (ClientList[j].Montant 💴💴 %lf \n", ClientList[j].Montant); 163 | break; 164 | } 165 | 166 | }else{ 167 | printf("the user is doesn't exsit in the database \n "); 168 | } 169 | } 170 | }else if(opp==2) 171 | { 172 | printf("Dépôt"); 173 | char cin[20]; 174 | double montantDepot; 175 | printf("s'il vous plait entrez votre cin :"); 176 | scanf("%s",&cin); 177 | printf("veuillez entrer combien d'argent vous voulez stocker :"); 178 | printf("s'il vous plait entrez votre montant 'Depot': "); 179 | scanf("%lf",&montantDepot); 180 | //find the user which you want to add some money to his account 181 | for (int j = 0; j < length; j++) 182 | { 183 | if(strcmp(ClientList[j].CIN,cin)==0){ 184 | printf("the user is exsit in the database "); 185 | ClientList[j].Montant += montantDepot; 186 | printf(" ⁜⁜ l'opération a été affectée avec succès \n"); 187 | printf("\t votre sold est => 💴💴 %lf \n", ClientList[j].Montant); 188 | break; 189 | }else{ 190 | printf("the user is doesn't exsit in the database "); 191 | } 192 | } 193 | }else{ 194 | printf("exit \n"); 195 | main(); 196 | Sleep(3000); 197 | } 198 | break; 199 | // Affichage 200 | case 4: 201 | printf("your choice is =>4"); 202 | // Par Ordre Ascendant 203 | // Par Ordre Descendant 204 | // Par Ordre Ascendant (les comptes bancaires ayant un montant supérieur à un chiffre introduit) 205 | // Par Ordre Descendant (les comptes bancaires ayant un montant supérieur à un chiffre introduit) 206 | // Recherche par CIN 207 | printf("Affichage :"); 208 | printf("\n"); 209 | printf("\t 1 - Par Ordre Ascendant"); 210 | printf("\n"); 211 | printf("\t 2 - Par Ordre Descendant"); 212 | printf("\n"); 213 | printf("\t 3 - Par Ordre Ascendant (les comptes bancaires ayant un montant supérieur à un chiffre introduit)"); 214 | printf("\n"); 215 | printf("\t 4 - Par Ordre Descendant (les comptes bancaires ayant un montant supérieur à un chiffre introduit)"); 216 | printf("\n"); 217 | printf("\t 5 - Recherche par CIN"); 218 | printf("\n"); 219 | printf("\t 6 - retourner"); 220 | printf("\n"); 221 | //* opp choice 222 | char cinUser[10]; 223 | int oppp; 224 | printf("=>"); 225 | scanf("%d",&oppp); 226 | switch (oppp) 227 | { 228 | // 229 | case 1: 230 | printf("1\n"); 231 | triAccount(ascending); 232 | break; 233 | case 2: 234 | printf("2\n"); 235 | triAccount(descending); 236 | break; 237 | case 3: 238 | printf("3\n"); 239 | break; 240 | case 4: 241 | printf("4\n"); 242 | break; 243 | case 5: 244 | //Recherche par CIN 245 | printf("5\n"); 246 | printf("please entre your cin \n"); 247 | scanf("%s",cinUser); 248 | rechercheparCIN(cinUser); 249 | break; 250 | case 6: 251 | printf("6\n"); 252 | main(); 253 | break; 254 | default: 255 | printf("Nothing else"); 256 | main(); 257 | break; 258 | } 259 | break; 260 | //* end of case 4 261 | //end of case 4 262 | case 5: 263 | printf("your choice is =>5"); 264 | fidelisationFunc(); 265 | 266 | break; 267 | case 6: 268 | printf("your choice is =>6"); 269 | exit(0); 270 | break; 271 | 272 | default: 273 | break; 274 | } 275 | 276 | main(); 277 | return 0; 278 | } 279 | 280 | //account sort function 281 | void triAccount(enum sort sortwith){ 282 | sortwith==0?printf("asending \n"):printf("desnding \n"); 283 | int posmin = 0; 284 | struct Client temp ; 285 | if (sortwith == 0) 286 | { 287 | 288 | for (int j = 0; j < length; j++) 289 | { 290 | for (int i = 1; i < length; i++) 291 | { 292 | if (ClientList[i].Montant |%s| => 💴💴%lf \n",ClientList[i].Nom, ClientList[i].CIN,ClientList[i].Montant); 305 | } 306 | printf("============================================\n"); 307 | } 308 | else{ 309 | for (int j = 0; j < length; j++) 310 | { 311 | for (int i = 1; i < length; i++) 312 | { 313 | if (ClientList[i].Montant>ClientList[i-1].Montant) 314 | { 315 | temp = ClientList[i]; 316 | ClientList[i] = ClientList[i-1]; 317 | ClientList[i-1] = temp; 318 | } 319 | } 320 | } 321 | printf("============================================"); 322 | for (int i = 0; i < length; i++) 323 | { 324 | 325 | printf(" %s => |%s| => 💴💴%lf \n",ClientList[i].Nom, ClientList[i].CIN,ClientList[i].Montant); 326 | } 327 | printf("============================================"); 328 | 329 | } 330 | 331 | } 332 | 333 | ///Fidélisation Ajouter 1.3% aux comptes ayant les 3 premiers montants supérieurs 334 | void fidelisationFunc(){ 335 | triAccount(descending); 336 | printf("=======================================\n"); 337 | for (int i = 0; i < 3; i++) 338 | { 339 | ClientList[i].Montant = ClientList[i].Montant+ (ClientList[i].Montant*1.3)/100; 340 | } 341 | printf("========================================\n"); 342 | 343 | for (int i = 0; i < length; i++) 344 | { 345 | printf(" %s => |%s| => 💴💴%lf \n",ClientList[i].Nom, ClientList[i].CIN,ClientList[i].Montant); 346 | } 347 | printf("============================================\n"); 348 | } -------------------------------------------------------------------------------- /Structure And Union/person.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | struct person 5 | { 6 | char nom[10]; 7 | char prenom[10]; 8 | int age ; 9 | }; 10 | 11 | 12 | int main(){ 13 | 14 | struct person p1 = {"khawla","bouziane",19}; 15 | struct person p2 = {"ayoub","elamghani",20}; 16 | 17 | p2.age =18; 18 | //modife 19 | strcpy(p2.nom,"ayoube 222"); 20 | //comperastion 21 | strcmp("khawla",p1.prenom); 22 | p1.age=19; 23 | 24 | if (strcmp("khawla",p1.prenom)==0) 25 | { 26 | printf("khawal 9ed ayoub"); 27 | } 28 | else if (p1.age > p2.age) 29 | { 30 | printf("khawal kbeer men ayoub"); 31 | 32 | }else{ 33 | printf("khawal sgheer men ayoub"); 34 | } 35 | 36 | 37 | 38 | 39 | 40 | } -------------------------------------------------------------------------------- /Structure And Union/structure.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | struct Client { 5 | char Id[20]; 6 | char name[20]; 7 | int accountNumber; 8 | int sold; 9 | 10 | }ClientList[19]; 11 | 12 | int main(){ 13 | 14 | 15 | struct Client c1,c2; 16 | 17 | strcpy(c1.Id,"HH197878"); 18 | strcpy(c1.name, "George Orwell"); 19 | c1.sold=400; 20 | c1.accountNumber=111; 21 | printf("%s",c2.Id); 22 | //output => HH197878 23 | 24 | //client 2 25 | strcpy(c2.Id,"HH9798"); 26 | strcpy(c2.name, "abdelillah elasri"); 27 | c2.sold=5000; 28 | c2.accountNumber=222; 29 | 30 | printf("%s",c2.name); 31 | //output => abdelillah elasri 32 | 33 | 34 | 35 | //add the client ot the list 36 | ClientList[0]=c1; 37 | ClientList[1]=c2; 38 | return 0; 39 | } -------------------------------------------------------------------------------- /bank/console_bank.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | 8 | void createAcounnt(); 9 | void loginTotheAccount(); 10 | int menu(); 11 | int isTheNumberAlreadyExist(); 12 | 13 | 14 | struct Client { 15 | char Id[10]; 16 | char firstname[20]; 17 | char lastname[20]; 18 | int accountNumber; 19 | double balance; 20 | int password; 21 | 22 | }ClientList[100]; 23 | 24 | 25 | int main(void){ 26 | srand(time(NULL)); 27 | int choice ; 28 | int randomNumber = rand(); 29 | 30 | 31 | int lastIndexOfLlist = 0; 32 | printf("🏦🏦 ***CONSOLE BANK*** 🏦🏦 \n\n"); 33 | //creating acount, 34 | 35 | //ask for the choice 36 | choice = menu(); 37 | printf("the choice = %d ",choice); 38 | // 39 | 40 | while (choice==1 ||choice==2) 41 | { 42 | printf("am in the while loop the choice is %d \n",choice); 43 | if (choice==1) 44 | { 45 | //here you must make the user create an account ; 46 | printf("🧾🧾\t create account \t🧾🧾 \n"); 47 | struct Client c1; 48 | char id[10]; 49 | char firsname[20]; 50 | char lastname[20]; 51 | double balance; 52 | //ask about information 53 | printf("Please Entre your national id : "); 54 | scanf("%s",&id); 55 | strcpy(c1.Id,id); 56 | //firstname 57 | printf("Please Entre your firstname : "); 58 | scanf("%s",&firsname); 59 | strcpy(c1.firstname, firsname); 60 | // lastname 61 | printf("Please Entre your lastname : "); 62 | scanf("%s",&lastname); 63 | strcpy(c1.lastname,lastname); 64 | //balance 65 | printf("Please Entre your balance : "); 66 | scanf("%lf",&balance); 67 | c1.balance=balance; 68 | 69 | int isTheUserExsit = 0; 70 | // printf("=========== in prosess"); 71 | for (int i = 0; i < 10; i++) 72 | { 73 | printf("%d",i); 74 | if(strcmp(c1.Id,ClientList[i].Id)==0){ 75 | printf("this id is already being used."); 76 | isTheUserExsit = 1; 77 | break; 78 | } 79 | 80 | } 81 | c1.accountNumber=randomNumber; 82 | c1.password=randomNumber; 83 | ClientList[lastIndexOfLlist]=c1; 84 | printf("your account is successfully created \n"); 85 | printf("🧑‍💻🧑‍💻 user information : 🤖🤖 \n"); 86 | printf("firstname => %s || lastname => %s || id => %s || accountNumber => %s || password => %s || balance => %s",c1.firstname,c1.lastname,c1.Id,c1.accountNumber,c1.password,c1.balance); 87 | choice= menu(); 88 | 89 | 90 | 91 | } 92 | //* end of if 93 | else 94 | { 95 | printf("login to the account \n"); 96 | } 97 | 98 | } 99 | return 0; 100 | } 101 | 102 | int isTheNumberAlreadyExist(int theNumber){ 103 | for (int i = 0; i < 10; i++) 104 | { 105 | if(theNumber,ClientList[i].accountNumber==0){ 106 | return 1; 107 | } 108 | } 109 | return 0; 110 | 111 | }; 112 | 113 | 114 | 115 | int menu(){ 116 | int n ; 117 | printf("====================== \n"); 118 | printf("1-Create acount \n"); 119 | //login to the account 120 | printf("2-login to the acount \n"); 121 | //exit the app 122 | printf("3-Exit \n"); 123 | printf("====================== \n"); 124 | printf("please choose your choice : "); 125 | return scanf("%d",&n); 126 | } 127 | 128 | -------------------------------------------------------------------------------- /bank/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | 5 | // #define money 4000; 6 | void sendMoney(); 7 | int showSold(); 8 | void showClientInformation(); 9 | 10 | int accountnumber1, accountnumber2; 11 | int account1Sold ,account2Sold ; 12 | 13 | struct Client { 14 | char Id[20]; 15 | char name[20]; 16 | int accountNumber; 17 | int sold; 18 | 19 | }ClientList[19]; 20 | 21 | 22 | int main(void){ 23 | // account1Sold=4000; 24 | // account2Sold=4000; 25 | 26 | // accountnumber1=1; 27 | // accountnumber2=2; 28 | // struct Client c1,c1; 29 | 30 | //client 2 31 | struct Client c1,c2; 32 | 33 | strcpy(c1.Id,"HH197878"); 34 | strcpy(c1.name, "George Orwell"); 35 | c1.sold=400; 36 | c1.accountNumber=111; 37 | 38 | 39 | //client 2 40 | strcpy(c2.Id,"HH9798"); 41 | strcpy(c2.name, "abdelillah elasri"); 42 | c2.sold=5000; 43 | c2.accountNumber=222; 44 | 45 | //add the client ot the list 46 | ClientList[0]=c1; 47 | ClientList[1]=c2; 48 | 49 | showClientInformation(); 50 | 51 | 52 | // int sold = showSold(929); 53 | // sendMoney(2,1,400); 54 | // printf("%d",showSold(1)); 55 | 56 | 57 | 58 | } 59 | 60 | //struct 61 | void showClientInformation(){ 62 | for (int i = 0; i <2; i++) 63 | { 64 | printf("===================================== \n"); 65 | printf("=> %s \n",ClientList[i].name); 66 | printf("=> %s \n",ClientList[i].Id); 67 | printf("=> %d \n",ClientList[i].accountNumber); 68 | printf("=> %d \n",ClientList[i].sold); 69 | printf("===================================== \n"); 70 | } 71 | 72 | } 73 | 74 | 75 | void sendMoney(int fromAccoutnumber,int accountNumber,int money){ 76 | if(fromAccoutnumber==accountnumber1){ 77 | account1Sold = account1Sold-money; 78 | account2Sold += money; 79 | printf("account 1 sent money to account 2 "); 80 | } 81 | else{ 82 | account2Sold = account2Sold-money; 83 | account1Sold += money; 84 | printf("account 2 sent money to account 1 "); 85 | } 86 | 87 | 88 | 89 | } 90 | 91 | int showSold(int accountnumber1s){ 92 | if (accountnumber1s==accountnumber1) 93 | { 94 | printf("=> account 1 => £ "); 95 | return account1Sold; 96 | }else{ 97 | printf("=> account 2=> £ "); 98 | return account2Sold; 99 | } 100 | 101 | } -------------------------------------------------------------------------------- /clock/Dclock.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | int main(void) 4 | { 5 | int h,m,s; 6 | int d = 1000; 7 | printf("Type the time: "); 8 | scanf("%i%i%i", &h,&m,&s); 9 | if ( s > 60 || m > 60 || h > 12 ) 10 | { 11 | printf("ERROR\n"); 12 | exit(0); 13 | } 14 | while (1) 15 | { 16 | if( s > 59 ) 17 | { 18 | s = 0; 19 | m++; 20 | } 21 | if( m > 59 ) 22 | { 23 | m = 0; 24 | h++; 25 | } 26 | if( h > 12 ) 27 | { 28 | h = 1; 29 | } 30 | printf("\nClock : "); 31 | printf("%02i:%02i:%02i", h,m,s); 32 | Sleep(d); 33 | s++; 34 | system("cls"); 35 | 36 | } 37 | 38 | 39 | } -------------------------------------------------------------------------------- /downloadeffect/download.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main(void){ 5 | 6 | 7 | int prog=10; 8 | int duration = 300; 9 | int i ; 10 | 11 | //todo need to make the counter beside the # download prograsse 12 | for (i = 0; i < prog; i++) 13 | { 14 | 15 | printf("#"); 16 | Sleep(duration); 17 | } 18 | 19 | printf("%i ",i); 20 | 21 | } -------------------------------------------------------------------------------- /practice/ControlFlow.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(void){ 4 | int i=10; 5 | 6 | // for (i = 1; i < 11; ++i) 7 | // { 8 | // printf("%d ", i); 9 | // } 10 | 11 | // int num, count, sum = 0; 12 | 13 | // printf("Enter a positive integer: "); 14 | // scanf("%d", &num); 15 | 16 | // for loop terminates when num is less than count 17 | // for(count = 1; count <= num; ++count) 18 | // { 19 | // sum += count; 20 | // } 21 | 22 | // printf("Sum = %d", sum); 23 | 24 | while (i <= 5) { 25 | printf("%d\n", i); 26 | if(i==3){ 27 | continue; 28 | } 29 | if(i==5){ 30 | break; 31 | } 32 | ++i; 33 | } 34 | 35 | } -------------------------------------------------------------------------------- /practice/Youcode.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elhajuojy/C-Programming-Guide/eaa468bc13d5e08854d6ec65f51fa847f792686d/practice/Youcode.c -------------------------------------------------------------------------------- /practice/calc.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | int main(void){ 4 | char op[5] ; 5 | int a,b; 6 | 7 | printf("please entre the first number"); 8 | scanf("%d",&a); 9 | printf("please entre the second number"); 10 | scanf("%d",&b); 11 | 12 | printf("chose your operator : "); 13 | scanf("%s",&op); 14 | // 15 | if (strcmp(op, "+") == 0) 16 | { 17 | printf("%d",a+b); 18 | } 19 | else if(strcmp(op, "-") == 0){ 20 | printf("%d",a-b); 21 | } 22 | else if(strcmp(op, "*") == 0){ 23 | printf("%d",a*b); 24 | 25 | }else if(strcmp(op, "/") == 0){ 26 | printf("%d",a/b); 27 | 28 | } 29 | else{ 30 | printf("nothing else"); 31 | } 32 | 33 | 34 | } 35 | 36 | -------------------------------------------------------------------------------- /practice/calcAvg.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void main(){ 4 | 5 | int len; 6 | double avg; 7 | int sum=0; 8 | 9 | printf("Please Entre the number element you want :"); 10 | scanf("%d",&len); 11 | int elements[len]; 12 | for (int i = 0; i < len; i++) 13 | { 14 | printf("please entre element %d : ",i+1); 15 | scanf("%d",&elements[i]); 16 | sum +=elements[i]; 17 | 18 | } 19 | 20 | avg = sum/len; 21 | printf("avg is %lf",avg); 22 | 23 | // C Multidimensional Arrays 24 | 25 | } -------------------------------------------------------------------------------- /practice/calcSwitch.c: -------------------------------------------------------------------------------- 1 | // Program to create a simple calculator 2 | #include 3 | 4 | int main() { 5 | char operation; 6 | double n1, n2; 7 | 8 | printf("Enter an operator (+, -, *, /): "); 9 | scanf("%c", &operation); 10 | printf("Enter two operands: "); 11 | scanf("%lf %lf",&n1, &n2); 12 | 13 | switch(operation) 14 | { 15 | case '+': 16 | printf("%.1lf + %.1lf = %.1lf",n1, n2, n1+n2); 17 | break; 18 | 19 | case '-': 20 | printf("%.1lf - %.1lf = %.1lf",n1, n2, n1-n2); 21 | break; 22 | 23 | case '*': 24 | printf("%.1lf * %.1lf = %.1lf",n1, n2, n1*n2); 25 | break; 26 | 27 | case '/': 28 | printf("%.1lf / %.1lf = %.1lf",n1, n2, n1/n2); 29 | break; 30 | // operator doesn't match any case constant +, -, *, / 31 | default: 32 | printf("Error! operator is not correct"); 33 | } 34 | 35 | return 0; 36 | } 37 | -------------------------------------------------------------------------------- /practice/goto.c: -------------------------------------------------------------------------------- 1 | // Program to calculate the sum and average of positive numbers 2 | // If the user enters a negative number, the sum and average are displayed. 3 | 4 | #include 5 | 6 | int main() { 7 | 8 | const int maxInput = 100; 9 | int i; 10 | double number, average, sum = 0.0; 11 | 12 | for (i = 1; i <= maxInput; ++i) { 13 | printf("%d. Enter a number: ", i); 14 | scanf("%lf", &number); 15 | 16 | // go to jump if the user enters a negative number 17 | if (number < 0.0) { 18 | goto jump; 19 | } 20 | sum += number; 21 | } 22 | 23 | jump: 24 | average = sum / (i - 1); 25 | printf("Sum = %.2f\n", sum); 26 | printf("Average = %.2f", average); 27 | 28 | return 0; 29 | } -------------------------------------------------------------------------------- /practice/lang.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(){ 4 | //simple app 5 | int age ; 6 | char name[20]; 7 | char reassoneWhy[100]; 8 | 9 | 10 | printf("your age please : \n"); 11 | scanf("%d",age); 12 | printf("your name please : \n"); 13 | scanf("%s",name); 14 | printf("your reasson for coming to youcode : \n"); 15 | scanf("%d",reassoneWhy); 16 | printf( "hello %s you age is %d and you came here because %s"); 17 | 18 | //calcaulter 19 | 20 | return 0; 21 | 22 | 23 | } -------------------------------------------------------------------------------- /practice/loops.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(){ 4 | int i =6; 5 | while (i<5) 6 | { 7 | printf("%d",i); 8 | } 9 | 10 | return 0; 11 | } 12 | 13 | 14 | -------------------------------------------------------------------------------- /practice/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main(){ 3 | 4 | //Variables 5 | int playerScore = 95; 6 | 7 | // change value of varaible 8 | char ch = 'a'; 9 | // some code 10 | ch = 'l'; 11 | 12 | // Literals 13 | int age = 22; 14 | float pi = 3.14; 15 | double note =17.55; 16 | char name[] = "Mehdi"; 17 | 18 | //constants 19 | const int age = 22; 20 | 21 | short a; 22 | long b; 23 | long long c; 24 | long double d; 25 | 26 | printf("size of short = %d bytes\n", sizeof(a)); 27 | printf("size of long = %d bytes\n", sizeof(b)); 28 | printf("size of long long = %d bytes\n", sizeof(c)); 29 | printf("size of long double= %d bytes\n", sizeof(d)); 30 | 31 | // C Input Output (I/O) 32 | int testInteger = 5; 33 | printf("Number = %d", testInteger); 34 | char chr = 'a'; 35 | printf("character = %c", chr); 36 | 37 | 38 | 39 | return 0; 40 | 41 | } -------------------------------------------------------------------------------- /practice/prefectNumber.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int main(){ 6 | int x,sum; 7 | 8 | printf("please entre the number"); 9 | scanf("%d",&x); 10 | sum =0; 11 | for(int i=1;i",i); 16 | sum=sum+i; 17 | } 18 | } 19 | 20 | if (x==sum) 21 | { 22 | printf("number est parfait %d =%d",sum,x); 23 | }else{ 24 | printf("number est non parfait %d =%d",sum,x); 25 | 26 | } 27 | 28 | 29 | 30 | return 0; 31 | } -------------------------------------------------------------------------------- /practice/static.c: -------------------------------------------------------------------------------- 1 | #include 2 | void display(); 3 | 4 | int main() 5 | { 6 | display(); 7 | display(); 8 | } 9 | 10 | //The value of a static variable persists until the end of the program. 11 | void display() 12 | { 13 | static int c = 1; 14 | c += 5; 15 | printf("%d ",c); 16 | } 17 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | # Guide to C Programming Langauge📕🧑‍💻 2 | 3 | ## in this repository you will find so many topics and practice file that can achieve your way of learning c language💕🪶 4 | 5 | C is a powerful general-purpose programming language. It can be used to develop software like operating systems, databases, compilers, and so on. C programming is an excellent language to learn to program for beginners 6 | 7 | ## topics 🗞️ 8 | 9 | 1. ### C introduction 10 | 11 | - Variables & Constants 12 | - C Data Types 13 | - C input/Output 14 | - C Operators 15 | 16 | 2. ### C Flow Control 17 | 18 | - if.. else 19 | - for loop 20 | - while loop 21 | - c break and continue 22 | - switch ..case 23 | 24 | 3. ### C Functions 25 | 26 | - Functions 27 | - Function Type 28 | - Rescursion 29 | - Storage 30 | 31 | 4. ### C Arrays 32 | 33 | - Arrays and Multi-dimensional arrays 34 | - Arrays & Function 35 | 36 | 5. ### C Pointers 37 | 38 | - Pointers 39 | - Poitner & Function 40 | - Memory Allocation 41 | 42 | 6. ### C String 43 | 44 | - String Function 45 | 46 | 7. ### Structure And Union 47 | 48 | - Structure 49 | - Struct & Poitners 50 | - Struct & Function 51 | - Unions 52 | 53 | 8. ### C Files 54 | 55 | - input/Output 56 | 57 | 9. ### Additional Topics 58 | 59 | - Enumeration 60 | - Preprocessors 61 | - Standard Libaray 62 | 63 | ## Links 64 | 65 | - 📫 How to reach me **elhajuojye@gmail.com** 66 | -------------------------------------------------------------------------------- /recursion/recursion.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void draw(int n); 4 | 5 | void main(){ 6 | 7 | int heghit ; 8 | printf("pleasse entre the heghit "); 9 | scanf("%d",&heghit); 10 | draw(heghit); 11 | } 12 | 13 | void draw(int n ){ 14 | if (n<=0) 15 | { 16 | return ; 17 | } 18 | 19 | draw(n-1); 20 | 21 | for (int i = 0; i < n ; i++) 22 | { 23 | printf("🎒"); 24 | } 25 | 26 | printf("\n"); 27 | } -------------------------------------------------------------------------------- /searching algorithms/LinearSearch.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | 4 | int main(){ 5 | int table[]= {1,99,100,8,0,9,0}; 6 | int size = sizeof table / sizeof table[0]; 7 | int n ; 8 | int found = 0; 9 | printf("please entre one number :"); 10 | scanf("%d",&n); 11 | for (int i = 0; i < size ; i++) 12 | { 13 | if (table[i]==n) 14 | { 15 | found = 1; 16 | break; 17 | } 18 | 19 | 20 | } 21 | found==0?printf("the number is not found "): 22 | printf("the number is found %d ",n); 23 | 24 | 25 | return 0; 26 | } -------------------------------------------------------------------------------- /searching algorithms/binarysearch.c: -------------------------------------------------------------------------------- 1 | #include 2 | //varaibles global 3 | int table[] = {3,5,8,7,99,6,12,20,1}; 4 | int size = sizeof table / sizeof table[0]; 5 | 6 | void sort(); 7 | void binarySearch(int arry[],int low,int heghit,int key); 8 | 9 | int main(){ 10 | sort(); 11 | for (int i = 0; i < size; i++) 12 | { 13 | printf("|%d|",table[i]); 14 | } 15 | 16 | printf("\n"); 17 | int n = 0; 18 | int start =0; 19 | int end = size; 20 | printf("please entre one number :"); 21 | scanf("%d",&n); 22 | binarySearch(table,start,end,n); 23 | return 0; 24 | } 25 | 26 | void binarySearch(int arry[],int low,int heghit,int key){ 27 | 28 | int m = (low+heghit)/2; 29 | if (low>heghit) 30 | { 31 | printf("not found "); 32 | } 33 | else if(arry[m]==key) 34 | { 35 | printf("found "); 36 | }else if (arry[m]>key) 37 | { 38 | binarySearch(arry , low,m-1,key); 39 | } 40 | else if (arry[m] 2 | 3 | int main() { 4 | int i, j, numberOfRows, star ; 5 | printf("Please entre the number :"); 6 | scanf("%d", &numberOfRows); 7 | 8 | for (i = 0; i < numberOfRows; i++) { 9 | 10 | for (j = 0; j < (numberOfRows - i ); j++) { 11 | printf(" "); 12 | } 13 | 14 | star=0; 15 | while (star <= i+1) 16 | { 17 | printf("*"); 18 | star++; 19 | }; 20 | 21 | star = 0; 22 | printf("\n"); 23 | } 24 | return 0; 25 | } -------------------------------------------------------------------------------- /simple Library/source/youcodePrinter.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elhajuojy/C-Programming-Guide/eaa468bc13d5e08854d6ec65f51fa847f792686d/simple Library/source/youcodePrinter.c -------------------------------------------------------------------------------- /sorting algorithms/bubbleSort.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | 4 | // selection sort; 5 | int main(void){ 6 | int table[] = {3,5,8,7,99,6,12,20,1}; 7 | int size = sizeof table / sizeof table[0]; 8 | int temp ; 9 | 10 | for (int j = 0; j < size; j++) 11 | { 12 | for (int i = 1; i < size; i++) 13 | { 14 | if (table[i] 2 | 3 | //insertion sort 4 | int main(void){ 5 | int table[] = {3,5,8,7,99,6,12,20,1}; 6 | 7 | int size = sizeof table / sizeof table[0]; 8 | int min= 0; 9 | int max= 0; 10 | for (int i = 0; i table[j]){ 16 | max = table[i]; 17 | min = table[j]; 18 | table[j] = max; 19 | table[i] = min; 20 | } 21 | } 22 | } 23 | for (int i = 0; i < size; i++) 24 | { 25 | printf("|%d|",table[i]); 26 | } 27 | 28 | 29 | } -------------------------------------------------------------------------------- /sorting algorithms/selectionSort.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | 4 | // selection sort; 5 | int main(void){ 6 | int table[] = {3,5,8,7,99,6,12,20,1}; 7 | int size = sizeof table / sizeof table[0]; 8 | int posmin = 0; 9 | int valueofIndex = 0; 10 | for (int i = 0; i < size; i++) 11 | { 12 | for (int j = i+1; j < size; j++) 13 | { 14 | if (table[j] 2 | #include 3 | #include 4 | #include 5 | int main(void){ 6 | 7 | char name[20]; 8 | 9 | printf("please entre a name :"); 10 | scanf("%s",name); 11 | printf("HI , %s",toupper(name)); 12 | } -------------------------------------------------------------------------------- /testYouCode/fibonacciSequence.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | 4 | int fabonaccci(int n ) 5 | { 6 | if (n==0) 7 | { 8 | return n=n+ 0; 9 | } 10 | else if (n==1) 11 | { 12 | n=n+ 1; 13 | } 14 | else{ 15 | // printf(" n= %d",n); 16 | n= fabonaccci(n-1) +fabonaccci(n-2); 17 | } 18 | } 19 | 20 | int main() 21 | { 22 | 23 | int f ; 24 | printf("suite de fibonacci choose un number :"); 25 | scanf("%d",&f); 26 | 27 | int res = fabonaccci(f); 28 | 29 | printf("res %d",res); 30 | 31 | 32 | 33 | 34 | } --------------------------------------------------------------------------------