├── .gitignore ├── .vscode ├── c_cpp_properties.json ├── settings.json └── tasks.json ├── Banking_Program_C ├── ac_statements │ ├── 127101234.txt │ ├── 127102345.txt │ ├── 127103456.txt │ └── 127104567.txt ├── bank.h ├── bank_main.c └── banking_func.c ├── C Programs ├── CProgram.c ├── Clg_Practicals │ ├── Decimal-Binary.c │ ├── Matrix_add.c │ ├── ascenting_order.c │ ├── electricity_bill.c │ ├── floids_triangle.c │ ├── palindrome.c │ ├── prime.c │ ├── prime_number.c │ ├── pyramid_of_numbers.c │ └── sum_of_digit.c ├── HelloWorld.c ├── MessageBot.c ├── StudentList.c ├── StudentsMark.c ├── Voding_Booth.c ├── alphabet position testing.c ├── binary triangle 2.c ├── binary triangle 3.c ├── binary triangle.c ├── c_server.c ├── check dividable num.c ├── check number positive or negative.c ├── check_int.c ├── check_the_even_num_array.c ├── diamond_pyramid.c ├── distance bvn two citties.c ├── factorial of num.c ├── file_reading.c ├── file_writing.c ├── floids_triangle.c ├── frequency_of_number.c ├── greatest_and_smallest_num_array.c ├── gross glosary.c ├── hallow_triangle.c ├── hashtable.c ├── lab.c ├── leep_year_checking_code.c ├── lines.c ├── multi_returns.c ├── multiplication_table.c ├── number_pyramid.c ├── number_range.c ├── number_triangle.c ├── numeric triangle 2.c ├── numeric triangle 3.c ├── numeric triangle 4.c ├── odd or even num.c ├── palindrome.c ├── pattern.c ├── pattern_using_if.c ├── pointers.c ├── practice.c ├── prime_number.c ├── primenumber.c ├── pyramid_triangle.c ├── read_full_fille.c ├── recursion.c ├── rev array.c ├── reversenumber.c ├── scanf_f.c ├── simple calculator.c ├── snakegame.c ├── string in structure.c ├── string.c ├── structure.c ├── studentslist.c ├── sum if the first n natural numbers.c ├── sum of digits.c ├── swap_number.c ├── tem into cdegrees.c ├── tempCodeRunnerFile.c ├── test.c ├── test.txt ├── test1.c ├── test2.txt ├── test3.txt ├── test4.txt ├── testing.c ├── voting.c └── voting_age.c └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | # Prerequisites 2 | *.d 3 | 4 | # Object files 5 | *.o 6 | *.ko 7 | *.obj 8 | *.elf 9 | 10 | # Linker output 11 | *.ilk 12 | *.map 13 | *.exp 14 | 15 | # Precompiled Headers 16 | *.gch 17 | *.pch 18 | 19 | # Libraries 20 | *.lib 21 | *.a 22 | *.la 23 | *.lo 24 | 25 | # Shared objects (inc. Windows DLLs) 26 | *.dll 27 | *.so 28 | *.so.* 29 | *.dylib 30 | 31 | # Executables 32 | *.exe 33 | *.out 34 | *.app 35 | *.i*86 36 | *.x86_64 37 | *.hex 38 | 39 | # Debug files 40 | *.dSYM/ 41 | *.su 42 | *.idb 43 | *.pdb 44 | 45 | # Kernel Module Compile Results 46 | *.mod* 47 | *.cmd 48 | .tmp_versions/ 49 | modules.order 50 | Module.symvers 51 | Mkfile.old 52 | dkms.conf -------------------------------------------------------------------------------- /.vscode/c_cpp_properties.json: -------------------------------------------------------------------------------- 1 | { 2 | "configurations": [ 3 | { 4 | "name": "Win32", 5 | "includePath": [ 6 | "${workspaceFolder}/**" 7 | ], 8 | "defines": [ 9 | "_DEBUG", 10 | "UNICODE", 11 | "_UNICODE" 12 | ], 13 | "cStandard": "c11", 14 | "cppStandard": "gnu++14", 15 | "intelliSenseMode": "windows-gcc-x86" 16 | } 17 | ], 18 | "version": 4 19 | } -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "C_Cpp.errorSquiggles": "disabled", 3 | "files.associations": { 4 | "*.embeddedhtml": "html", 5 | "stdio.h": "c", 6 | "bank.h": "c" 7 | } 8 | } -------------------------------------------------------------------------------- /.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | "tasks": [ 3 | { 4 | "type": "cppbuild", 5 | "label": "C/C++: gcc.exe build active file", 6 | "command": "C:\\MinGW\\bin\\gcc.exe", 7 | "args": [ 8 | "-fdiagnostics-color=always", 9 | "-g", 10 | "${file}", 11 | "-o", 12 | "${fileDirname}\\${fileBasenameNoExtension}.exe" 13 | ], 14 | "options": { 15 | "cwd": "${fileDirname}" 16 | }, 17 | "problemMatcher": [ 18 | "$gcc" 19 | ], 20 | "group": { 21 | "kind": "build", 22 | "isDefault": true 23 | }, 24 | "detail": "Task generated by Debugger." 25 | } 26 | ], 27 | "version": "2.0.0" 28 | } -------------------------------------------------------------------------------- /Banking_Program_C/ac_statements/127101234.txt: -------------------------------------------------------------------------------- 1 | ************************* 2 | Banking Statement 3 | ************************* 4 | 5 | Name: Vijay R 6 | Ac No: 127101234 7 | Email: vijayr@gmail.ac.in 8 | Phone: 73394800000 9 | 10 | --------------------------------------------------------------------------------- 11 | Date Description Transaction Type Amount (Rs) Balance (Rs) 12 | --------------------------------------------------------------------------------- 13 | 06-07-2024 Initial Deposit Credit 10000 10000 14 | 06-07-2024 Withdrawal Deposit 500 9500 15 | 06-07-2024 Deposit Credit 1000 10500 16 | 07-07-2024 Deposit Credit 1500 12000 17 | 08-07-2024 Deposit Credit 1300 13300 18 | 08-07-2024 Deposit Credit 1500 14800 19 | 08-07-2024 Withdrawal Debit 1000 13800 20 | 29-10-2024 Deposit Credit 500 14300 21 | -------------------------------------------------------------------------------- /Banking_Program_C/ac_statements/127102345.txt: -------------------------------------------------------------------------------- 1 | ************************* 2 | Banking Statement 3 | ************************* 4 | 5 | Name: Gopinath R 6 | Ac No: 127102345 7 | Email: gopinath@gmail.ac.in 8 | Phone: 9629630000 9 | 10 | --------------------------------------------------------------------------------- 11 | Date Description Transaction Type Amount (Rs) Balance (Rs) 12 | --------------------------------------------------------------------------------- 13 | 06-02-2024 Initial Deposit Credit 20000 20000 14 | 08-02-2024 Withdrawal Debit 5000 15000 15 | 12-02-2024 Deposit Credit 1000 16000 16 | 10-03-2024 Deposit Credit 3500 19500 17 | 10-03-2024 Withdrawal Debit 2000 17500 18 | 08-07-2024 Deposit Credit 2500 20000 19 | 08-07-2024 Withdrawal Debit 1500 18500 20 | 09-07-2024 Deposit Credit 1500 20000 21 | 09-07-2024 Withdrawal Debit 500 19500 22 | -------------------------------------------------------------------------------- /Banking_Program_C/ac_statements/127103456.txt: -------------------------------------------------------------------------------- 1 | ************************* 2 | Banking Statement 3 | ************************* 4 | 5 | Name: Ram M 6 | Ac No: 127103456 7 | Email: Ramachandran@gmail.ac.in 8 | Phone: 9097450900 9 | 10 | --------------------------------------------------------------------------------- 11 | Date Description Transaction Type Amount (Rs) Balance (Rs) 12 | --------------------------------------------------------------------------------- 13 | 01-03-2024 Initial Deposit Credit 10000 10000 14 | 02-03-2024 Deposit Credit 1000 11000 15 | 04-03-2024 Deposit Credit 2000 13000 16 | 07-03-2024 Withdrawal Dedit 500 12500 17 | 12-04-2024 Withdrawal Debit 1000 11500 18 | -------------------------------------------------------------------------------- /Banking_Program_C/ac_statements/127104567.txt: -------------------------------------------------------------------------------- 1 | ************************* 2 | Banking Statement 3 | ************************* 4 | 5 | Name: Hariharan M 6 | Ac No: 127104567 7 | Email: hariharan@gmail.ac.in 8 | Phone: 9384560000 9 | 10 | --------------------------------------------------------------------------------- 11 | Date Description Transaction Type Amount (Rs) Balance (Rs) 12 | --------------------------------------------------------------------------------- 13 | 01-01-2024 Initial Deposit Credit 5000 5000 14 | 02-01-2024 Deposit Credit 1000 6000 15 | 03-01-2024 Withdrawal Dedit 500 5500 16 | 05-01-2024 Deposit Credit 2000 7500 17 | -------------------------------------------------------------------------------- /Banking_Program_C/bank.h: -------------------------------------------------------------------------------- 1 | #ifndef BANK_H 2 | #define BANK_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | // define constants or macros 11 | #define Length 55 12 | #define MaxLength 255 13 | 14 | struct Users { // create a structure for store the user credential 15 | int account_no; 16 | char user_name[Length]; 17 | char password[Length]; 18 | }; 19 | 20 | // Function Declarations 21 | void welcome(); 22 | void login(); 23 | void UserOptions(); 24 | char* getCurrentDate(); 25 | void userDetails(bool UserLogged, int UserIndex); 26 | void UserProfile(int UserIndex); 27 | void printStatment(int ac_no); 28 | float balanceCheck(int ac_no); 29 | void deposit(int ac_no); 30 | void withdraw(int ac_no, int UserIndex); 31 | bool depositPrint(int ac_no, int amount); 32 | bool withdrawPrint(int ac_no, int amount); 33 | void logout(); 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /Banking_Program_C/bank_main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "banking_func.c" 3 | 4 | void main(){ 5 | 6 | welcome(); // call the welcome function from banking_func.c file 7 | login(); // call the login function from banking_func.c file 8 | 9 | } -------------------------------------------------------------------------------- /Banking_Program_C/banking_func.c: -------------------------------------------------------------------------------- 1 | #include "bank.h" 2 | 3 | struct Users users[] = { // call the struct to assign the values 4 | {127101234, "Vijay", "vijay@123"}, 5 | {127102345, "Gopi", "gopi@123"}, 6 | {127103456, "Ram", "ram@123"}, 7 | {127104567, "Hari", "hari@123"} 8 | }; 9 | 10 | // Function definition 11 | void welcome(){ // Function without parameter and no return value 12 | printf("===========================================\n"); 13 | printf("\t Welcome to Banking App \n"); 14 | printf("===========================================\n"); 15 | } 16 | 17 | void login() 18 | { 19 | 20 | char re; 21 | char username[Length]; 22 | char password[Length]; 23 | int userIndex; 24 | int usercount = sizeof(users) / sizeof(users[0]); // calculate the usercount 25 | int TryPass = 0; 26 | // printf("Total users: %d\n",usercount); 27 | 28 | login: // create label for goto 29 | printf("\nEnter the user name: "); 30 | scanf("%s", username); 31 | 32 | bool userFound = false; 33 | for (int i = 0; i < usercount; i++) { 34 | if (strcmp(username, users[i].user_name) == 0) { // users[i].user_name used to call the username in the index i 35 | userFound = true; 36 | userIndex = i; 37 | break; 38 | } 39 | } 40 | 41 | if (userFound) { 42 | printf("User Found\n"); 43 | 44 | password: 45 | printf("Enter the password: "); 46 | scanf("%s", &password); 47 | 48 | if (strcmp(users[userIndex].password, password) == 0) // strcmp == 0 used to compare two string 49 | { 50 | system("cls"); // Clear the terminal 51 | printf("User Logged Successful\n"); // Print msg to ensure the user logged 52 | bool userLogged = true; // assign userLogged into true to check the user 53 | userDetails(userLogged,userIndex); // call the userDetails function to move further option 54 | } 55 | else 56 | { 57 | printf("Password Wrong!\n\n"); 58 | TryPass++; // TryPass variable used to count the given wrong passwords 59 | if(TryPass == 4){ 60 | printf("You have exceeded the number of attempts!!!\n"); 61 | exit(1); // used to terminate the entire program 62 | 63 | } 64 | goto password; // used to go for the particular label line 65 | } 66 | } 67 | 68 | else { 69 | printf("User Not Found\n"); 70 | printf("Retry (Y/N): "); 71 | scanf(" %c", &re); 72 | 73 | if(re != 'n' && re != 'N') 74 | goto login; 75 | else 76 | exit(1); 77 | } 78 | } 79 | 80 | void userDetails(bool UserLogged, int UserIndex){ // Function with parameter and no return value 81 | if(UserLogged){ 82 | int option; 83 | char cont; 84 | 85 | UserOptions(); // call UserOptions to print the Options 86 | 87 | printf("Enter your choice: "); 88 | scanf("%d", &option); 89 | 90 | switch (option) 91 | { 92 | case 1: 93 | printf("\nYour Balance is: %.2f\n", balanceCheck(users[UserIndex].account_no)); // De 94 | break; 95 | case 2: 96 | UserProfile(UserIndex); 97 | break; 98 | case 3: 99 | printStatment(users[UserIndex].account_no); 100 | break; 101 | case 4: 102 | deposit(users[UserIndex].account_no); 103 | break; 104 | case 5: 105 | withdraw(users[UserIndex].account_no, UserIndex); 106 | break; 107 | default: 108 | printf("Invalid Option\n"); 109 | break; 110 | } 111 | 112 | cont_check: 113 | printf("\nContinue (C)/ Logout(L): "); 114 | scanf(" %c", &cont); 115 | 116 | if(cont == 'C' || cont == 'c'){ 117 | system("cls"); 118 | userDetails(UserLogged,UserIndex); // Recursion Function 119 | } 120 | else if(cont == 'L' || cont == 'l') 121 | logout(); 122 | else{ 123 | printf("Invalid Input\n"); 124 | goto cont_check; 125 | } 126 | } 127 | } 128 | 129 | void UserOptions(){ 130 | 131 | printf("--- User Menu ---\n"); 132 | printf("1. Check Bank Balance.\n"); 133 | printf("2. View User Details.\n"); 134 | printf("3. Check account statement\n"); 135 | printf("4. Deposit Money.\n"); 136 | printf("5. Withdraw Money.\n"); 137 | 138 | } 139 | 140 | void UserProfile(int UserIndex){ 141 | 142 | system("cls"); 143 | printf("\n===================\n"); 144 | printf("***** Profile *****\n"); 145 | printf("===================\n\n"); 146 | 147 | printf("User Name: %s\n", users[UserIndex].user_name); 148 | printf("Account Number: %d\n", users[UserIndex].account_no); 149 | printf("User Balance: %.2f\n", balanceCheck(users[UserIndex].account_no)); 150 | } 151 | 152 | void logout(){ 153 | 154 | char check; 155 | 156 | printf("\nYou have successfully logged out."); 157 | printf("\nLogin(Y) / Exit(N): "); 158 | while ((getchar()) != '\n'); // Clear the input buffer before using scanf 159 | scanf("%c", &check); 160 | 161 | if(check == 'Y' || check == 'y'){ 162 | system("cls"); 163 | login(); 164 | } 165 | else{ 166 | system("cls"); 167 | printf("Thank you for using our services.\n"); 168 | exit(1); 169 | } 170 | } 171 | 172 | float balanceCheck(int ac_no){ // Function with parameter and return value 173 | 174 | FILE *fp; // create a fp FILE pointer to access the files 175 | char line[MaxLength]; 176 | char *balanceStr; 177 | char *token; 178 | char filename[Length]; 179 | float balance; 180 | 181 | sprintf(filename, "./ac_statements/%d.txt",ac_no); // concat the string and int 182 | 183 | fp = fopen(filename, "r"); // open the file and assign the address in fp 184 | 185 | if (fp == NULL) // check the file NULL or not 186 | perror("Account not found"); // display error messages 187 | 188 | while (fgets(line, MaxLength, fp) != NULL) { // Read each line until the end of file 189 | 190 | // Split the line into tokens separated by whitespace 191 | token = strtok(line, " \t\n"); // used to tokenize (split) strings into smaller tokens based on a delimiter 192 | 193 | while (token != NULL) { // Traverse to the last token in the line 194 | balanceStr = token; // Update lastWord to the current token because we give the balance in last 195 | token = strtok(NULL, " \t\n"); // Get the next token 196 | } 197 | } 198 | 199 | fclose(fp); // Close the file 200 | 201 | balance = atof(balanceStr); // convert ascii into float (atoi - convert into int) 202 | 203 | return balance; 204 | 205 | } 206 | 207 | void printStatment(int ac_no) 208 | { 209 | 210 | system("cls"); 211 | char filename[Length]; 212 | char statement[MaxLength]; 213 | 214 | sprintf(filename, "./ac_statements/%d.txt", ac_no); // concat the string and int 215 | 216 | FILE *st = fopen(filename, "r"); // also we directly open the file in the FILE declaration 217 | printf("\n"); 218 | 219 | if(st == NULL) perror("No statement Available"); // Check if the file exists or not 220 | 221 | while(fgets(statement, sizeof(statement), st)){ 222 | printf("%s", statement); 223 | } 224 | 225 | } 226 | 227 | void deposit(int ac_no){ 228 | 229 | int amount; 230 | char confirm; 231 | 232 | printf("Enter the amount you want to deposit: "); 233 | scanf("%d", &amount); 234 | system("cls"); 235 | 236 | printf("Are you sure want to deposit %d? (y/n): ", amount); 237 | scanf(" %c", &confirm); 238 | system("cls"); 239 | 240 | if(confirm == 'y' || confirm == 'Y'){ 241 | 242 | bool deposited = depositPrint(ac_no, amount); 243 | 244 | if(deposited) 245 | printf("Amount deposited successfully\n"); 246 | else 247 | printf("Deposit failed\n"); 248 | } 249 | else 250 | printf("Deposit cancelled\n"); 251 | } 252 | 253 | void withdraw(int ac_no, int userIndex){ 254 | int amount, TryPass = 0; 255 | float balance; 256 | char confirm, password[Length]; 257 | balance = balanceCheck(ac_no); 258 | 259 | CashWithdraw: 260 | system("cls"); 261 | printf("Your Balance is: %.2f\n", balance); 262 | printf("Enter the amount you want to withdraw: "); 263 | scanf("%d", &amount); 264 | system("cls"); 265 | 266 | if(amount <= balance){ 267 | printf("Are you sure want to withdraw %d? (y/n): ", amount); 268 | scanf(" %c",&confirm); 269 | 270 | if(confirm == 'y' || confirm == 'Y'){ 271 | printf("\nEnter the \"Password\" to Confirm Withdraw \n"); 272 | 273 | password: 274 | printf("Enter your password: "); 275 | scanf("%s", &password); 276 | 277 | if (strcmp(users[userIndex].password, password) == 0) // strcmp == 0 used to compare two string 278 | { 279 | system("cls"); 280 | bool withdrawed = withdrawPrint(ac_no, amount); 281 | 282 | if(withdrawed) 283 | printf("Withdrawal Successful\n"); 284 | else 285 | printf("Withdraw failed"); 286 | } 287 | else 288 | { 289 | 290 | printf("Password Wrong! Try Again... \n\n"); 291 | TryPass++; // TryPass variable used to count the given wrong passwords 292 | if(TryPass == 4){ 293 | printf("You have exceeded the number of attempts!!!\n"); 294 | exit(1); // used to terminate the entire program 295 | 296 | } 297 | goto password; // used to go for the particular label line 298 | } 299 | } 300 | else 301 | printf("Withdraw cancelled\n"); 302 | } 303 | else 304 | printf("Insufficient Balance\n"); 305 | 306 | } 307 | 308 | 309 | bool depositPrint(int ac_no, int amount){ 310 | 311 | char filename[55]; 312 | FILE *dp; 313 | 314 | sprintf(filename, "./ac_statements/%d.txt", ac_no); 315 | 316 | dp = fopen(filename, "a"); // append the file 317 | if (dp == NULL) { 318 | perror("Error opening file"); 319 | return false; 320 | } 321 | int balance = balanceCheck(ac_no) + amount; 322 | 323 | fprintf(dp, "%s\tDeposit\t\t Credit\t\t%d \t %d\n", getCurrentDate(), amount, balance); 324 | 325 | fclose(dp); 326 | return true; 327 | 328 | } 329 | 330 | bool withdrawPrint(int ac_no, int amount){ 331 | 332 | char filename[55]; 333 | FILE *dp; 334 | 335 | sprintf(filename, "./ac_statements/%d.txt", ac_no); 336 | 337 | dp = fopen(filename, "a"); // append the file 338 | if (dp == NULL) { 339 | perror("Error opening file"); 340 | return false; 341 | } 342 | int balance = balanceCheck(ac_no) - amount; 343 | 344 | fprintf(dp, "%s\tWithdrawal\t Debit\t\t%d \t %d\n", getCurrentDate(), amount, balance); 345 | 346 | fclose(dp); 347 | return true; 348 | 349 | } 350 | 351 | char* getCurrentDate() { // Function with return value and No Parameter 352 | static char date[80]; // Static array to hold the date string 353 | time_t t = time(NULL); 354 | struct tm *tmp = localtime(&t); 355 | 356 | strftime(date, sizeof(date), "%d-%m-%Y", tmp); 357 | return date; 358 | } -------------------------------------------------------------------------------- /C Programs/CProgram.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "lab.c" 3 | 4 | void main(){ 5 | //Prime(); 6 | Rev(); 7 | } 8 | -------------------------------------------------------------------------------- /C Programs/Clg_Practicals/Decimal-Binary.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(){ 4 | 5 | int num,i,k,a[10]; 6 | 7 | printf("Enter the Number:"); 8 | scanf("%d",&num); 9 | 10 | i = 1; 11 | 12 | while(num > 0){ 13 | a[i] = num%2; 14 | num /= 2; 15 | i++; 16 | } 17 | printf("Before i:%d\n",i); 18 | i--; 19 | printf("after i:%d\n",i); 20 | 21 | printf("Binary Number of given number is: "); 22 | for(k=i;k>0;k--){ 23 | printf("%d",a[k]); 24 | } 25 | 26 | } -------------------------------------------------------------------------------- /C Programs/Clg_Practicals/Matrix_add.c: -------------------------------------------------------------------------------- 1 | # -------------------------------------------------------------------------------- /C Programs/Clg_Practicals/ascenting_order.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void main(){ 4 | 5 | int i,j,t,n,a[10]; 6 | 7 | printf("Enter the number of N:"); 8 | scanf("%d",&n); 9 | 10 | for(i=1;i<=n;i++){ 11 | printf("Enter Number %d:",i); 12 | scanf("%d",&a[i]); 13 | } 14 | 15 | for(i=1;i<=n;i++){ 16 | for(j=i;j<=n;j++){ 17 | 18 | if(a[i] > a[j]){ 19 | 20 | t = a[i]; 21 | a[i] = a[j]; 22 | a[j] = t; 23 | 24 | } 25 | } 26 | } 27 | 28 | 29 | printf("Ascending Order of Givem Number: "); 30 | for(i=1;i<=n;i++){ 31 | printf("%d ",a[i]); 32 | 33 | } 34 | 35 | } -------------------------------------------------------------------------------- /C Programs/Clg_Practicals/electricity_bill.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(){ 4 | 5 | int cr,pr,units,netunits,n,cn; 6 | float charges; 7 | 8 | printf("\nTAMIL NADU ELECTRICITY BOARD CASH BILL\n\n"); 9 | 10 | printf("Customer Number: "); 11 | scanf("%d",&cn); 12 | 13 | printf("Bill Number: "); 14 | scanf("%d",&n); 15 | 16 | printf("Particulars\n"); 17 | 18 | printf("Current Reading: "); 19 | scanf("%d",&cr); 20 | 21 | printf("Previous Reading: "); 22 | scanf("%d",&pr); 23 | 24 | units = cr - pr; 25 | 26 | printf("The Units consumed by the Customer is %d\n",units); 27 | 28 | if(units <= 100){ 29 | 30 | charges = (units*1); 31 | } 32 | else if(units > 100 && units <= 200){ 33 | 34 | netunits = units - 100; 35 | charges = (netunits * 2 + 100); 36 | 37 | } 38 | else if(units > 200 && units <= 300){ 39 | 40 | netunits = units - 200; 41 | charges = (netunits * 3 + 300); 42 | } 43 | else if(units > 300 && units <= 400){ 44 | 45 | netunits = units - 300; 46 | charges = (netunits * 4 + 600); 47 | } 48 | else if(units > 400){ 49 | 50 | netunits = units - 400; 51 | charges = (netunits * 7 + 1000); 52 | } 53 | 54 | printf("The charges for the customer is : %f",charges); 55 | 56 | } 57 | -------------------------------------------------------------------------------- /C Programs/Clg_Practicals/floids_triangle.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(){ 4 | 5 | int i,j,t=1,rows; 6 | 7 | printf("Enter the Number of n"); 8 | scanf("%d",&rows); 9 | 10 | for(i=1;i<=rows;i++){ 11 | for(j=1;j<=i;j++){ 12 | printf("%d ",t); 13 | t++; 14 | } 15 | printf("\n"); 16 | 17 | } 18 | return 0; 19 | } -------------------------------------------------------------------------------- /C Programs/Clg_Practicals/palindrome.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void main(){ 4 | 5 | int n,s=0,r,t; 6 | 7 | printf("Enter the number: "); 8 | scanf("%d",&n); 9 | 10 | t = n; 11 | 12 | while(n>0){ 13 | 14 | r = n % 10; 15 | s = (s * 10) + r; 16 | n = n / 10; 17 | } 18 | 19 | if(t == s) 20 | printf("%d is a Palindrome",t); 21 | else 22 | printf("%d is not a Palindrome",t); 23 | 24 | } -------------------------------------------------------------------------------- /C Programs/Clg_Practicals/prime.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void main() 4 | { 5 | int n,i=1,k=0; 6 | 7 | printf("\n Enter the any number"); 8 | scanf("%d",&n); 9 | 10 | while(i<=n) 11 | { 12 | 13 | if(n%i==0) 14 | k++; 15 | i++; 16 | 17 | } 18 | 19 | if(k==2) 20 | printf("%d is a prime number",n); 21 | 22 | else 23 | printf("%d is a not prime number",n); 24 | 25 | } 26 | 27 | -------------------------------------------------------------------------------- /C Programs/Clg_Practicals/prime_number.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void main(){ 4 | 5 | int i=1,n,k=0; 6 | 7 | printf("Enter the Number: "); 8 | scanf("%d",&n); 9 | 10 | while(i<=n){ 11 | if(n%i == 0) 12 | k++; 13 | i++; 14 | } 15 | 16 | if(k==2) 17 | printf("Prime Number"); 18 | else 19 | printf("Not a Prime Number"); 20 | 21 | } -------------------------------------------------------------------------------- /C Programs/Clg_Practicals/pyramid_of_numbers.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void main(){ 4 | 5 | int i,j,k,s,rows,t=1; 6 | 7 | printf("Enter the Number of rows: "); 8 | scanf("%d",&rows); 9 | 10 | for(i=1;i<=rows;i++){ 11 | for(j=1;j<=(rows-i);j++) 12 | printf(" "); 13 | 14 | s = (i*2) - 1; 15 | 16 | for(k=1;k<=s;k++){ 17 | 18 | if(t<10) 19 | printf(" %d",t); 20 | else 21 | printf("%d ",t); 22 | t++; 23 | } 24 | printf("\n\n"); 25 | } 26 | } -------------------------------------------------------------------------------- /C Programs/Clg_Practicals/sum_of_digit.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void main(){ 4 | 5 | int n,s=0,r,n1=0; 6 | 7 | 8 | printf("Enter the Number: "); 9 | scanf("%d",&n); 10 | 11 | n1 = n; 12 | 13 | while(n>0){ 14 | r = n % 10; 15 | s = s + r; 16 | n = n / 10; 17 | } 18 | 19 | printf("Sum of Digit of %d is %d",n1,s); 20 | 21 | } -------------------------------------------------------------------------------- /C Programs/HelloWorld.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main(){ 3 | 4 | int num = 27101236; 5 | 6 | printf("%d ",num); 7 | 8 | return 0; 9 | } -------------------------------------------------------------------------------- /C Programs/MessageBot.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | void sendMsg(const char* msg, int n) { 5 | // Copy the message to the clipboard 6 | OpenClipboard(0); 7 | EmptyClipboard(); 8 | HGLOBAL hClipboardData = GlobalAlloc(GMEM_DDESHARE, strlen(msg) + 1); 9 | char* pchData = (char*)GlobalLock(hClipboardData); 10 | strcpy(pchData, msg); 11 | GlobalUnlock(hClipboardData); 12 | SetClipboardData(CF_TEXT, hClipboardData); 13 | CloseClipboard(); 14 | 15 | Sleep(3000); 16 | 17 | // Simulate key presses using the Windows API 18 | INPUT input; 19 | input.type = INPUT_KEYBOARD; 20 | input.ki.wScan = 0; 21 | input.ki.time = 0; 22 | input.ki.dwExtraInfo = 0; 23 | 24 | for (int i = 0; i < n; i++) { 25 | // Press and release CTRL+V to paste the message from clipboard 26 | input.ki.wVk = VK_CONTROL; 27 | input.ki.dwFlags = 0; 28 | SendInput(1, &input, sizeof(INPUT)); 29 | 30 | input.ki.wVk = 'V'; 31 | input.ki.dwFlags = 0; 32 | SendInput(1, &input, sizeof(INPUT)); 33 | 34 | input.ki.wVk = VK_CONTROL; 35 | input.ki.dwFlags = KEYEVENTF_KEYUP; 36 | SendInput(1, &input, sizeof(INPUT)); 37 | 38 | input.ki.wVk = 'V'; 39 | input.ki.dwFlags = KEYEVENTF_KEYUP; 40 | SendInput(1, &input, sizeof(INPUT)); 41 | 42 | // Press and release ENTER to send the message 43 | input.ki.wVk = VK_RETURN; 44 | input.ki.dwFlags = 0; 45 | SendInput(1, &input, sizeof(INPUT)); 46 | 47 | input.ki.wVk = VK_RETURN; 48 | input.ki.dwFlags = KEYEVENTF_KEYUP; 49 | SendInput(1, &input, sizeof(INPUT)); 50 | 51 | Sleep(500); 52 | } 53 | } 54 | 55 | int main() { 56 | char msg[100]; 57 | int n; 58 | 59 | printf("Enter the Msg: "); 60 | fgets(msg, sizeof(msg), stdin); 61 | 62 | printf("How many times to Send: "); 63 | scanf("%d", &n); 64 | 65 | // Remove the trailing newline character from the message 66 | msg[strcspn(msg, "\n")] = 0; 67 | 68 | sendMsg(msg, n); 69 | 70 | return 0; 71 | } 72 | -------------------------------------------------------------------------------- /C Programs/StudentList.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #define MAX 50 5 | 6 | struct student{ 7 | int num; 8 | int id; 9 | char name[10][10 ]; 10 | }; 11 | 12 | int main(){ 13 | 14 | char sub[10][10] = {"Tamil","English","Maths","Science","Social"}; 15 | struct student s1;//object for students; 16 | int i,m; 17 | char names[10][50]; 18 | int marks[100]; 19 | int tot_mark=0; 20 | 21 | printf("Enter number of Students: "); 22 | scanf("%d",&s1.num); 23 | getchar(); 24 | 25 | for(i=0;i 2 | #include 3 | 4 | #define MAX 50 5 | 6 | struct student{ 7 | int num; 8 | int id; 9 | char name[10][10]; 10 | }; 11 | 12 | int main(){ 13 | 14 | char sub[] = {"Tamil", "English", "Maths", "Science", "Social"}; 15 | struct student s1;//object for students; 16 | int i,a,n,b,k; 17 | char names[10][50]; 18 | 19 | 20 | printf("Enter number of Students: "); 21 | scanf("%d",&n); 22 | 23 | int marks[n][5]; 24 | int tot_mark[n]; 25 | getchar(); 26 | 27 | for(k = 0;k 2 | 3 | #define CANDIDATE_COUNT 4 | 5 | 6 | 7 | #define CANDIDATE1 "THALAPATHY VIJAY" 8 | #define CANDIDATE2 "JAMES BONT" 9 | #define CANDIDATE3 "TOM CRUZ" 10 | #define CANDIDATE4 "TONY STARK" 11 | 12 | int votesCount1=0,votesCount2=0,votesCount3=0,votesCount4=0,spoiledtvotes=0; 13 | 14 | void castVote(){ 15 | int choice; 16 | printf("\n\n###Please choose your Candidate ###\n\n"); 17 | printf("\n 1.%s",CANDIDATE1); 18 | printf("\n 2.%s",CANDIDATE2); 19 | printf("\n 3.%s",CANDIDATE3); 20 | printf("\n 4.%s",CANDIDATE4); 21 | printf("\n 5.%s","Nota"); 22 | 23 | printf("\n\n Input your choice(1-5):"); 24 | scanf("%d",&choice); 25 | 26 | switch(choice){ 27 | case1:votesCount1++;break; 28 | case2:votesCount2++;break; 29 | case3:votesCount3++;break; 30 | case4:votesCount4++;break; 31 | case5:spoiledtvotes++;break; 32 | default:printf("\n Error: Wrong Choice!! Please retry"); 33 | //Hold the screen 34 | getchar(); 35 | } 36 | printf("\n thanks for vote !!"); 37 | } 38 | 39 | void votesCount(){ 40 | printf("\n\n ### Voting Statics ###"); 41 | printf("\n %s - %d", CANDIDATE1, votesCount1); 42 | printf("\n %s - %d", CANDIDATE2, votesCount2); 43 | printf("\n %s - %d", CANDIDATE3, votesCount3); 44 | printf("\n %s - %d", CANDIDATE4, votesCount4); 45 | printf("\n %s - %d", "Spoiled Votes", spoiledtvotes); 46 | } 47 | 48 | void getLeadingCandidate(){ 49 | printf("\n\n ### Leading Candidate ###\n\n"); 50 | if(votesCount1>votesCount2 && votesCount1>votesCount3 && votesCount1>votesCount4) 51 | printf("[%s]",CANDIDATE1); 52 | else if(votesCount2>votesCount3 && votesCount2>votesCount4 && votesCount2>votesCount1) 53 | printf("[%s]",CANDIDATE2); 54 | else if(votesCount3>votesCount4 && votesCount3>votesCount2 && votesCount3>votesCount1) 55 | printf("[%s]",CANDIDATE3); 56 | else if(votesCount4>votesCount1 && votesCount4>votesCount2 && votesCount4>votesCount3) 57 | printf("[%s]",CANDIDATE4); 58 | else 59 | printf("-----Warning !!! No-win situation---"); 60 | 61 | } 62 | 63 | int main() 64 | { 65 | int i; 66 | int choice; 67 | do{ 68 | printf("\n\n ### Welcome to Election/Voting 2023 ####"); 69 | printf("\n\n 1. Cast The Vote"); 70 | printf("\n 2. Find Vote Count"); 71 | printf("\n 3. Find Leading Candidate"); 72 | printf("\n 0. Exit"); 73 | 74 | printf("\n\n Please enter your choice: "); 75 | scanf("%d",&choice); 76 | 77 | switch(choice) 78 | { 79 | case 1: castVote();break; 80 | case 2: votesCount();break; 81 | case 3: getLeadingCandidate();break; 82 | default: printf("\n Error: Invalid Choice"); 83 | } 84 | }while(choice!=0); 85 | 86 | //hold the screen 87 | getchar(); 88 | return 0; 89 | } 90 | -------------------------------------------------------------------------------- /C Programs/alphabet position testing.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | 6 | char alphabet; 7 | 8 | printf("enter the alphabet: "); 9 | scanf("%c",&alphabet); 10 | 11 | 12 | if(alphabet == 'a') 13 | { 14 | printf("%c position is 1",alphabet); 15 | } 16 | else if(alphabet == 'b') 17 | { 18 | printf("%c position is 2",alphabet); 19 | } 20 | else if(alphabet == 'c') 21 | { 22 | printf("%c position is 3",alphabet); 23 | } 24 | else if(alphabet == 'd') 25 | { 26 | printf("%c position is 4",alphabet); 27 | } 28 | else if(alphabet == 'e') 29 | { 30 | printf("%c position is 5",alphabet); 31 | } 32 | else if(alphabet == 'f') 33 | { 34 | printf("%c position is 6",alphabet); 35 | } 36 | else if(alphabet == 'g') 37 | { 38 | printf("%c position is 7",alphabet); 39 | } 40 | else if(alphabet == 'h') 41 | { 42 | printf("%c position is 8",alphabet); 43 | } 44 | else if(alphabet == 'i') 45 | { 46 | printf("%c position is 9",alphabet); 47 | } 48 | else if(alphabet == 'j') 49 | { 50 | printf("%c position is 10",alphabet); 51 | } 52 | else if(alphabet == 'k') 53 | { 54 | printf("%c position is 11",alphabet); 55 | } 56 | else if(alphabet == 'k') 57 | { 58 | printf("%c position is 12",alphabet); 59 | } 60 | else if(alphabet == 'm') 61 | { 62 | printf("%c position is 13",alphabet); 63 | } 64 | else if(alphabet == 'n') 65 | { 66 | printf("%c position is 14",alphabet); 67 | } 68 | else if(alphabet == 'o') 69 | { 70 | printf("%c position is 15",alphabet); 71 | } 72 | else if(alphabet == 'p') 73 | { 74 | printf("%c position is 16",alphabet); 75 | } 76 | else if(alphabet == 'q') 77 | { 78 | printf("%c position is 17",alphabet); 79 | } 80 | else if(alphabet == 'r') 81 | { 82 | printf("%c position is 18",alphabet); 83 | } 84 | else if(alphabet == 's') 85 | { 86 | printf("%c position is 19",alphabet); 87 | } 88 | else if(alphabet == 't') 89 | { 90 | printf("%c position is 20",alphabet); 91 | } 92 | else if(alphabet == 'u') 93 | { 94 | printf("%c position is 21",alphabet); 95 | } 96 | else if(alphabet == 'v') 97 | { 98 | printf("%c position is 22",alphabet); 99 | } 100 | else if(alphabet == 'w') 101 | { 102 | printf("%c position is 23",alphabet); 103 | } 104 | else if(alphabet == 'x') 105 | { 106 | printf("%c position is 24",alphabet); 107 | } 108 | else if(alphabet == 'y') 109 | { 110 | printf("%c position is 25",alphabet); 111 | } 112 | else if(alphabet == 'z') 113 | { 114 | printf("%c position is 26",alphabet); 115 | } 116 | else 117 | { 118 | printf("not a alphbet"); 119 | } 120 | return 0; 121 | } -------------------------------------------------------------------------------- /C Programs/binary triangle 2.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | 5 | int i,j,n; 6 | 7 | printf("enter the number:"); 8 | scanf("%d",&n); 9 | 10 | for(i=1;i<=n;i++){ 11 | for(j=1;j<=i;j++){ 12 | 13 | if(j%2 == 0){ 14 | printf("0"); 15 | } 16 | else{ 17 | printf("1"); 18 | } 19 | 20 | } 21 | printf("\n"); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /C Programs/binary triangle 3.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | int i, j, rows,k; 5 | int count = 1; 6 | 7 | printf("Enter the number of rows\n"); 8 | scanf("%d", &rows); 9 | 10 | for (i = 1; i < rows; i++) { 11 | for (j = 0; j <= i; j++) { 12 | printf(" "); 13 | } 14 | 15 | for(k=i;k>=1;k--){ 16 | printf("%d ", count); 17 | count = !count; 18 | } 19 | count = i % 2; 20 | printf("\n"); 21 | } 22 | return(0); 23 | } -------------------------------------------------------------------------------- /C Programs/binary triangle.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(){ 4 | 5 | int i,j,num,k; 6 | 7 | 8 | printf("enter the number:"); 9 | scanf("%d",&num); 10 | 11 | 12 | for(i=1;i<=num;i++){ 13 | 14 | for(j=i;j<=num;j++) { 15 | printf(" "); 16 | 17 | } 18 | 19 | for(k=i;k>=1;k--){ 20 | 21 | 22 | 23 | if(k%2 == 0){ 24 | printf("0"); 25 | } 26 | else{ 27 | printf("1"); 28 | } 29 | } 30 | printf("\n"); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /C Programs/c_server.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VIJAYWHAT/C-programs/0f109bc391fc31c760c2ff1a01550fc1bd10f16e/C Programs/c_server.c -------------------------------------------------------------------------------- /C Programs/check dividable num.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(){ 4 | 5 | int i,n; 6 | printf("enter the number:"); 7 | scanf("%d",&n); 8 | for(i=1;i<=n;i++){ 9 | if(n%i == 0){ 10 | printf("%d\n",i); 11 | } 12 | } 13 | 14 | } -------------------------------------------------------------------------------- /C Programs/check number positive or negative.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main(){ 3 | int num; 4 | printf("enter the number: "); 5 | scanf("%d",&num); 6 | 7 | if(num>0) 8 | { 9 | printf("positive"); 10 | } 11 | else if(num == 0) 12 | { 13 | printf("num is 0"); 14 | } 15 | else if(num<0){ 16 | printf("negative"); 17 | } 18 | else 19 | { 20 | printf("non"); 21 | } 22 | return 0; 23 | } -------------------------------------------------------------------------------- /C Programs/check_int.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(){ 4 | int n; 5 | printf("Enter a number: "); 6 | if( scanf("%d", &n) == 1 ){ 7 | printf("You entered: %d\n", n); 8 | } 9 | else{ 10 | printf("Input in not a Integer"); 11 | } 12 | 13 | } -------------------------------------------------------------------------------- /C Programs/check_the_even_num_array.c: -------------------------------------------------------------------------------- 1 | #include 2 | void main() 3 | { 4 | int n; 5 | printf("Enter number of elements in the array: "); 6 | scanf("%d", &n); 7 | 8 | int array[n]; 9 | 10 | //take the n number of input 11 | for(int i=0;i 3 | 4 | // Prints diamond pattern 5 | void printDiamond(int n) 6 | { 7 | int space = n - 1; 8 | 9 | // Run loop till the number 10 | // of rows 11 | for (int i = 0; i < n; i++) 12 | { 13 | // Loop for the initially space 14 | // before the star printing 15 | for (int j = 0; j < space; j++) 16 | printf(" "); 17 | 18 | // Print the i+1 stars 19 | for (int j = 0; j <= i; j++) 20 | printf("* "); 21 | 22 | printf("\n"); 23 | space--; 24 | } 25 | 26 | // Repeat again in the reverse order 27 | space = 0; 28 | 29 | // run a loop till number of rows 30 | for (int i = n; i > 0; i--) 31 | { 32 | // Loop for the initially space 33 | // before the star printing 34 | for (int j = 0; j < space; j++) 35 | printf(" "); 36 | 37 | // Print the i stars 38 | for (int j = 0; j < i; j++) 39 | printf("* "); 40 | 41 | printf("\n"); 42 | space++; 43 | } 44 | } 45 | 46 | // Driver code 47 | int main() 48 | { 49 | int n; 50 | printf("enter the rows: "); 51 | if (scanf("%d", &n) == 1) { 52 | 53 | if(n > 0) 54 | printDiamond(n); 55 | else 56 | printf("Invalid input... Enter the number greater than 1"); 57 | } 58 | else 59 | printf("Invalid input... Enter the valid INTEGER"); 60 | 61 | return 0; 62 | } 63 | -------------------------------------------------------------------------------- /C Programs/distance bvn two citties.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main (){ 4 | float km,m,cm,ft,inch; 5 | 6 | printf("enter the distance in kilometers: "); 7 | 8 | scanf("%f",&km); 9 | 10 | m = km*1000; 11 | cm = m * 100; 12 | inch = cm/2.54; 13 | ft = inch/12; 14 | 15 | printf("distance in meter = %f\n",m); 16 | printf("distance in centimeter = %f\n",cm); 17 | printf("distance in feet = %f\n",ft); 18 | printf("distance in inches = %f\n",inch); 19 | 20 | return 0; 21 | } -------------------------------------------------------------------------------- /C Programs/factorial of num.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(){ 4 | 5 | int i,n,fact = 1; 6 | 7 | printf("enter the number: "); 8 | scanf("%d",&n); 9 | 10 | for(i=1;i<=n;i++){ 11 | fact = fact * i; 12 | } 13 | 14 | if(n < 0){ 15 | printf("number is negative!"); 16 | } 17 | printf("factorial: %d \n",fact); 18 | 19 | } -------------------------------------------------------------------------------- /C Programs/file_reading.c: -------------------------------------------------------------------------------- 1 | #include 2 | // Reading operation in file handling 3 | 4 | int main(){ 5 | 6 | FILE *fp; // Declare the file Pointer 7 | char c[100],c1; 8 | 9 | 10 | fp = fopen("test.txt","r+w"); // Open the file in "read" Mode 11 | 12 | // c1 = fgetc(fp); // get the single char from the file fp and store in variable "c1" 13 | // printf("%c \n",c1); // print the char 14 | 15 | fgets(c,10,fp); // get the 10char count string from the file fp and store in variable "c" 16 | printf("%s",c); // print the string (Hello Wor) only 9char print(bcuz this get n-1 size) 17 | 18 | fclose(fp); 19 | return 0; 20 | } -------------------------------------------------------------------------------- /C Programs/file_writing.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(){ 4 | 5 | FILE *fp; 6 | char string[100]; 7 | 8 | fp = fopen("test4.txt","a+"); // file open with the write and read mode 9 | 10 | if (fp == NULL) { 11 | printf("Could not open file for writing and reading.\n"); 12 | return 1; 13 | } 14 | 15 | fputs("Hello VJ!\nI am Happy to help you today\n",fp); // fputs user to write a string 16 | fprintf(fp,"Hi VJ"); // fprintf also used to write the string 17 | rewind(fp); // Reset file pointer to the beginning 18 | 19 | 20 | fgets(string,50,fp); 21 | printf("%s",string); 22 | 23 | 24 | fclose(fp); // close the file 25 | printf("File Writed successful"); 26 | return 0; 27 | 28 | } -------------------------------------------------------------------------------- /C Programs/floids_triangle.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(){ 4 | 5 | int i,j,r,t=1; 6 | 7 | printf("Enter the number of rows:"); 8 | scanf("%d",&r); 9 | 10 | 11 | for(i=1;i<=r;i++){ 12 | 13 | for(j=1;j<=i;j++){ 14 | printf("%d ",t); 15 | t++; 16 | 17 | } 18 | printf("\n"); 19 | } 20 | 21 | return 0; 22 | 23 | } 24 | -------------------------------------------------------------------------------- /C Programs/frequency_of_number.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(){ 4 | 5 | 6 | int array[] = {1, 7 | 2, 8 | 6, 9 | 4, 10 | 8, 11 | 5, 12 | 9, 13 | 7, 14 | 8, 15 | 10, 16 | 1, 17 | 6, 18 | 3, 19 | 8, 20 | 6, 21 | 10, 22 | 3, 23 | 8, 24 | 2, 25 | 7, 26 | 6, 27 | 5, 28 | 7, 29 | 6, 30 | 8, 31 | 6, 32 | 7, 33 | 5, 34 | 6, 35 | 6, 36 | 5, 37 | 6, 38 | 7, 39 | 5, 40 | 6, 41 | 4, 42 | 8, 43 | 6, 44 | 8, 45 | 10}; 46 | 47 | int count = 0; 48 | printf("value%13s\n","frequency"); //%13s for the space 49 | for(int i=1;i<=10;i++){ 50 | for(int j=1;j<=40;j++){ 51 | if(array[j] == i){ //check the i in array[j] 52 | count++; //adding the count 53 | } 54 | } 55 | 56 | printf("%d%13d\n",i,count); 57 | count = 0; 58 | } 59 | 60 | return 0; 61 | 62 | } -------------------------------------------------------------------------------- /C Programs/greatest_and_smallest_num_array.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | 5 | int n,arr[10]; 6 | 7 | printf("Enter the number of elements:"); 8 | scanf("%d", &n); 9 | 10 | for (int i = 0; i < n; i++) { 11 | printf("Enter number %d:",i+1); 12 | scanf("%d", &arr[i]); 13 | } 14 | 15 | int max = arr[0]; 16 | int min = arr[0]; 17 | 18 | for (int i = 1; i < n;i++ ) { 19 | if ( max < arr[i]) { 20 | max = arr[i]; 21 | } 22 | 23 | if ( min > arr[i]) { 24 | min = arr[i]; 25 | } 26 | } 27 | 28 | printf("Largest number = %d\n", max); 29 | printf("smallest number = %d\n", min); 30 | 31 | return 0; 32 | } -------------------------------------------------------------------------------- /C Programs/gross glosary.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(){ 4 | 5 | float bp,da,hra,grpay; 6 | 7 | printf("\nenter the basic salary of ramesh:"); 8 | scanf("%f",&bp); 9 | 10 | da=0.4 * bp; 11 | hra = 0.2 * bp; 12 | grpay = bp + da + hra; 13 | 14 | printf("basic salary of ramesh = %f\n",bp); 15 | printf("dearness allowance = %f\n",da); 16 | printf("house rent allowance = %f\n",hra); 17 | printf("gross pay of ramesh is %f\n",grpay); 18 | 19 | } -------------------------------------------------------------------------------- /C Programs/hallow_triangle.c: -------------------------------------------------------------------------------- 1 | // a Hollow Star Pyramid 2 | #include 3 | 4 | int main() 5 | { 6 | int i, space, n = 5, j = 0; 7 | 8 | // first for loop is used to iterate number of rows 9 | for (i = 0; i < n - 1; i++) { 10 | 11 | // second for loop is used to print spaces 12 | for (space = 1; space < n - i; space++) { 13 | printf(" "); 14 | } 15 | // third for loop is used to print the required pattern 16 | for (j = 0; j <= 2 * i; j++) { 17 | if (j == 0 || j == 2 * i) 18 | printf("*"); 19 | else 20 | printf(" "); 21 | } 22 | // print the new line after every row 23 | printf("\n"); 24 | } 25 | // used to print last row 26 | for (i = 0; i < n; i++) { 27 | printf("* "); 28 | } 29 | return 0; 30 | } 31 | -------------------------------------------------------------------------------- /C Programs/hashtable.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #define MAX_NAME 256 7 | #define TABLE_SIZE 10 8 | 9 | typedef struct 10 | { 11 | char name[MAX_NAME]; 12 | int age; 13 | //....add other stuff later,maybe 14 | } person; 15 | 16 | unsigned int hash(char *name){ 17 | return 5; 18 | } 19 | 20 | int main() { 21 | printf("vj => %u\n",hash("vj")); 22 | printf("goushik => %u\n",hash("goushik")); 23 | printf("ashraf => %u\n",hash("ashraf")); 24 | printf("gopi => %u\n",hash("gopi")); 25 | 26 | return 0; 27 | } 28 | -------------------------------------------------------------------------------- /C Programs/lab.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "lines.c" 3 | 4 | void Prime(){ 5 | 6 | lineb(); 7 | printf("\tPrime Number"); 8 | line(); 9 | //Prime Or Not 10 | int n,k=0,i=1; //Declaring The Variables 11 | 12 | printf("Enter the Number:");//Ask the Number From User 13 | scanf("%d",&n);//Scan the Number 14 | 15 | while(i<=n){//checking the less the i 16 | //if the the number is greater than i loop was end 17 | 18 | if(n%i == 0)//checking n%i==0 or not 19 | k++;//if n%i == 0 k was increament 20 | i++; //if the loop was entered i was increament 21 | 22 | } 23 | 24 | if(k==2)//if k = 2 that is a prime number 25 | printf("%d is a prime Number",n); 26 | 27 | else//else it is not a prime number 28 | printf("%d is not a Prime Number",n); 29 | 30 | } 31 | 32 | void SumOfDigit(){ 33 | 34 | lineb(); 35 | printf("\tSum Of Digit"); 36 | line(); 37 | 38 | int n,r,s,n1; 39 | 40 | printf("Enter the Number:"); 41 | scanf("%d",&n); 42 | 43 | n1=n; 44 | s=0; 45 | 46 | while(n>0){ 47 | 48 | r=n%10; 49 | s=s+r; 50 | n=n/10; 51 | 52 | } 53 | printf("Sum of Digit of %d is : %d",n1,s); 54 | 55 | } 56 | 57 | void Palindrome(){ 58 | 59 | lineb(); 60 | printf("\tPalindrome"); 61 | line(); 62 | 63 | int n,t,s,r; 64 | 65 | printf("Enter the number:"); 66 | scanf("%d",&n); 67 | 68 | t=n; 69 | s=0; 70 | 71 | while(n>0){ 72 | 73 | r=n%10; 74 | s=(s*10)+r; 75 | n=n/10; 76 | 77 | } 78 | 79 | if(t==s) 80 | printf("%d is a Palindrome",t); 81 | else 82 | printf("%d is not a palindrome",t); 83 | 84 | } 85 | 86 | void Rev(){ 87 | 88 | lineb(); 89 | printf("\tReverse The Number"); 90 | line(); 91 | 92 | int n,t,s,r; 93 | 94 | printf("Enter the number:"); 95 | scanf("%d",&n); 96 | 97 | t=n; 98 | s=0; 99 | 100 | while(n>0){ 101 | 102 | r=n%10; 103 | s=(s*10)+r; 104 | n=n/10; 105 | 106 | } 107 | 108 | printf("Reverse : %d",s); 109 | 110 | } 111 | 112 | -------------------------------------------------------------------------------- /C Programs/leep_year_checking_code.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | 5 | int year; 6 | printf("enter the year:"); 7 | scanf("%d",&year); 8 | 9 | if(year%100 == 0) 10 | { 11 | if(year%400 == 0) 12 | { 13 | printf("leap year"); 14 | 15 | } 16 | else 17 | { 18 | printf("not a leap year"); 19 | } 20 | } 21 | else 22 | { 23 | if(year%4 == 0) 24 | { 25 | printf("leap year"); 26 | 27 | } 28 | else 29 | { 30 | printf("not a leap year"); 31 | } 32 | } 33 | return 0; 34 | } -------------------------------------------------------------------------------- /C Programs/lines.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | 4 | void line(){ 5 | 6 | printf("\n===============================\n"); 7 | 8 | } 9 | 10 | void lineb(){ 11 | 12 | printf("===============================\n"); 13 | 14 | } 15 | 16 | void bline(){ 17 | 18 | printf("\n==============================="); 19 | 20 | } 21 | 22 | void eline() 23 | { 24 | printf("=========="); 25 | } 26 | -------------------------------------------------------------------------------- /C Programs/multi_returns.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | typedef struct 4 | { 5 | int doubled,cubed; 6 | }number_range; 7 | 8 | 9 | void calculate(int num,int* doubled,int *cubed) { 10 | 11 | *doubled = num * num; 12 | *cubed = num * num * num; 13 | 14 | } 15 | 16 | number_range calculate2(int num){ 17 | 18 | number_range number; 19 | number.doubled = num * num; 20 | number.cubed = num * num * num; 21 | return number; 22 | } 23 | 24 | int main(){ 25 | 26 | int num = 10; 27 | 28 | number_range nr; 29 | int doubled , cubed; 30 | calculate(num,&doubled, &cubed); 31 | nr = calculate2(num); 32 | 33 | printf("The number using pointer: %d %d\n",doubled, cubed); 34 | printf("The number using structure: %d %d",nr.doubled,nr.cubed); 35 | 36 | return 0; 37 | } -------------------------------------------------------------------------------- /C Programs/multiplication_table.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | 5 | int i,n; 6 | printf("enter the number: "); 7 | scanf("%d",&n); 8 | for(i=1;i<=10;i++){ 9 | printf("%d * %d = %d \n",i,n,n*i); 10 | } 11 | 12 | return 0; 13 | } 14 | 15 | -------------------------------------------------------------------------------- /C Programs/number_pyramid.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(){ 4 | 5 | int i,j,k,r,s,t=1; 6 | 7 | printf("Enter the number of rows:"); 8 | scanf("%d",&r); 9 | 10 | for(i=1;i<=r;i++){ 11 | for(j=1;j<=(r-i);j++) 12 | printf(" "); 13 | 14 | s=(2*i)-1; 15 | for(k=1;k<=s;k++){ 16 | 17 | if(t<10) 18 | printf(" %d",t); 19 | 20 | else 21 | printf("%d ",t); 22 | t++; 23 | 24 | } 25 | printf("\n"); 26 | } 27 | return 0; 28 | 29 | } -------------------------------------------------------------------------------- /C Programs/number_range.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(){ 4 | 5 | 6 | int n,sum=0,a; 7 | 8 | printf("Enter a number:"); 9 | scanf("%d",&n); 10 | 11 | a = n*(n+1); 12 | sum = a/2; 13 | 14 | printf("%d",sum); 15 | return 0; 16 | } 17 | -------------------------------------------------------------------------------- /C Programs/number_triangle.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | 6 | int i,j,num,t=1; 7 | 8 | printf("enter the number:"); 9 | scanf("%d",&num); 10 | 11 | for(i=1;i<=num;i++) 12 | { 13 | for(j=1;j<=i;j++) { 14 | printf("%d ",t); 15 | t++; 16 | } 17 | printf("\n"); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /C Programs/numeric triangle 2.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | 6 | int i,j,num; 7 | 8 | printf("enter the number:"); 9 | scanf("%d",&num); 10 | 11 | 12 | for(i=num;i>=1;--i) 13 | { 14 | for(j=1;j<=i;j++) { 15 | printf("%d",j); 16 | 17 | } 18 | printf("\n"); 19 | } 20 | } -------------------------------------------------------------------------------- /C Programs/numeric triangle 3.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | 5 | int i,j,n,print=0; 6 | 7 | printf("enter the number:"); 8 | scanf("%d",&n); 9 | 10 | for(i=1;i<=n;i++){ 11 | for(j=1;j<=i;j++){ 12 | print++; 13 | printf("%d ",print); 14 | } 15 | printf("\n"); 16 | 17 | } 18 | } -------------------------------------------------------------------------------- /C Programs/numeric triangle 4.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | 6 | int i,j,num,k; 7 | 8 | 9 | printf("enter the number:"); 10 | scanf("%d",&num); 11 | 12 | 13 | for(i=1;i<=num;i++){ 14 | 15 | for(j=i;j<=num;j++) { 16 | printf(" "); 17 | 18 | } 19 | 20 | for(k=i;k>=1;k--){ 21 | 22 | 23 | printf("%d",k); 24 | 25 | 26 | } 27 | 28 | printf("\n"); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /C Programs/odd or even num.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | 5 | int num; 6 | 7 | printf("enter the number:"); 8 | scanf("%d",&num); 9 | 10 | if(num%2 == 0 ){ 11 | printf("even number"); 12 | } 13 | else{ 14 | printf("odd number"); 15 | } 16 | } -------------------------------------------------------------------------------- /C Programs/palindrome.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | int num,copy,rev=0; 5 | 6 | printf("enter the number:"); 7 | scanf("%d",&num); 8 | 9 | copy = num; 10 | 11 | while(copy > 0){ 12 | 13 | rev = rev*10; 14 | rev = rev + (copy%10); 15 | copy /= 10; 16 | 17 | } 18 | 19 | if(num == rev){ 20 | 21 | printf("palindrome"); 22 | 23 | 24 | } 25 | 26 | else { 27 | printf("not a palindrome"); 28 | } 29 | 30 | return 0; 31 | } -------------------------------------------------------------------------------- /C Programs/pattern.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(){ 4 | 5 | int i,j,n; //pattern1 start 6 | 7 | printf("enter the n:"); 8 | scanf("%d",&n); 9 | 10 | for(i=1;i<=n;i++){ 11 | for(j=1;j<=n;j++){ 12 | 13 | printf("*"); 14 | } 15 | printf("\n"); 16 | 17 | } 18 | } 19 | //pattern1 end 20 | 21 | /* int i,j,row,col; //pattern2 start 22 | 23 | printf("enter the row:"); 24 | scanf("%d",&row); 25 | 26 | printf("enter the col:"); 27 | scanf("%d",&col); 28 | 29 | for(i=1;i<=row;i++){ 30 | for(j=1;j<=col;j++){ 31 | 32 | printf("*"); 33 | } 34 | printf("\n"); 35 | } 36 | 37 | } //pattern2 end*/ 38 | 39 | 40 | /* int i,j,k,n; //pattern3 start 41 | 42 | printf("enter the num:"); 43 | scanf("%d",&n); 44 | 45 | for(i=n;i>=1;i--){ 46 | for(j=1;j<=i;j++){ 47 | printf("*"); 48 | } 49 | printf("\n"); 50 | 51 | } 52 | } //pattern3 end*/ 53 | 54 | 55 | /*int n; //pattern4 start 56 | 57 | printf("enter the num:"); 58 | scanf("%d",&n); 59 | 60 | for(int i=1;i<=n;i++){ 61 | for(int j=1;j<=i;j++){ 62 | printf("%d",j); 63 | } 64 | printf("\n"); 65 | 66 | } 67 | 68 | }//pattern 4 end*/ 69 | 70 | 71 | 72 | /* int n,i,j; 73 | 74 | printf("enter the num:"); 75 | scanf("%d",&n); 76 | 77 | for(i=1;i<=n;i++){ 78 | for(j=1;j<=i;j++){ 79 | printf("%d",j); 80 | 81 | } 82 | printf("\n"); 83 | } 84 | for(i=n-1;i>=1;i--){ 85 | for(j=1;j<=i;j++){ 86 | printf("%d",j); 87 | } 88 | printf("\n"); 89 | } 90 | 91 | 92 | }*/ 93 | 94 | 95 | 96 | -------------------------------------------------------------------------------- /C Programs/pattern_using_if.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(){ 4 | 5 | int i,j,n; 6 | 7 | printf("enter the n:"); 8 | scanf("%d",&n); 9 | 10 | for (int i = 1; i <= 2 * n - 1; i++) //input(3)i=1;i<= 2 * n-1(2*3-1=5);i++ 11 | {//output(i = 4) 12 | int c; 13 | if (i > n) //check i > n (2 > n) 14 | { 15 | c = n - (i - n); //(n-(i-n)) (3-(4-3))(3-(1))c=2 16 | } 17 | else 18 | { 19 | c = i; //c = 2 20 | } 21 | for (int j = 1; j <= c; j++) //j=1;j=c(j=2);j++ 1,2 22 | { 23 | printf("%d", j); //printing(1,2) 24 | 25 | 26 | } 27 | printf("\n"); 28 | } 29 | } 30 | 31 | 32 | //EXPLANATION 33 | 34 | // n=3 35 | // i = 1; i <= 2 * n - 1; i++ 36 | // i<=(2*n-1)(2*3-1)i<=5 37 | // i=1 38 | // if(i>n)(1>3) no 39 | // else(c=i)(c=1) 40 | // j = 1; j <= c; j++ 41 | // j<=c(j<=1) 42 | // print(j)=1 -jloop end go to i 43 | 44 | // n=3 45 | // i=2;i<=5 46 | // if(i>n)(2>3) no 47 | // else(c=i)(c=2) 48 | // j = 1; j <= c; j++ 49 | // j<=c(j<=2) 50 | // print(j)=1,2 -jloop end go to i 51 | 52 | // n=3 53 | // i=3;i<=5 54 | // if(i>n)(3>3) no 55 | // else(c=i)(c=3) 56 | // j = 1; j <= c; j++ 57 | // j<=c(j<=3) 58 | // print(j)=1,2,3 -jloop end go to i 59 | 60 | // n=3 61 | // i=4;i<=5 62 | // if(i>n)(4>3) yes 63 | // c = n - (i - n); //(n-(i-n))(3-(4-3))(3-(1))c=2 64 | // j = 1; j <= c; j++ 65 | // j<=c(j<=2) 66 | // print(j)=1,2 -jloop end go to i 67 | 68 | // n=3 69 | // i=4;i<=5 70 | // if(i>n)(5>3) yes 71 | // c = n - (i - n); //(n-(i-n))(3-(4-3))(3-(2))c=1 72 | // j = 1; j <= c; j++ 73 | // j<=c(j<=1) 74 | // print(j)=1 -jloop end go to i 75 | 76 | 77 | -------------------------------------------------------------------------------- /C Programs/pointers.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(void){ 4 | 5 | printf("Memory size: %d * %d = %d",sizeof(void *),sizeof(void *),sizeof(void *)*sizeof(void *)); 6 | 7 | } -------------------------------------------------------------------------------- /C Programs/practice.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int sum(){ 4 | 5 | int a,b; 6 | printf("enter two numbers: "); 7 | scanf("%d %d",&a,&b); 8 | return a+b; 9 | } 10 | 11 | void end(){ 12 | printf("The program was ended!\n"); 13 | } 14 | 15 | int main(){ 16 | 17 | printf("Sum of two digits: %d",sum()); 18 | 19 | 20 | 21 | } 22 | -------------------------------------------------------------------------------- /C Programs/prime_number.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void main() 4 | { 5 | int n,i = 1,k = 0; 6 | 7 | printf("\n Enter the any number: "); 8 | scanf("%d",&n); 9 | 10 | while(i <= n) 11 | { 12 | if(n % i == 0) 13 | k++; 14 | i++; 15 | } 16 | if(k==2) 17 | printf(" %d is a prime number",n); 18 | else 19 | printf(" %d is a not prime number",n); 20 | 21 | } 22 | -------------------------------------------------------------------------------- /C Programs/primenumber.c: -------------------------------------------------------------------------------- 1 | //Type1 2 | 3 | #include 4 | 5 | int main(){ 6 | 7 | int i,n,flag=0; 8 | 9 | printf("enter n:"); 10 | scanf("%d",&n); 11 | 12 | for(i=2;i 32 | 33 | int main(){ 34 | 35 | int n,i,flag=0; 36 | 37 | printf("enter n:"); 38 | scanf("%d",&n); 39 | 40 | for(i=2;i // Header file 2 | 3 | void main(){ // main function with no returns 4 | 5 | int i,j,k,s,rows; 6 | 7 | printf("Enter the Number of rows: "); // print function for display and getting input from the user 8 | scanf("%d",&rows); // scan function for getting input from the user 9 | 10 | for(i=1;i<=rows;i++){ // parent loop 11 | for(j=1;j<=(rows-i);j++) // child loop 12 | printf(" "); // print space for triangle comes center 13 | 14 | s = (i*2) - 1; // s to calculate the rows to print 15 | 16 | for(k=1;k<=s;k++){ // k loop for print the star 17 | printf(" *"); 18 | } 19 | printf("\n\n"); 20 | } 21 | } 22 | 23 | -------------------------------------------------------------------------------- /C Programs/read_full_fille.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | FILE *fp; 5 | char string[100]; 6 | 7 | fp = fopen("test4.txt", "r"); 8 | if (fp == NULL) { 9 | printf("Could not open file for reading.\n"); 10 | return 1; 11 | } 12 | 13 | printf("Contents of the file:\n"); 14 | 15 | // Read and print each line until end of file 16 | while (fgets(string, sizeof(string), fp) != NULL) { 17 | printf("%s", string); 18 | } 19 | 20 | fclose(fp); // Close the file 21 | 22 | printf("\nFile read successfully.\n"); 23 | return 0; 24 | } 25 | -------------------------------------------------------------------------------- /C Programs/recursion.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | 4 | 5 | int fact(int n){ 6 | 7 | if(n <= 1) 8 | return 1; 9 | else 10 | return n * fact(n - 1); 11 | } 12 | 13 | void main(){ 14 | 15 | int num = 4; 16 | printf("The factorial of %d is: %d",num,fact(num)); 17 | 18 | } -------------------------------------------------------------------------------- /C Programs/rev array.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(){ 4 | 5 | int i,num[] = {1,4,2,3}; 6 | 7 | for(i=3;i>=0;i--){ 8 | printf("%d",num[i]); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /C Programs/reversenumber.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | int num,copy,rev=0; 5 | 6 | printf("enter the number:"); 7 | scanf("%d",&num); 8 | 9 | copy = num; 10 | 11 | while(copy > 0){ 12 | 13 | rev = rev * 10; 14 | rev = rev + (copy%10); 15 | copy /= 10; 16 | 17 | } 18 | 19 | printf("reverse number:%d",rev); 20 | 21 | return 0; 22 | } -------------------------------------------------------------------------------- /C Programs/scanf_f.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(){ 4 | 5 | int n; 6 | printf("the output: %d",scanf("%d %c %d",&n,&n,&n)); 7 | 8 | return 0; 9 | } 10 | -------------------------------------------------------------------------------- /C Programs/simple calculator.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | 5 | int num1,num2; 6 | char op; 7 | 8 | printf("enter the number1 :"); 9 | scanf("%d",&num1); 10 | 11 | printf("enter the operator :"); 12 | scanf("\n %c",&op); 13 | 14 | printf("enter the number2:"); 15 | scanf("%d",&num2); 16 | 17 | if(op == '+'){ 18 | printf("sum:%d + %d = %d",num1,num2,num1+num2); 19 | } 20 | else if(op == '-'){ 21 | printf("sum:%d - %d = %d",num1,num2,num1-num2); 22 | } 23 | else if(op == '*'){ 24 | printf("sum:%d * %d = %d",num1,num2,num1*num2); 25 | } 26 | else if(op == '/'){ 27 | printf("sum:%d / %d = %d",num1,num2,num1/num2); 28 | } 29 | else{ 30 | printf("invaild operator"); 31 | } 32 | 33 | return 0; 34 | } -------------------------------------------------------------------------------- /C Programs/snakegame.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | #define UP 72 12 | #define DOWN 80 13 | #define LEFT 75 14 | #define RIGHT 77 15 | 16 | int length; 17 | int bend_no; 18 | int len; 19 | char key; 20 | void record(); 21 | void load(); 22 | int life; 23 | void Delay(long double); 24 | void Move(); 25 | void Food(); 26 | int Score(); 27 | void Print(); 28 | void gotoxy(int x, int y); 29 | void GotoXY(int x,int y); 30 | void Bend(); 31 | void Boarder(); 32 | void Down(); 33 | void Left(); 34 | void Up(); 35 | void Right(); 36 | void ExitGame(); 37 | int Scoreonly(); 38 | 39 | struct coordinate 40 | { 41 | int x; 42 | int y; 43 | int direction; 44 | }; 45 | 46 | typedef struct coordinate coordinate; 47 | 48 | coordinate head, bend[500],food,body[30]; 49 | 50 | int main() 51 | { 52 | 53 | char key; 54 | 55 | Print(); 56 | 57 | system("cls"); 58 | 59 | load(); 60 | 61 | length=5; 62 | 63 | head.x=25; 64 | 65 | head.y=20; 66 | 67 | head.direction=RIGHT; 68 | 69 | Boarder(); 70 | 71 | Food(); //to generate food coordinates initially 72 | 73 | life=3; //number of extra lives 74 | 75 | bend[0]=head; 76 | 77 | Move(); //initialing initial bend coordinate 78 | 79 | return 0; 80 | 81 | } 82 | 83 | void Move() 84 | { 85 | int a,i; 86 | 87 | do 88 | { 89 | 90 | Food(); 91 | fflush(stdin); 92 | 93 | len=0; 94 | 95 | for(i=0; i<30; i++) 96 | 97 | { 98 | 99 | body[i].x=0; 100 | 101 | body[i].y=0; 102 | 103 | if(i==length) 104 | 105 | break; 106 | 107 | } 108 | 109 | Delay(length); 110 | 111 | Boarder(); 112 | 113 | if(head.direction==RIGHT) 114 | 115 | Right(); 116 | 117 | else if(head.direction==LEFT) 118 | 119 | Left(); 120 | 121 | else if(head.direction==DOWN) 122 | 123 | Down(); 124 | 125 | else if(head.direction==UP) 126 | 127 | Up(); 128 | 129 | ExitGame(); 130 | 131 | } 132 | while(!kbhit()); 133 | 134 | a=getch(); 135 | 136 | if(a==27) 137 | 138 | { 139 | 140 | system("cls"); 141 | 142 | exit(0); 143 | 144 | } 145 | key=getch(); 146 | 147 | if((key==RIGHT&&head.direction!=LEFT&&head.direction!=RIGHT)||(key==LEFT&&head.direction!=RIGHT&&head.direction!=LEFT)||(key==UP&&head.direction!=DOWN&&head.direction!=UP)||(key==DOWN&&head.direction!=UP&&head.direction!=DOWN)) 148 | 149 | { 150 | 151 | bend_no++; 152 | 153 | bend[bend_no]=head; 154 | 155 | head.direction=key; 156 | 157 | if(key==UP) 158 | 159 | head.y--; 160 | 161 | if(key==DOWN) 162 | 163 | head.y++; 164 | 165 | if(key==RIGHT) 166 | 167 | head.x++; 168 | 169 | if(key==LEFT) 170 | 171 | head.x--; 172 | 173 | Move(); 174 | 175 | } 176 | 177 | else if(key==27) 178 | 179 | { 180 | 181 | system("cls"); 182 | 183 | exit(0); 184 | 185 | } 186 | 187 | else 188 | 189 | { 190 | 191 | printf("\a"); 192 | 193 | Move(); 194 | 195 | } 196 | } 197 | 198 | void gotoxy(int x, int y) 199 | { 200 | 201 | COORD coord; 202 | 203 | coord.X = x; 204 | 205 | coord.Y = y; 206 | 207 | SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord); 208 | 209 | } 210 | void GotoXY(int x, int y) 211 | { 212 | HANDLE a; 213 | COORD b; 214 | fflush(stdout); 215 | b.X = x; 216 | b.Y = y; 217 | a = GetStdHandle(STD_OUTPUT_HANDLE); 218 | SetConsoleCursorPosition(a,b); 219 | } 220 | void load() 221 | { 222 | int row,col,r,c,q; 223 | gotoxy(36,14); 224 | printf("loading..."); 225 | gotoxy(30,15); 226 | for(r=1; r<=20; r++) 227 | { 228 | for(q=0; q<=100000000; q++); //to display the character slowly 229 | printf("%c",177); 230 | } 231 | getch(); 232 | } 233 | void Down() 234 | { 235 | int i; 236 | for(i=0; i<=(head.y-bend[bend_no].y)&&len=70||head.y<=10||head.y>=30||check!=0) 272 | { 273 | life--; 274 | if(life>=0) 275 | { 276 | head.x=25; 277 | head.y=20; 278 | bend_no=0; 279 | head.direction=RIGHT; 280 | Move(); 281 | } 282 | else 283 | { 284 | system("cls"); 285 | printf("All lives completed\nBetter Luck Next Time!!!\nPress any key to quit the game\n"); 286 | record(); 287 | exit(0); 288 | } 289 | } 290 | } 291 | void Food() 292 | { 293 | if(head.x==food.x&&head.y==food.y) 294 | { 295 | length++; 296 | time_t a; 297 | a=time(0); 298 | srand(a); 299 | food.x=rand()%70; 300 | if(food.x<=10) 301 | food.x+=11; 302 | food.y=rand()%30; 303 | if(food.y<=10) 304 | 305 | food.y+=11; 306 | } 307 | else if(food.x==0)/*to create food for the first time coz global variable are initialized with 0*/ 308 | { 309 | food.x=rand()%70; 310 | if(food.x<=10) 311 | food.x+=11; 312 | food.y=rand()%30; 313 | if(food.y<=10) 314 | food.y+=11; 315 | } 316 | } 317 | void Left() 318 | { 319 | int i; 320 | for(i=0; i<=(bend[bend_no].x-head.x)&&len"); 350 | else 351 | printf("*"); 352 | } 353 | /*body[len].x=head.x-i; 354 | body[len].y=head.y;*/ 355 | len++; 356 | } 357 | Bend(); 358 | if(!kbhit()) 359 | head.x++; 360 | } 361 | void Bend() 362 | { 363 | int i,j,diff; 364 | for(i=bend_no; i>=0&&len0) 381 | for(j=1; j<=diff; j++) 382 | { 383 | /*GotoXY(bend[i].x,(bend[i].y-j)); 384 | printf("*");*/ 385 | body[len].x=bend[i].x; 386 | body[len].y=bend[i].y-j; 387 | GotoXY(body[len].x,body[len].y); 388 | printf("*"); 389 | len++; 390 | if(len==length) 391 | break; 392 | } 393 | } 394 | else if(bend[i].y==bend[i-1].y) 395 | { 396 | diff=bend[i].x-bend[i-1].x; 397 | if(diff<0) 398 | for(j=1; j<=(-diff)&&len0) 411 | for(j=1; j<=diff&&len Use arrow keys to move the snake.\n\n-> You will be provided foods at the several coordinates of the screen which you have to eat. Everytime you eat a food the length of the snake will be increased by 1 element and thus the score.\n\n-> Here you are provided with three lives. Your life will decrease as you hit the wall or snake's body.\n\n-> YOu can pause the game in its middle by pressing any key. To continue the paused game press any other key once again\n\n-> If you want to exit press esc. \n"); 455 | printf("\n\nPress any key to play game..."); 456 | if(getch()==27) 457 | exit(0); 458 | } 459 | void record() 460 | { 461 | char plname[20],nplname[20],cha,c; 462 | int i,j,px; 463 | FILE *info; 464 | info=fopen("record.txt","a+"); 465 | getch(); 466 | system("cls"); 467 | printf("Enter your name\n"); 468 | scanf("%[^\n]",plname); 469 | //************************ 470 | for(j=0; plname[j]!='\0'; j++) //to convert the first letter after space to capital 471 | { 472 | nplname[0]=toupper(plname[0]); 473 | if(plname[j-1]==' ') 474 | { 475 | nplname[j]=toupper(plname[j]); 476 | nplname[j-1]=plname[j-1]; 477 | } 478 | else nplname[j]=plname[j]; 479 | } 480 | nplname[j]='\0'; 481 | //***************************** 482 | //sdfprintf(info,"\t\t\tPlayers List\n"); 483 | fprintf(info,"Player Name :%s\n",nplname); 484 | //for date and time 485 | 486 | time_t mytime; 487 | mytime = time(NULL); 488 | fprintf(info,"Played Date:%s",ctime(&mytime)); 489 | //************************** 490 | fprintf(info,"Score:%d\n",px=Scoreonly());//call score to display score 491 | //fprintf(info,"\nLevel:%d\n",10);//call level to display level 492 | for(i=0; i<=50; i++) 493 | fprintf(info,"%c",'_'); 494 | fprintf(info,"\n"); 495 | fclose(info); 496 | printf("Wanna see past records press 'y'\n"); 497 | cha=getch(); 498 | system("cls"); 499 | if(cha=='y') 500 | { 501 | info=fopen("record.txt","r"); 502 | do 503 | { 504 | putchar(c=getc(info)); 505 | } 506 | while(c!=EOF); 507 | } 508 | fclose(info); 509 | } 510 | int Score() 511 | { 512 | int score; 513 | GotoXY(20,8); 514 | score=length-5; 515 | printf("SCORE : %d",(length-5)); 516 | score=length-5; 517 | GotoXY(50,8); 518 | printf("Life : %d",life); 519 | return score; 520 | } 521 | int Scoreonly() 522 | { 523 | int score=Score(); 524 | system("cls"); 525 | return score; 526 | } 527 | void Up() 528 | { 529 | int i; 530 | for(i=0; i<=(bend[bend_no].y-head.y)&&len 3 | #include 4 | 5 | // Create a structure called myStructure 6 | struct mystructure{ // Structure declaration 7 | char String[30]; // String 8 | };// End the structure with a semicolon 9 | 10 | int main() { 11 | // Create a structure variable of myStructure called s1 12 | struct mystructure s1; 13 | 14 | // Assign a value to the string using the strcpy function 15 | strcpy(s1.String, "Hello Vijay"); 16 | 17 | // Print values 18 | printf("my string: %s",s1.String); 19 | 20 | return 0; 21 | } -------------------------------------------------------------------------------- /C Programs/string.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(){ 4 | 5 | // Method 1 6 | char name[] = "Vijay Raja"; 7 | printf("String: %s\n", name); 8 | printf("String with minimum width: %20s\n", name); 9 | printf("String with left alignment: %-20s\n", name); 10 | printf("String with precision (first 5 chars): %.5s\n", name); 11 | 12 | // Method 2 13 | char dept[50]; 14 | printf("Enter the Dept: "); 15 | scanf("%s",dept); 16 | printf("Hello, %s\n", dept); 17 | 18 | // Method 3 19 | getchar(); 20 | char clg[50]; 21 | printf("Enter the College Name: "); 22 | // MAX Size if 50 defined 23 | fgets(clg, 50, stdin); 24 | printf("String is: "); 25 | // Displaying Strings using Puts 26 | puts(clg); 27 | 28 | // Method 4 29 | char str[50]; 30 | printf("Enter a line of text: "); 31 | gets(str); // Unsafe, do not use in real programs 32 | printf("You entered: %s\n", str); 33 | 34 | 35 | // Method 5 36 | char str2[50]; 37 | printf("Enter a line of text: "); 38 | scanf("%49[^\n]", str2); // Read until newline, limit to 49 characters 39 | // scanf("%[^\n]c", str2); 40 | printf("You entered: %s\n", str2); 41 | 42 | return 0; 43 | } 44 | 45 | 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /C Programs/structure.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | // Create a structure called myStructure 4 | struct myStructure { 5 | int myNum; 6 | char myLetter; 7 | }; 8 | 9 | void printing(){ 10 | struct myStructure s1; 11 | 12 | printf("the Number: %d",s1.myNum); 13 | 14 | } 15 | 16 | int main() { 17 | // Create a structure variable of myStructure called s1 18 | struct myStructure s1; 19 | 20 | // Assign values to members of s1 21 | s1.myNum = 16; 22 | s1.myLetter = 'V'; 23 | 24 | 25 | // Print values 26 | printf("My number: %d\n", s1.myNum); 27 | printf("My letter: %c\n", s1.myLetter); 28 | 29 | printing(); 30 | 31 | return 0; 32 | } 33 | 34 | -------------------------------------------------------------------------------- /C Programs/studentslist.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main(){ 5 | 6 | int i; 7 | char names[20][20]; 8 | int num, j; 9 | 10 | printf("Enter the number of students:"); 11 | scanf("%d", &num); 12 | 13 | // Clear the input buffer 14 | getchar(); 15 | 16 | for (i = 0; i < num; i++) 17 | { 18 | printf("Enter the %d Student Name:", i + 1); 19 | fgets(names[i], sizeof(names[i]), stdin); 20 | 21 | names[i][strcspn(names[i], "\n")] = '\0'; 22 | } 23 | 24 | printf("Students List:\n"); 25 | 26 | for (j = 0; j < num; j++) 27 | { 28 | puts(names[j]); 29 | } 30 | 31 | return 0; 32 | } 33 | -------------------------------------------------------------------------------- /C Programs/sum if the first n natural numbers.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() { 3 | 4 | int i,n,sum = 0; 5 | 6 | 7 | printf("enter the value of n: "); 8 | scanf("%d",&n); 9 | 10 | for(i = 1; i <= n ; i++){ 11 | 12 | sum = sum + i ; 13 | } 14 | 15 | printf("%d \n",sum); 16 | } -------------------------------------------------------------------------------- /C Programs/sum of digits.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | 5 | int num, sum = 0,a; 6 | 7 | printf("enter the number:"); 8 | scanf("%d",&num); 9 | 10 | while(num > 0) 11 | { 12 | a = num % 10; // sum = sum + (n%10) 13 | sum = sum + a ; 14 | num = num / 10; 15 | } 16 | 17 | printf("sum of digit : %d",sum); 18 | } 19 | -------------------------------------------------------------------------------- /C Programs/swap_number.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void swap(int *a, int *b){ 4 | int temp = *a; 5 | *a = *b; 6 | *b = temp; 7 | } 8 | 9 | int main(){ 10 | 11 | int a,b; 12 | printf("Enter two Numbers: "); 13 | scanf("%d %d",&a,&b); 14 | printf("Number before swap: a = %d, b = %d\n",a,b); 15 | swap(&a,&b); 16 | printf("Number after swap: a = %d, b = %d",a,b); 17 | return 0; 18 | } -------------------------------------------------------------------------------- /C Programs/tem into cdegrees.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(){ 4 | float fr,cent; 5 | 6 | printf("\nEnter the temparature(F):"); 7 | scanf("%f",&fr); 8 | 9 | cent = 5.0 / 9.0 * (fr -32); 10 | 11 | printf("temparature in centigrade = %f\n",cent); 12 | 13 | return 0 ; 14 | } -------------------------------------------------------------------------------- /C Programs/tempCodeRunnerFile.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | typedef struct 4 | { 5 | int doubled,cubed; 6 | }number_range; 7 | 8 | 9 | void calculate(int num,int* doubled,int *cubed) { 10 | 11 | *doubled = num * num; 12 | *cubed = num * num * num; 13 | 14 | } 15 | 16 | number_range calculate2(int num){ 17 | 18 | number_range number; 19 | number.doubled = num * num; 20 | number.cubed = num * num * num; 21 | return number; 22 | } 23 | 24 | int main(){ 25 | 26 | int num = 10; 27 | 28 | number_range nr; 29 | int doubled , cubed; 30 | calculate(num,&doubled, &cubed); 31 | nr = calculate2(num); 32 | 33 | printf("The number using pointer: %d %d\n",doubled, cubed); 34 | printf("The number using structure: %d %d",nr.doubled,nr.cubed); 35 | 36 | return 0; 37 | } -------------------------------------------------------------------------------- /C Programs/test.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(void) { 4 | 5 | FILE *file; 6 | char c; 7 | file = fopen("test.txt","a"); 8 | 9 | // fputs("\nI am Vj!",file); 10 | fprintf(file,"\nHi vijay,How can i help you ?"); 11 | 12 | printf("file writed"); 13 | 14 | fclose(file); 15 | 16 | return 0; 17 | } -------------------------------------------------------------------------------- /C Programs/test.txt: -------------------------------------------------------------------------------- 1 | Hello VJ! 2 | I am Happy to help you today 3 | -------------------------------------------------------------------------------- /C Programs/test1.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int a = 100; 4 | 5 | void function(){ 6 | a = 10; 7 | printf("a in function: %d\n",a); 8 | a = 50; 9 | } 10 | 11 | int main(){ 12 | function(); 13 | printf("a in main: %d",a); 14 | return 0; 15 | } -------------------------------------------------------------------------------- /C Programs/test2.txt: -------------------------------------------------------------------------------- 1 | Hello VJ! 2 | 3 | v 4 | Hello VJ! 5 | I am Happy to help you today 6 | v 7 | Hello VJ! 8 | I am Happy to help you today 9 | v 10 | Hello VJ! 11 | I am Happy to help you today 12 | -------------------------------------------------------------------------------- /C Programs/test3.txt: -------------------------------------------------------------------------------- 1 | Hello VJ! 2 | I am Happy to help you today 3 | Hello VJ! 4 | I am Happy to help you today 5 | -------------------------------------------------------------------------------- /C Programs/test4.txt: -------------------------------------------------------------------------------- 1 | Hello VJ! 2 | I am Happy to help you today 3 | Hello VJ! 4 | I am Happy to help you today 5 | Hi VJ -------------------------------------------------------------------------------- /C Programs/testing.c: -------------------------------------------------------------------------------- 1 | // #include 2 | 3 | // int main() { 4 | 5 | // int n=0,m=0; 6 | // while(m<5,n<7){ 7 | // m++; 8 | // n++; 9 | // printf("%d , %d",m,n); 10 | // } 11 | // return 0; 12 | // } 13 | 14 | // #include 15 | 16 | // int main(){ 17 | // int j,k; 18 | 19 | // for(k=1;k<=3;k++){ 20 | // for(j=3;j>=1;j--){ 21 | 22 | // printf("%d,%d\n",k,j); 23 | // } 24 | // } 25 | // } 26 | 27 | #include 28 | 29 | int main(){ 30 | int a=0,i=0,b; 31 | for(i=0;i<5;i++){ 32 | a+2; 33 | continue; 34 | 35 | printf("a=%d,i=%d\n",a,i); 36 | } 37 | 38 | printf("%d,%d",a,i); 39 | return 0; 40 | 41 | } -------------------------------------------------------------------------------- /C Programs/voting.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #define CANDIDATE_COUNT 4 | 5 | #define CANDIDATE1 "JHON WICK" 6 | #define CANDIDATE2 "JAMES BONT" 7 | #define CANDIDATE3 "TOM CRUZ" 8 | #define CANDIDATE4 "TONY STARK" 9 | 10 | 11 | void votesCount(){ 12 | printf("\n\n ### Voting Statics ###"); 13 | printf("\n %s - %d", CANDIDATE1, votesCount1); 14 | printf("\n %s - %d", CANDIDATE2, votesCount2); 15 | printf("\n %s - %d", CANDIDATE3, votesCount3); 16 | printf("\n %s - %d", CANDIDATE4, votesCount4); 17 | printf("\n %s - %d", "Spoiled Votes", spoiledtvotes); 18 | return 0;void castVote(int choice){ 19 | } 20 | 21 | void getLeadingCandidate(){ 22 | printf("\n\n ### Leading Candidate ###\n\n"); 23 | if(votesCount1>votesCount2 && votesCount1>votesCount3 && votesCount1>votesCount4) 24 | printf("[%s]",CANDIDATE1); 25 | else if(votesCount2>votesCount3 && votesCount2>votesCount4 && votesCount2>votesCount1) 26 | printf("[%s]",CANDIDATE2); 27 | else if(votesCount3>votesCount4 && votesCount3>votesCount2 && votesCount3>votesCount1) 28 | printf("[%s]",CANDIDATE3); 29 | else if(votesCount4>votesCount1 && votesCount4>votesCount2 && votesCount4>votesCount3) 30 | printf("[%s]",CANDIDATE4); 31 | else 32 | printf("-----Warning !!! No-win situation---"); 33 | 34 | } 35 | 36 | int main() 37 | { 38 | int i,choice,select; 39 | 40 | 41 | printf("\n\n ### Welcome to Election/Voting 2023 ####"); 42 | printf("\n\n 1. Cast The Vote"); 43 | printf("\n 2. List Candidate Name"); 44 | printf("\n 0. Exit"); 45 | 46 | printf("\n\n Please enter your choice: "); 47 | scanf("%d",&choice); 48 | 49 | if(choice != 0){ 50 | if(choice == 1){ 51 | int votesCount1=0,votesCount2=0,votesCount3=0,votesCount4=0,spoiledtvotes=0; 52 | printf("\n\n###Please choose your Candidate ###\n\n"); 53 | printf("\n 1.%s",CANDIDATE1); 54 | printf("\n 2.%s",CANDIDATE2); 55 | printf("\n 3.%s",CANDIDATE3); 56 | printf("\n 4.%s",CANDIDATE4); 57 | printf("\n 5.nota"); 58 | 59 | printf("\n\n Input your choice(1-5):"); 60 | scanf("%d",&select); 61 | 62 | switch(select){ 63 | case 1: 64 | votesCount1++; 65 | break; 66 | case 2: 67 | votesCount2++; 68 | break; 69 | case 3: 70 | votesCount3++; 71 | break; 72 | case 4: 73 | votesCount4++; 74 | break; 75 | case 5: 76 | spoiledtvotes++; 77 | break; 78 | default: 79 | printf("\n Error: Wrong Choice!! Please retry"); 80 | getchar(); 81 | 82 | } 83 | } 84 | 85 | //hold the screen 86 | getchar(); 87 | } 88 | return 0; 89 | } 90 | -------------------------------------------------------------------------------- /C Programs/voting_age.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(){ 4 | int voting_age; 5 | 6 | 7 | printf("enter you age:"); 8 | scanf("%d",&voting_age); 9 | 10 | 11 | 12 | if(voting_age >= 18){ 13 | 14 | printf("Legal to vode,collect your voter id\n"); 15 | 16 | } 17 | 18 | /*else if(voting_age == 17) 19 | { 20 | printf("please wait for %d more year to vote\n",18-voting_age); 21 | } */ 22 | 23 | else{ 24 | 25 | 26 | const char *year = (voting_age == 17) ? "year" : "years"; 27 | 28 | printf("please wait for %d more %s to vote\n",18-voting_age,year); 29 | } 30 | 31 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # C-programs 2 | 3 | $ git add . 4 | $ git commit -am 'message' 5 | $ git push 6 | 7 | # my creation of C Programs 8 | 9 | ## Run the C Program 10 | 11 | Compile the program -> gcc -o first firstprogram.c 12 | Run the program -> first 13 | 14 | 15 | 16 | 17 | --------------------------------------------------------------------------------