├── Filename.txt ├── Day_1 ├── README.md ├── new └── John.c ├── Freecodecamp_practise ├── Inno.txt ├── Pointer.c ├── Met ├── a.out ├── For_loop.c ├── main.c ├── Memory_Addresses.c ├── Arrays.c ├── functions.c ├── Nested_Loop.c ├── Return_statement.c ├── while_loop.c ├── Switch_Statement.c ├── calculator.c ├── if_statment.c ├── freecodecamp_practise.c └── structs.c ├── malloc_free ├── README.md ├── main.h └── first_malloc.c ├── Day_4 ├── Ans ├── Play ├── ans ├── If.c └── Ass2.c ├── Static_Libraries ├── main.h ├── Inno ├── add.o ├── mul.o ├── calc.o ├── lib_UDO.a ├── lib_okoye.a ├── add.c ├── mul.c └── calc.c ├── C_argc_argv ├── me ├── Str_to_num.c ├── C_argc_argv.c └── C_argc.c ├── Day_5 ├── compare ├── observe ├── comdowhile.c ├── infinite_loop.c ├── forloop.c ├── whileloop.c ├── multiple.c └── Dowhileloop.c ├── File_Handling ├── .vscode │ └── settings.json └── write.c ├── Doubly_linked_list ├── .vscode │ └── settings.json ├── create.c ├── insertion.c └── insertion2.c ├── Bitwise_Manipulation ├── i └── Bitwise.c ├── hello.c ├── Linked_list ├── Struct.h ├── insert_begin.c ├── Glink.c └── node.c ├── var.c ├── Factorial.c ├── macro.c ├── innocentsax ├── Endinnomos.c ├── nestedloop.c ├── Conditional ├── link3.c ├── Link1.c ├── Switch.c ├── link2.c ├── BMI_Calculator.c └── Scores.c ├── file.c ├── Stack_and_Quenes ├── push.c ├── stacks.c ├── pop.c ├── Linked_list_stack.c └── main.c ├── node2.c ├── node.c ├── pointers.c ├── Sorting_Algorithm.c └── Hash_table.c /Filename.txt: -------------------------------------------------------------------------------- 1 | HELLO WORLD 2 | -------------------------------------------------------------------------------- /Day_1/README.md: -------------------------------------------------------------------------------- 1 | How to use Data type 2 | -------------------------------------------------------------------------------- /Freecodecamp_practise/Inno.txt: -------------------------------------------------------------------------------- 1 | Hello Innocent -------------------------------------------------------------------------------- /malloc_free/README.md: -------------------------------------------------------------------------------- 1 | Solving more problems on Malloc and free 2 | -------------------------------------------------------------------------------- /Day_1/new: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Innocentsax/C_Learning/HEAD/Day_1/new -------------------------------------------------------------------------------- /Day_4/Ans: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Innocentsax/C_Learning/HEAD/Day_4/Ans -------------------------------------------------------------------------------- /Day_4/Play: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Innocentsax/C_Learning/HEAD/Day_4/Play -------------------------------------------------------------------------------- /Day_4/ans: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Innocentsax/C_Learning/HEAD/Day_4/ans -------------------------------------------------------------------------------- /Freecodecamp_practise/Pointer.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | 5 | -------------------------------------------------------------------------------- /Static_Libraries/main.h: -------------------------------------------------------------------------------- 1 | void add(int a, int b); 2 | void mul(int a, int b); 3 | -------------------------------------------------------------------------------- /C_argc_argv/me: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Innocentsax/C_Learning/HEAD/C_argc_argv/me -------------------------------------------------------------------------------- /Day_5/compare: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Innocentsax/C_Learning/HEAD/Day_5/compare -------------------------------------------------------------------------------- /Day_5/observe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Innocentsax/C_Learning/HEAD/Day_5/observe -------------------------------------------------------------------------------- /File_Handling/.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "C_Cpp.errorSquiggles": "disabled" 3 | } -------------------------------------------------------------------------------- /Doubly_linked_list/.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "C_Cpp.errorSquiggles": "disabled" 3 | } -------------------------------------------------------------------------------- /Bitwise_Manipulation/i: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Innocentsax/C_Learning/HEAD/Bitwise_Manipulation/i -------------------------------------------------------------------------------- /Static_Libraries/Inno: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Innocentsax/C_Learning/HEAD/Static_Libraries/Inno -------------------------------------------------------------------------------- /Static_Libraries/add.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Innocentsax/C_Learning/HEAD/Static_Libraries/add.o -------------------------------------------------------------------------------- /Static_Libraries/mul.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Innocentsax/C_Learning/HEAD/Static_Libraries/mul.o -------------------------------------------------------------------------------- /Freecodecamp_practise/Met: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Innocentsax/C_Learning/HEAD/Freecodecamp_practise/Met -------------------------------------------------------------------------------- /Static_Libraries/calc.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Innocentsax/C_Learning/HEAD/Static_Libraries/calc.o -------------------------------------------------------------------------------- /Freecodecamp_practise/a.out: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Innocentsax/C_Learning/HEAD/Freecodecamp_practise/a.out -------------------------------------------------------------------------------- /Static_Libraries/lib_UDO.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Innocentsax/C_Learning/HEAD/Static_Libraries/lib_UDO.a -------------------------------------------------------------------------------- /Static_Libraries/lib_okoye.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Innocentsax/C_Learning/HEAD/Static_Libraries/lib_okoye.a -------------------------------------------------------------------------------- /malloc_free/main.h: -------------------------------------------------------------------------------- 1 | #ifndef MAIN_H 2 | #define MAIN_H 3 | 4 | char *create_array(unsigned int size, char c); 5 | 6 | 7 | #endif 8 | -------------------------------------------------------------------------------- /Static_Libraries/add.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void add(int a, int b) 4 | { 5 | printf("addition of integer: %d\n", a + b); 6 | } 7 | -------------------------------------------------------------------------------- /Static_Libraries/mul.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void mul(int a, int b) 4 | { 5 | printf("Multiplication of integer: %d\n", a * b); 6 | } 7 | -------------------------------------------------------------------------------- /Freecodecamp_practise/For_loop.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | for (int i = 1; i <= 20; i+=5) 6 | { 7 | printf("%d\n", i); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /hello.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | /** 4 | * main - print out Hello world 5 | * 6 | * Return: 0 7 | */ 8 | int main(void) 9 | { 10 | printf("Hello \"Innocent\"\n"); 11 | } 12 | -------------------------------------------------------------------------------- /Static_Libraries/calc.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "main.h" 3 | 4 | int main() 5 | { 6 | int a = 50; 7 | int b = 20; 8 | 9 | add(a,b); 10 | mul(a,b); 11 | 12 | return 0; 13 | } 14 | -------------------------------------------------------------------------------- /Day_5/comdowhile.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | int age; 6 | 7 | do { 8 | printf("ENTER YOUR AGE: "); 9 | scanf("%d\n", &age); 10 | } 11 | while (age < 15 || age > 35); 12 | } 13 | -------------------------------------------------------------------------------- /Linked_list/Struct.h: -------------------------------------------------------------------------------- 1 | #ifndef _MAIN_H_ 2 | #define _MAIN_H_ 3 | 4 | /* Template for our node */ 5 | struct node 6 | { 7 | int age; 8 | struct node *link; 9 | }; 10 | void insert_begin(struct node **head, int num); 11 | #endif 12 | -------------------------------------------------------------------------------- /Freecodecamp_practise/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int main() 6 | { 7 | FILE *fp; 8 | fp = fopen("Inno.txt", "w"); 9 | fprintf(fp, "%s", "Hello Innocent"); 10 | fclose(fp); 11 | 12 | } 13 | -------------------------------------------------------------------------------- /var.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | /** 4 | * main - print the football score. 5 | * 6 | * Return: 0 7 | */ 8 | int main(void) 9 | { 10 | int x, y; 11 | 12 | x = 2; 13 | y = 0; 14 | 15 | printf("Agentina %d:%d Croatia\n", x, y); 16 | } 17 | -------------------------------------------------------------------------------- /Day_5/infinite_loop.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | /** 4 | * main - Print an infinite code on the STDOUT 5 | * 6 | * Return: 0 7 | */ 8 | int main(void) 9 | { 10 | int x = 0; 11 | 12 | while (x < 7) 13 | { 14 | printf("%d", x); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Day_5/forloop.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | /** 4 | * main - Print variables using Do while loop 5 | * 6 | * Return: 0 7 | */ 8 | int main(void) 9 | { 10 | int x = 0; 11 | 12 | for (x = 0; x <=10; x++) 13 | { 14 | printf("%d\n", x); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Day_5/whileloop.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | /** 4 | * main - Print Variables using Whileloop 5 | * 6 | * Return: 0 7 | */ 8 | int main(void) 9 | { 10 | int num = 0; 11 | 12 | while (num < 7) 13 | { 14 | printf("%d\n", num); 15 | num++; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Day_5/multiple.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(void) 4 | { 5 | int n; 6 | 7 | printf("ENTER A NUMBER: "); 8 | scanf("%d", &n); 9 | 10 | 11 | for(int i= 1; i <= 10; i++) 12 | { 13 | printf("%d * %d = %d \n", n, i, n * i); 14 | } 15 | return 0; 16 | } 17 | -------------------------------------------------------------------------------- /Day_5/Dowhileloop.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | /** 4 | * main - Print out variables using Dowhile loops 5 | * 6 | * Return: 0 7 | */ 8 | int main(void) 9 | { 10 | int i = 7; 11 | 12 | do { 13 | printf("%d\n", i); 14 | i++; 15 | } 16 | while (i < 5); 17 | } 18 | -------------------------------------------------------------------------------- /Freecodecamp_practise/Memory_Addresses.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | int age = 30; 6 | double gpa = 3.4; 7 | char grade = 'A'; 8 | 9 | printf("Here is the address for age:%p\n gpa: %p\n grade: %p\n ", &age, &gpa, &grade); 10 | return 0; 11 | } 12 | -------------------------------------------------------------------------------- /Freecodecamp_practise/Arrays.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | //Arrays of Number 6 | int new[] = {2, 4, 6, 8, 10, 12, 14}; 7 | 8 | //To modified any value in the string, u can declare a new function. 9 | new[4] = 321; 10 | printf("%d\n", new[4]); 11 | } 12 | -------------------------------------------------------------------------------- /C_argc_argv/Str_to_num.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int main(int argc, char* argv[]) 6 | { 7 | char str[] = "21f innocent"; 8 | char* endPtr; 9 | long int x = strtol(str, &endPtr, 16); 10 | printf("The number is %ld\n", x); 11 | return 0; 12 | } 13 | -------------------------------------------------------------------------------- /Factorial.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | 4 | void factorial(int n) 5 | { 6 | int a, i; 7 | 8 | a = 1; 9 | i = 1; 10 | while ( i <= n) 11 | { 12 | a = a * 1; 13 | i++; 14 | } 15 | return (a); 16 | } 17 | 18 | int main(void) 19 | { 20 | int f; 21 | 22 | f = factorial(5); 23 | printf("5! = %d\n", f); 24 | return 0; 25 | } 26 | -------------------------------------------------------------------------------- /macro.c: -------------------------------------------------------------------------------- 1 | #include 2 | #define N 5 3 | 4 | int main() 5 | { 6 | int arr[N], i; 7 | 8 | for (i = 0; i < N; i++) 9 | { 10 | printf("Enter the input for index %d: ", i); 11 | scanf("%d", &arr[i]); 12 | } 13 | 14 | printf("\nArray elements are as follows: %d \n", i); 15 | for ( i = 0; i < N; i++) 16 | { 17 | printf("%d ", arr[i]); 18 | } 19 | printf("\n"); 20 | return 0; 21 | } 22 | -------------------------------------------------------------------------------- /Freecodecamp_practise/functions.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | void saxophone(char name[], int age) 5 | { 6 | printf("Hello %s, Your new age is %d!\n", name, age); 7 | } 8 | 9 | int main() 10 | { 11 | //Function is a collection of code that perform a specific task. 12 | saxophone("Innocent", 26); 13 | saxophone("Ekemini", 23); 14 | saxophone("Samuel", 29); 15 | 16 | return 0; 17 | } 18 | -------------------------------------------------------------------------------- /innocentsax: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int main() 6 | { 7 | //Declare a file pointer variable 8 | FILE *fp; 9 | //Open the file using fopen() 10 | fp = fopen("Filename", "w"); 11 | //Process the file using the suitable function 12 | fprintf(fp, "%s", "HELLO WORLD"); 13 | //Close the file using fclose() function 14 | fclose(fp); 15 | 16 | return 0; 17 | } 18 | -------------------------------------------------------------------------------- /Freecodecamp_practise/Nested_Loop.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | int nums[3][2] = 6 | { 7 | {3, 5},//the count start from 0, hence this is 0. 8 | {6, 7},//this is 1. 9 | {19,12},//this is 2. 10 | }; 11 | 12 | //printf("%d\n", nums[0][0]); 13 | 14 | int i, j; 15 | 16 | for (i = 0; i < 3; i++) 17 | { 18 | for (j = 0; j < 2; j++) 19 | { 20 | printf("%d,", nums[i][j]); 21 | } 22 | printf("\n"); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /C_argc_argv/C_argc_argv.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int main(int argc, char* argv[]) 6 | { 7 | int i; 8 | for (i = 0; i < argc; i++) 9 | { 10 | printf("argv[%d]: %s\n", i, argv[i]); 11 | } 12 | 13 | int result = 1; 14 | for (i = 1; i < argc; i++) 15 | { 16 | int x = strtol(argv[i], NULL, 10); 17 | result = result * x; 18 | } 19 | printf("Multiplication result is %d\n", result); 20 | return 0; 21 | } 22 | -------------------------------------------------------------------------------- /C_argc_argv/C_argc.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int main(int argc, char* argv[]) 6 | { 7 | int sum = 0; 8 | printf("argc = %d\n", argc); 9 | printf("Let's see what is in argv[]\n"); 10 | 11 | if (argc > 1) 12 | { 13 | for (int i = 0; i < argc; i++) 14 | { 15 | printf("argv[%d] = %s\n", i, argv[i]); 16 | sum = sum + atoi(argv[i]); 17 | } 18 | printf("The sum of the num = %d\n", sum); 19 | } 20 | return 0; 21 | } 22 | -------------------------------------------------------------------------------- /Freecodecamp_practise/Return_statement.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | double man(double num) 4 | { 5 | //double result = num * num * num; 6 | return num * num * num; 7 | } 8 | 9 | int main() 10 | { 11 | printf("Answer: %f \n", man(3.0)); 12 | } 13 | 14 | //You can actually write a function code here, but you will have to 15 | //put the prototype at the top (above the main function) before you can 16 | //call the function down. 17 | // 18 | //Here is the prototyp example: double man(double num); 19 | -------------------------------------------------------------------------------- /Doubly_linked_list/create.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | //Struct of the node 5 | struct node 6 | { 7 | struct node* prev; 8 | int data; 9 | struct node* next; 10 | }; 11 | 12 | int main() 13 | { 14 | //allocating a memory for the node 15 | struct node *head = malloc(sizeof(struct node)); 16 | head->prev = NULL; 17 | head->data = 10; 18 | head->next = NULL; 19 | //transvering the node 20 | printf("%d\n",head->data); 21 | return 0; 22 | } 23 | -------------------------------------------------------------------------------- /Endinnomos.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | // WAP that request a client to input 5 arrays of numbers 6 | 7 | int moses[5]; 8 | int endesew; 9 | 10 | 11 | for ( endesew = 0; endesew < 5; endesew++) 12 | { 13 | printf("please input a number: "); 14 | scanf("%d", &moses[endesew]); 15 | } 16 | printf("\nThe total number of entered is: %d\n", endesew); 17 | 18 | for (endesew = 0; endesew < 5; endesew++) 19 | { 20 | printf("%d", moses[endesew]); 21 | } 22 | printf("\n"); 23 | 24 | } 25 | -------------------------------------------------------------------------------- /nestedloop.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | int num; 6 | printf("Enter the number of star: "); 7 | scanf("%d", &num); 8 | for (int i = 1; i <= num; i++) 9 | { 10 | for (int j = 1; j <= i; j++) 11 | { 12 | printf(" %d ", j); 13 | } 14 | printf("\n"); 15 | } 16 | 17 | /**int i = 0; 18 | do 19 | { 20 | int j = 0; 21 | do 22 | { 23 | printf(" * "); 24 | j++; 25 | } 26 | while (j < 5); 27 | 28 | printf("\n"); 29 | i++; 30 | } 31 | while (i < 5);*/ 32 | 33 | 34 | 35 | } 36 | -------------------------------------------------------------------------------- /Day_4/If.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | /** 4 | * main - Print my work on if and else statment 5 | * 6 | * Return: 0 7 | */ 8 | int main(void) 9 | { 10 | int age = 70; 11 | 12 | 13 | if (age == 10) 14 | { 15 | printf("You can start playing Saxophone\n"); 16 | } 17 | else if (age < 10) 18 | { 19 | printf("You cannot play the saxophone\n"); 20 | } 21 | else if(age > 10 && age <20) 22 | { 23 | printf("You are too old to play Saxophone\n"); 24 | } 25 | else 26 | { 27 | printf("Please try again letter\n"); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Day_1/John.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | /** 4 | * main - print integar in John story 5 | * 6 | * Return: 0 7 | */ 8 | int main(void) 9 | { 10 | float x, y; 11 | char var[] = "John"; 12 | 13 | x = 4.0; 14 | y = 3.6; 15 | 16 | printf("A short story about %s\n", var); 17 | printf("%s was a coder, he codes in Assembly because he is in school\n", var); 18 | printf("In year 2, John also had a cgpa of %.1f and a grade of a\n", x); 19 | printf("In year 3, %s also had a cgpa of %.1f and a grade of a\n", var, x); 20 | printf("In year 4, %s also had a cgpa of %.1f and a grade of a\n", var, y); 21 | } 22 | -------------------------------------------------------------------------------- /Freecodecamp_practise/while_loop.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | int secretNumber = 5; 6 | int guess; 7 | int guessCount = 0; 8 | int guessLimit = 3; 9 | int outOfGuesses = 0; 10 | 11 | while (guess != secretNumber && outOfGuesses == 0) 12 | { 13 | if(guessCount < guessLimit) 14 | { 15 | printf("Enter a number: "); 16 | scanf("%d", &guess); 17 | guessCount++; 18 | } 19 | else 20 | { 21 | outOfGuesses = 1; 22 | } 23 | } 24 | if (outOfGuesses == 1) 25 | { 26 | printf("Out of Guesses\n"); 27 | } 28 | else 29 | { 30 | printf("You Win!\n"); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Freecodecamp_practise/Switch_Statement.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | char grade; 6 | 7 | 8 | printf("Enter your Grade: "); 9 | scanf(" %c", &grade); 10 | 11 | switch (grade) 12 | { 13 | case 'A': 14 | printf("You are Great!\n"); 15 | break; 16 | case 'B': 17 | printf("You are alright!\n"); 18 | break; 19 | case 'C': 20 | printf("You did poorly!\n"); 21 | break; 22 | case 'D': 23 | printf("You did very Bad!\n"); 24 | break; 25 | case 'F': 26 | printf("You have Fail!\n"); 27 | break; 28 | default: 29 | printf("Invalid Grade\n"); 30 | } 31 | return 0; 32 | } 33 | -------------------------------------------------------------------------------- /malloc_free/first_malloc.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "main.h" 4 | 5 | char *create_array(unsigned int size, char c) 6 | { 7 | /*Write a function that creates an array of chars, and initializes it with a specific char.*/ 8 | char *ptArray; 9 | 10 | //allocating enough space for all array members 11 | ptArray = malloc(size * sizeof(char)); 12 | 13 | //put a char c in each of the memory location. 14 | for (unsigned int count = 0; count < size; count++) 15 | { 16 | //assign the char to the specific memory location. 17 | ptArray[count] = c; 18 | } 19 | 20 | return (ptArray); 21 | 22 | } 23 | -------------------------------------------------------------------------------- /Doubly_linked_list/insertion.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | //Defining the structure of the node 5 | struct node 6 | { 7 | struct node* prev; 8 | int data; 9 | struct node* next; 10 | }; 11 | //adding a node to the empty structure 12 | struct node* addToEmpty(struct node* head, int data) 13 | { 14 | struct node* temp = malloc(sizeof(struct node)); 15 | temp->prev = NULL; 16 | temp->data = data; 17 | temp->next = NULL; 18 | head = temp; 19 | return head; 20 | } 21 | 22 | int main() 23 | { 24 | //Declaring the head 25 | struct node* head = NULL; 26 | head = addToEmpty(head, 45); 27 | //Transvering the node 28 | printf("%d\n", head->data); 29 | return 0; 30 | } 31 | -------------------------------------------------------------------------------- /Day_4/Ass2.c: -------------------------------------------------------------------------------- 1 | #include 2 | /** 3 | * main - Print Assement 2 on the screen 4 | * 5 | * Return: 0 6 | */ 7 | int main(void) 8 | { 9 | int age; 10 | 11 | printf("ENTER YOUR AGE\n"); 12 | scanf("%d", &age); 13 | 14 | 15 | 16 | if (age < 15 || age > 35) 17 | { 18 | printf("Sorry only ages between 15 - 35 is allowed\n"); 19 | } 20 | else if (age == 20) 21 | { 22 | printf("Welcome, You deserve special attention\n"); 23 | } 24 | else if (age == 30) 25 | { 26 | printf("Please Take this program Seriously\n"); 27 | } 28 | else if (age == 34 || age == 35) 29 | { 30 | printf("Please Do everything to Succeed now\n"); 31 | } 32 | else 33 | { 34 | printf("You are Warmly Welcome\n"); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Freecodecamp_practise/calculator.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | double num1, num2; 6 | char ops; 7 | 8 | printf("Enter a number: "); 9 | scanf("%lf", &num1); 10 | printf("Enter an operator: "); 11 | scanf(" %c", &ops); 12 | printf("Enter a number: "); 13 | scanf("%lf", &num2); 14 | 15 | if (ops == '+') 16 | { 17 | printf("%f\n", num1 + num2); 18 | } 19 | else if (ops == '-') 20 | { 21 | printf("%f\n", num1 - num2); 22 | } 23 | else if (ops == '/') 24 | { 25 | printf("%f\n", num1 / num2); 26 | } 27 | else if (ops == '*') 28 | { 29 | printf("%f\n", num1 * num2); 30 | } 31 | else 32 | { 33 | printf("invalid operator, rest in Jesus name"); 34 | } 35 | 36 | return 0; 37 | 38 | } 39 | -------------------------------------------------------------------------------- /Freecodecamp_practise/if_statment.c: -------------------------------------------------------------------------------- 1 | #include 2 | /** 3 | int inno(int num1, int num2) 4 | { 5 | int result; 6 | 7 | if(num1 > num2) 8 | { 9 | result = num1; 10 | } 11 | else 12 | { 13 | result = num2; 14 | } 15 | return result; 16 | } 17 | 18 | int main() 19 | { 20 | printf("%d\n", udo(15, 10)); 21 | return 0; 22 | }*/ 23 | 24 | int udo(int num1, int num2, int num3) 25 | { 26 | int result; 27 | 28 | if (num1 >= num2 && num1 >= num3) 29 | { 30 | result = num1; 31 | } 32 | else if (num2 >= num1 && num2 >= num3) 33 | { 34 | result = num2; 35 | } 36 | else { 37 | result = num3; 38 | } 39 | return result; 40 | } 41 | int main() 42 | { 43 | printf("%d\n", udo(15, 10, 24)); 44 | 45 | 46 | return 0; 47 | } 48 | -------------------------------------------------------------------------------- /Linked_list/insert_begin.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "Struct.h" 4 | 5 | void insert_begin(struct node **head, int num) 6 | { 7 | /* Create a new node */ 8 | struct node *newNode; 9 | 10 | newNode = (struct node *) malloc (sizeof(struct node)); 11 | 12 | if (newNode == NULL) 13 | { 14 | return; 15 | } 16 | 17 | newNode->age = num; 18 | 19 | if (*head == NULL) //Check if list is empty when the head is equal null 20 | { 21 | newNode->link = NULL; 22 | } 23 | else 24 | { 25 | /* Point the next of the new node to what head was pointing to */ 26 | newNode->link = *head; 27 | } 28 | 29 | 30 | /* Redirect head to point to new node */ 31 | *head = newNode; 32 | 33 | printf("@iamINNOCENT.UDO.. I do hard things with Singly Linked List..>"); 34 | } 35 | -------------------------------------------------------------------------------- /Conditional/link3.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | struct node 4 | { 5 | int value; 6 | struct node *next; 7 | }; 8 | typedef struct node inno; 9 | 10 | inno *create_new_node(int value) 11 | { 12 | inno *result = malloc(sizeof(inno)); 13 | result->value = value; 14 | result->next = NULL; 15 | 16 | return result; 17 | } 18 | 19 | void printlist(inno *head) 20 | { 21 | inno *temp = head; 22 | while (temp != NULL) 23 | { 24 | printf("%d -->", temp->value); 25 | temp = temp->next; 26 | } 27 | printf("\n"); 28 | } 29 | 30 | int main() 31 | { 32 | inno *head = NULL; 33 | inno *temp; 34 | 35 | for(int i = 0; i < 25; i++) 36 | { 37 | temp = create_new_node(i); 38 | temp->next = head; 39 | head = temp; 40 | } 41 | 42 | printlist(head); 43 | 44 | return 0; 45 | } 46 | -------------------------------------------------------------------------------- /file.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int main() 6 | { 7 | //Declare a file pointer variable 8 | FILE *fp; 9 | //Open the file using fopen() and write into the file 10 | fp = fopen("Filename.txt", "w"); 11 | //Process the file using the suitable function 12 | fprintf(fp, "%s", "HELLO WORLD\n"); 13 | //Close the file using fclose() function 14 | fclose(fp); 15 | 16 | 17 | FILE *read;//Pointer variable which is the first step in file handing 18 | char see[100];//Char variable that read the characters in a file 19 | read = fopen("Filename.txt", "r");//fopen() to open the file 20 | printf("%s",fgets(see, 50, read));// get the information of file using fgets and print it out @%s 21 | fclose(read);// the close the file 22 | 23 | 24 | return 0; 25 | } 26 | -------------------------------------------------------------------------------- /Stack_and_Quenes/push.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #define MAX 5 4 | 5 | //Write a program to implement a stack in an array stack_arr[] using stack_arr as the top element. 6 | int stack_arr[MAX]; 7 | int first = -1; // first replaces the top, because all element must come through the top(first) 8 | 9 | void push(int data) 10 | { 11 | int i; 12 | first +=1; 13 | for(i=first; i>0; i--) 14 | stack_arr[i] = stack_arr[i-1]; 15 | stack_arr[0] = data; 16 | } 17 | 18 | void print() 19 | { 20 | int i; 21 | if(first == -1) 22 | { 23 | printf("stack underflow\n"); 24 | exit(1); 25 | } 26 | for(i=0; i<=first; i++) 27 | printf("%d ", stack_arr[i]); 28 | printf("\n"); 29 | } 30 | int main() 31 | { 32 | push(30); 33 | push(90); 34 | push(40); 35 | 36 | print(); 37 | return 0; 38 | } 39 | -------------------------------------------------------------------------------- /Conditional/Link1.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | struct node 5 | { 6 | int value; 7 | struct node *next; 8 | }; 9 | typedef struct node inno; 10 | 11 | int main(void) 12 | { 13 | inno *n1, n2, n3; 14 | inno *head; 15 | 16 | n1 = malloc(sizeof(inno)); 17 | // Lets declare Values 18 | n1->value = 24; 19 | n2.value = 45; 20 | n3.value = 39; 21 | 22 | //Link them up 23 | head = n1; 24 | n3.next = NULL; 25 | n2.next = &n3; 26 | n1->next = &n2; 27 | 28 | inno n4; 29 | n4.value = 27; 30 | n4.next = &n2; 31 | n1->next = &n4; 32 | 33 | inno n5; 34 | n5.value = 100; 35 | n5.next = &n3; 36 | n2.next = &n5; 37 | 38 | 39 | inno *temp = head; 40 | while (temp != NULL) 41 | { 42 | printf("%d -->", temp->value); 43 | temp = temp->next; 44 | } 45 | printf("\n"); 46 | 47 | return 0; 48 | } 49 | -------------------------------------------------------------------------------- /Bitwise_Manipulation/Bitwise.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | 4 | int main() 5 | { 6 | /**int x,y,z,m; 7 | x = 6; 8 | y = 12; 9 | 10 | m = x & y; 11 | 12 | 13 | printf("AND = %d\n", m); 14 | 15 | int or = x | y; 16 | printf("OR = %d\n", or); 17 | 18 | int xor = x ^ y; 19 | printf("XOR = %d\n", xor); 20 | 21 | int shiftRight = y >> 2; 22 | printf(" >> = %d\n", shiftRight); 23 | 24 | int shiftLeft = x << 2; 25 | printf("<< = %d\n", shiftLeft); 26 | 27 | int not = x ~ y; 28 | printf("NOT = %d\n", not);*/ 29 | 30 | /**char x = 1, y = 2; 31 | if(x&y) 32 | printf("Result of x&y is 1\n"); 33 | if(x&&y) 34 | printf("Result of x&&y is 1\n");*/ 35 | 36 | int a = 4, b = 3; 37 | a = a ^ b; 38 | b = a ^ b; 39 | a = a ^ b; 40 | 41 | printf("After XOR, a = %d and b = %d\n", a, b); 42 | 43 | return 0; 44 | 45 | } 46 | -------------------------------------------------------------------------------- /Linked_list/Glink.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | struct test 5 | { 6 | int num; 7 | struct test *link; 8 | }; 9 | int main(void) 10 | { 11 | struct test *head; 12 | struct test *testA, *testB, *testC; 13 | 14 | head = (struct test *) malloc(sizeof(struct test)); 15 | testA = (struct test *) malloc(sizeof(struct test)); 16 | testB = (struct test *) malloc(sizeof(struct test)); 17 | testC = (struct test *) malloc(sizeof(struct test)); 18 | 19 | testA->num = 200; 20 | testB->num = 500; 21 | testC->num = 1000; 22 | 23 | testA->link = testB; 24 | testB->link = testC; 25 | testC->link = NULL; 26 | 27 | head = testA; 28 | 29 | while (head->link != NULL) 30 | { 31 | head = head->link; 32 | printf("%d -->", head->num); 33 | } 34 | printf("%d", head->num); 35 | printf("\n"); 36 | 37 | 38 | 39 | } 40 | -------------------------------------------------------------------------------- /Conditional/Switch.c: -------------------------------------------------------------------------------- 1 | #include 2 | /** 3 | * @Author --> INNOCENT UDO || ALX COHORT 11 4 | * 5 | * main - Write a program for a school grading System. the grade are 6 | * 80 ... 100, 70 ... 79, 65 ... 69, 60 ... 64, 50 ... 59, and 0 ...49. 7 | * 8 | * Return: 0 9 | */ 10 | 11 | 12 | int main(void) 13 | { 14 | int score; 15 | 16 | printf("Kindly enter your score: "); 17 | scanf("%d", &score); 18 | 19 | switch (score) 20 | { 21 | case 80 ... 100: 22 | printf("A\n"); 23 | break; 24 | case 70 ... 79: 25 | printf("B\n"); 26 | break; 27 | case 65 ... 69: 28 | printf("C\n"); 29 | break; 30 | case 60 ... 64: 31 | printf("D\n"); 32 | break; 33 | case 50 ... 59: 34 | printf("E\n"); 35 | break; 36 | case 0 ... 49: 37 | printf("Failed\n"); 38 | break; 39 | default: 40 | printf("Invalid Score\n"); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /Freecodecamp_practise/freecodecamp_practise.c: -------------------------------------------------------------------------------- 1 | /**#include 2 | 3 | // main - Print the addition of numbers using printf 4 | 5 | int main() 6 | { 7 | int num1, num2; 8 | 9 | printf("Enter your first number: "); 10 | scanf("%d", &num1); 11 | 12 | printf("Enter your Second number: "); 13 | scanf("%d", &num2); 14 | 15 | printf("Ans: %d\n", num1 * num2); 16 | 17 | 18 | return 0; 19 | }*/ 20 | 21 | #include 22 | 23 | int main() 24 | { 25 | //Building a Mad Libs Game 26 | char color[20]; 27 | char noun[20]; 28 | char celeb[20]; 29 | 30 | printf("Enter your color: "); 31 | fgets(color, 20, stdin); 32 | printf("Enter your noun: "); 33 | scanf("%s", noun); 34 | printf("Enter your celeb: "); 35 | scanf("%s", celeb); 36 | 37 | printf("Roses are %s\n", color); 38 | printf("%s are Blue\n", noun); 39 | printf("I Love %s\n", celeb); 40 | } 41 | -------------------------------------------------------------------------------- /Conditional/link2.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | struct node 4 | { 5 | int value; 6 | struct node *next; 7 | }; 8 | typedef struct node inno; 9 | 10 | inno *create_new_node(int value) 11 | { 12 | inno *result = malloc(sizeof(inno)); 13 | result->value = value; 14 | result->next = NULL; 15 | 16 | return result; 17 | } 18 | 19 | void printlist(inno *head) 20 | { 21 | inno *temp = head; 22 | while (temp != NULL) 23 | { 24 | printf("%d -->", temp->value); 25 | temp = temp->next; 26 | } 27 | printf("\n"); 28 | } 29 | 30 | int main() 31 | { 32 | inno *head; 33 | inno *temp; 34 | 35 | temp = create_new_node(27); 36 | head = temp; 37 | 38 | temp = create_new_node(8); 39 | temp->next = head; 40 | head = temp; 41 | 42 | temp = create_new_node(100); 43 | temp->next = head; 44 | head = temp; 45 | 46 | printlist(head); 47 | 48 | return 0; 49 | } 50 | -------------------------------------------------------------------------------- /Freecodecamp_practise/structs.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | //Struct is a Data structure that we can store group of Data types 5 | //such as char, int, double and string. 6 | struct Phone //Attribute of my phone 7 | { 8 | char name[35]; 9 | char version[20]; 10 | int warranty; 11 | double ipm; 12 | }; 13 | 14 | int main() 15 | { 16 | struct Phone samsung; 17 | samsung.warranty = 2; 18 | samsung.ipm = 119.657; 19 | strcpy( samsung.name, "A03\n"); 20 | strcpy( samsung.version, "Private\n"); 21 | 22 | struct Phone nokia; 23 | nokia.warranty = 5; 24 | nokia.ipm = 234.987; 25 | strcpy( nokia.name, "Spark"); 26 | strcpy( nokia.version, "terminal"); 27 | 28 | struct Phone gionee; 29 | gionee.warranty = 24; 30 | gionee.ipm = 2387.678; 31 | strcpy( gionee.name, "Charming"); 32 | strcpy( gionee.version, "Public"); 33 | 34 | 35 | printf("%lf\n", nokia.ipm); 36 | } 37 | -------------------------------------------------------------------------------- /File_Handling/write.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | // A program that write staff names into a text file 5 | 6 | // STEP BY STEP PROCEDURE TO WRITE INTO A FILE 7 | int main(void) 8 | { 9 | char str[500];// Optional: Declare a variable that collect input from user 10 | //Step.1: Declare a pointer variable 11 | FILE *fptr; 12 | //Step 2: Open the file Using fopen() 13 | 14 | fptr = fopen("staff_names.txt", "w"); 15 | //check if the pointer variable is pointing to a NULL file 16 | if (fptr == NULL) 17 | { 18 | printf("Error"); 19 | exit (1); 20 | } 21 | //Here is where you get input from the User 22 | printf("Kindly input the staff names: "); 23 | scanf("%s", str); 24 | 25 | //step 3: Processing information into the file, using fprintf 26 | fprintf(fptr,"%s", fgets(str, 100, stdin)); 27 | 28 | //step 4: Close the file 29 | fclose(fptr); 30 | 31 | return 0; 32 | } 33 | -------------------------------------------------------------------------------- /Stack_and_Quenes/stacks.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #define MAX 4 4 | 5 | // Write a program to PUSH an element onto Stack 6 | //int stack_arr[4]; //Global Declaration of stack 1 7 | int stack_arr[MAX]; // Global Declaration of stack 2 8 | int top = -1; // top = -1 indicates that the stack is empty 9 | 10 | void push(int data) 11 | { 12 | if(top == MAX -1)// if isFull() return 0, then it indicates the stack is not full. hence, the code after if construct will be evaluated 13 | { 14 | printf("Stack overflow"); 15 | return;//indicate the end of the function 16 | } 17 | top = top + 1; 18 | stack_arr[top] = data; 19 | } 20 | void print() 21 | { 22 | for(int i = 0; i <=top; i++) 23 | printf("%d ",stack_arr[i]); 24 | printf("\n"); 25 | } 26 | int main() 27 | { 28 | 29 | push(1); // Recall: pushing an element involve two steps: 1 increment the variables top by 1 and 2, store the value at the index top 30 | push(3); 31 | push(5); 32 | push(7); 33 | print(); 34 | } 35 | -------------------------------------------------------------------------------- /node2.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | struct node 5 | { 6 | int age; 7 | struct node *link; 8 | }; 9 | int main(void) 10 | { 11 | /* Declare the Head */ 12 | struct node *head; 13 | /* Declare a node */ 14 | struct node *nodeA, nodeB, nodeC; 15 | 16 | /* Allocate memory for the node using malloc */ 17 | nodeA = malloc(sizeof(struct node)); 18 | nodeB = malloc(sizeof(struct node)); 19 | nodeC = malloc(sizeof(struct node)); 20 | /* Assign value to the node */ 21 | nodeA->age = 27; 22 | nodeB->age = 24; 23 | nodeC->age = 19; 24 | 25 | /* Assigning a link to the node */ 26 | nodeA->link = nodeB; 27 | nodeB->link = nodeC; 28 | nodeC->link = NULL; 29 | 30 | /* Create a head */ 31 | head = nodeA; 32 | 33 | /* Create a temporal pointer */ 34 | temp = head; 35 | 36 | /* Traversing the linkes list and printing each member */ 37 | while (temp->next != NULL) 38 | { 39 | printf("%d -->", temp->age); 40 | temp = temp->next; 41 | } 42 | printf("%d -->\n", temp->age); 43 | 44 | } 45 | -------------------------------------------------------------------------------- /node.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | /** 5 | * main - A program on how to create a node in a singly linked list 6 | * 7 | * Return: 0; 8 | */ 9 | 10 | struct node 11 | { 12 | int data; 13 | struct node *link; 14 | }; 15 | int main(void) 16 | { 17 | struct node *head = malloc(sizeof(struct node)); 18 | head -> data = 45; 19 | head -> link = NULL; 20 | 21 | struct node *current = malloc(sizeof(struct node)); 22 | current -> data = 98; 23 | current -> link = NULL; 24 | head -> link = current; 25 | 26 | /** 27 | current = malloc(sizeof(struct node)); 28 | current -> data = 3; 29 | current -> link = NULL;*/ 30 | 31 | //current -> link -> link = current; 32 | struct node *current3 = malloc(sizeof(struct node)); 33 | current3 -> data = 26; 34 | current3 -> link = NULL; 35 | current -> link = current3; 36 | 37 | while (head -> link != NULL) 38 | { 39 | printf("%d-->%d-->%d\n", head -> data, current -> data, current3 -> data); 40 | current = current -> link -> link; 41 | } 42 | 43 | return 0; 44 | } 45 | -------------------------------------------------------------------------------- /Stack_and_Quenes/pop.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #define MAX 4 4 | 5 | // Write a program to pop an element onto Stack 6 | //int stack_arr[4]; //Global Declaration of stack 1 7 | int stack_arr[MAX]; // Global Declaration of stack 2 8 | int top = -1; // top = -1 indicates that the stack is empty 9 | void push(int data) 10 | { 11 | if(top == MAX - 1) 12 | { 13 | printf("Stack overflow"); 14 | return;//indicate the end of the function 15 | } 16 | top = top + 1; 17 | stack_arr[top] = data; 18 | } 19 | int pop() 20 | { 21 | int value; 22 | if(top == -1) 23 | { 24 | printf("Stack underflow"); 25 | exit(1); 26 | } 27 | value = stack_arr[top]; 28 | top = top - 1; 29 | return value; 30 | } 31 | void print() 32 | { 33 | for(int i = 0; i<=top; i++) 34 | printf("%d ",stack_arr[i]); 35 | printf("\n"); 36 | } 37 | int main() 38 | { 39 | int data; 40 | push(1); // Recall: pushing an element involve two steps: 1 increment the variables top by 1 and 2, store the value at the index top 41 | push(3); 42 | push(5); 43 | push(7); 44 | data = pop(); 45 | print(); 46 | 47 | } 48 | -------------------------------------------------------------------------------- /Doubly_linked_list/insertion2.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | //Defining the structure of the node 5 | struct node 6 | { 7 | struct node* prev; 8 | int data; 9 | struct node* next; 10 | }; 11 | 12 | //Adding a node to the empty structure of the node 13 | struct node* addToEmpty(struct node* head, int data) 14 | { 15 | struct node* temp = malloc(sizeof(struct node)); 16 | temp->prev = NULL; 17 | temp->data = data; 18 | temp->next = NULL; 19 | head = temp; 20 | return head; 21 | } 22 | //Adding a node to the beginning of the node 23 | struct node* addAtBeg(struct node* head, int data) 24 | { 25 | struct node* temp = malloc(sizeof(struct node)); 26 | temp->prev = NULL; 27 | temp->data = data; 28 | temp->next = NULL; 29 | 30 | temp->next = head; 31 | head->prev = temp; 32 | 33 | head = temp; 34 | return head; 35 | } 36 | 37 | int main() 38 | { 39 | //Declaring the head 40 | struct node* head = NULL; 41 | //Declaring a pointer to the node 42 | struct node* ptr; 43 | //calling the 2 structures declared above 44 | head = addToEmpty(head, 45); 45 | head = addAtBeg(head, 34); 46 | 47 | ptr = head; 48 | //transvering the node 49 | while(ptr != NULL) 50 | { 51 | printf("%d ", ptr->data); 52 | ptr = ptr->next; 53 | } 54 | printf("\n"); 55 | return 0; 56 | } 57 | -------------------------------------------------------------------------------- /pointers.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | /**int arrayNumber[5][2] = 6 | { 7 | {2, 3}, 8 | {4, 5}, 9 | {9, 0}, 10 | {4, 3}, 11 | {7, 6}, 12 | }; 13 | int i, j; 14 | 15 | for ( i = 0; i < 5; i++) 16 | { 17 | for ( j = 0; j < 2; j++) 18 | { 19 | printf("arrayNumber[%d][%d] = %d\n", i, j, arrayNumber[i][j]); 20 | } 21 | }*/ 22 | /** 2D array declaration 23 | int abc[5][4]; 24 | /*Counter variables for the loop 25 | int i, j; 26 | for(i=0; i<5; i++) { 27 | for(j=0;j<4;j++) { 28 | printf("Enter value for abc[%d][%d]:", i, j); 29 | scanf("%d", &abc[i][j]); 30 | } 31 | }*/ 32 | 33 | 34 | /** 35 | int abc[5][4] = { 36 | {0,1,2,3}, 37 | {4,5,6,7}, 38 | {8,9,10,11}, 39 | {12,13,14,15}, 40 | {16,17,18,19}, 41 | }; 42 | 43 | for (int i = 0; i <= 4; i++) 44 | { 45 | printf("%p ", abc[i]); 46 | }*/ 47 | 48 | /** 49 | int n; 50 | 51 | printf("size of 'char' on my computer: %ld bytes\n",sizeof(char)); 52 | printf("size of type 'int' on my computer: %ld byte\n",sizeof(int)); 53 | printf("size of type 'float' on my computer: %ld byte\n",sizeof(float)); 54 | printf("size of type 'double' on my computer: %ld byte\n",sizeof(double));*/ 55 | 56 | int *p; 57 | int **q; 58 | printf("Size of pointer: %lu\n", sizeof(p)); 59 | printf("size of pointer to pointer: %lu\n", sizeof(*q)); 60 | 61 | return 0; 62 | } 63 | -------------------------------------------------------------------------------- /Conditional/BMI_Calculator.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | /** 4 | * Author - UDO INNOCENT CHARLES || ALX COHORT 11 || 26 JANUARY 2023 5 | * 6 | * main - A program that Calculate BODY MASS INDEX (BMI). 7 | * Return: 0; 8 | */ 9 | int main(void) 10 | { 11 | //Declaration of variables for storing data. 12 | float weight, height, bmi; 13 | 14 | // Prompt user to input weight in kilogram. 15 | printf("Kindly enter your weight in kg: "); 16 | scanf("%f\n", &weight); 17 | // Prompt user to input height in Meters 18 | printf("Kindly enter your height in meter: "); 19 | scanf("%f\n", &height); 20 | //Here is the calculation for BMI according to the standard formular 21 | bmi = weight / (height * height); 22 | // Print out result on the Screen 23 | printf("Your BMI is %f\n", bmi); 24 | // Using logical statement to determine the class of the obtained result 25 | if (bmi < 18) 26 | { 27 | printf("You are UNDERWEIGHT\n"); 28 | } 29 | else if (bmi >= 18 && bmi <= 25) 30 | { 31 | printf("Your Weight is NORMAL\n"); 32 | } 33 | else if (bmi >= 26 && bmi <= 29) 34 | { 35 | printf("You are OVERWEIGHT\n"); 36 | } 37 | else if (bmi >= 30) 38 | { 39 | printf("Its OBESITY\n"); 40 | 41 | if (bmi >= 30 && bmi <= 34) 42 | { 43 | printf("You have Class 1 Obesity\n"); 44 | } 45 | else if (bmi >= 35 && bmi <= 39) 46 | { 47 | printf("You have Class 2 Obesity\n"); 48 | } 49 | else if (bmi >= 40) 50 | { 51 | printf("You have Class 3 Obesity\n"); 52 | } 53 | } 54 | 55 | } 56 | -------------------------------------------------------------------------------- /Stack_and_Quenes/Linked_list_stack.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | /** 5 | * Important note: Linked list is use in Stack Data structure when the size of the stack is not known in advance 6 | * 7 | */ 8 | 9 | struct node 10 | { 11 | int data; 12 | struct node* link; 13 | } *top = NULL; 14 | 15 | void push(int data) 16 | { 17 | struct node* newNode; 18 | newNode = malloc(sizeof(newNode)); 19 | //Checking if memory can't be allocated for any reason 20 | if(newNode == NULL) 21 | { 22 | printf("Stack Overflow.\n"); 23 | exit(1); 24 | } 25 | newNode->data = data; 26 | newNode->link = NULL; 27 | 28 | newNode->link = top; 29 | top = newNode; 30 | } 31 | 32 | void print() 33 | { 34 | struct node* temp; 35 | temp = top; 36 | printf("The stack elements are: "); 37 | while(temp) 38 | { 39 | printf("%d ", temp->data); 40 | temp = temp->link; 41 | } 42 | printf("\n"); 43 | } 44 | 45 | int main() 46 | { 47 | int choice, data; 48 | while(1) 49 | { 50 | printf("1. Push\n"); 51 | printf("2. Print\n"); 52 | printf("3. Quit\n"); 53 | printf("\n"); 54 | printf("Enter your choice: "); 55 | scanf("%d", &choice); 56 | 57 | switch(choice) 58 | { 59 | case 1: 60 | printf("Enter the element to be pushed: "); 61 | scanf("%d", &data); 62 | push(data); 63 | break; 64 | 65 | case 2: 66 | print(); 67 | break; 68 | case 3: 69 | exit(1); 70 | 71 | default: 72 | printf("Wrong Choice\n"); 73 | break; 74 | } 75 | } 76 | return 0; 77 | } 78 | -------------------------------------------------------------------------------- /Linked_list/node.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "Struct.h" 4 | /** 5 | struct node 6 | { 7 | int age; 8 | struct node *link; 9 | };*/ 10 | 11 | void printlist(struct node *head) 12 | { 13 | struct node *temp = head; 14 | while (temp->link != NULL) 15 | { 16 | printf("%d -->", temp->age); 17 | temp = temp->link; 18 | } 19 | printf("%d -->", temp->age); 20 | printf("\n"); 21 | } 22 | int main(void) 23 | { 24 | /* Declare the Head */ 25 | struct node *head; 26 | head = (struct node *) malloc(sizeof(struct node)); 27 | /* Declare a node */ 28 | struct node *nodeA, *nodeB, *nodeC; 29 | 30 | /* Allocate memory for the node using malloc */ 31 | nodeA = (struct node *) malloc(sizeof(struct node)); 32 | nodeB = (struct node *) malloc(sizeof(struct node)); 33 | nodeC = (struct node *) malloc(sizeof(struct node)); 34 | /* Assign value to the node */ 35 | nodeA->age = 27; 36 | nodeB->age = 24; 37 | nodeC->age = 19; 38 | 39 | /* Assigning a link to the node */ 40 | nodeA->link = nodeB; 41 | nodeB->link = nodeC; 42 | nodeC->link = NULL; 43 | 44 | /* Create a head */ 45 | head = nodeA; 46 | 47 | /* Inserting new node at the beginning */ 48 | insert_begin(&head, 70); 49 | 50 | /* Traversing the linkes list and printing each member */ 51 | /**while (head->link != NULL) 52 | { 53 | head = head->link; 54 | printf("%d -->", head->age); 55 | } 56 | printf("%d\n", head->age);*/ 57 | printlist(head); 58 | } 59 | -------------------------------------------------------------------------------- /Conditional/Scores.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | /** 4 | * @Author --> INNOCENT UDO || ALX COHORT 11 5 | * 6 | * main - WAP(Write a program) for a school grading System. the grades are: 80 -> 100 = A; 7 | * 70 -> 79 = B; 65 -> 69 = C; 50 -> 59 = D; Below 40 -> F. 8 | * 9 | * Return: 0 10 | */ 11 | 12 | int main(void) 13 | { 14 | int score = 20; 15 | 16 | /* Tell your user to type in their score */ 17 | printf("Enter you Score: \n"); 18 | /* Accept the user's input */ 19 | scanf("%d", &score); 20 | 21 | /* Check if the score is between 80 and 100, then print the grade */ 22 | if (score >= 80 && score <= 100) 23 | { 24 | printf("A\n"); 25 | /* Using a nested-if-else loop to check for Distinction and Excellent */ 26 | if (score >= 90) 27 | { 28 | printf("Distinction! You deserve a Gift.\n"); 29 | 30 | /* Using a nested-if-else to determine the type of gift according to score */ 31 | if (score >= 95) 32 | { 33 | printf("Your Gifts is GOLD\n"); 34 | } 35 | else 36 | { 37 | printf("Your Gift is SLIVER\n"); 38 | } 39 | } 40 | else 41 | { 42 | printf("Excellent! But no Gift.\n"); 43 | } 44 | } 45 | 46 | /* Check if the score is between 70 to 79 then print grade B */ 47 | else if (score >= 70 && score <= 79) 48 | { 49 | printf("B\n"); 50 | } 51 | 52 | /* Check if the Score is between 65 to 69 then print grade C */ 53 | 54 | else if (score >= 60 && score <= 69) 55 | { 56 | printf("C\n"); 57 | } 58 | 59 | /* Check if the score is between 50 to 59 then print grade D */ 60 | else if (score >= 50 && score <= 59) 61 | { 62 | printf("D\n"); 63 | } 64 | else 65 | { 66 | printf("Failed\n"); 67 | } 68 | 69 | return 0; 70 | 71 | } 72 | -------------------------------------------------------------------------------- /Stack_and_Quenes/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #define MAX 4 4 | 5 | /** 6 | * main - write a program that perform all the function in Stack Data Structure 7 | * @ 1. push 8 | * @ 2. pop 9 | * @ 3. Print the top element 10 | * @ 4. Print all the elements of the stack 11 | * @ 5. Quit 12 | * hint: Prompt your user for input: Please enter your choice 13 | * 14 | * Return: 0; 15 | */ 16 | int stack_arr[MAX]; 17 | int top = -1; 18 | 19 | int isFull() 20 | { 21 | if(top == MAX - 1) 22 | return 1; //indicates the end of the function 23 | else 24 | return 0; 25 | } 26 | 27 | int isEmpty() 28 | { 29 | if(top == -1) 30 | return 1; 31 | else 32 | return 0; 33 | } 34 | 35 | void push(int data) 36 | { 37 | if(isFull()){ 38 | printf("Stack Overflow\n"); 39 | return; 40 | } 41 | top = top + 1; 42 | stack_arr[top] = data; 43 | } 44 | 45 | int pop() 46 | { 47 | int value; 48 | if(isEmpty()) 49 | { 50 | printf("Stack underflow\n"); 51 | exit(1); 52 | } 53 | value = stack_arr[top]; 54 | top = top - 1; 55 | return value; 56 | } 57 | 58 | int peek() 59 | { 60 | if(isEmpty()) 61 | { 62 | printf("Stack underflow\n"); 63 | exit(1); 64 | } 65 | 66 | return stack_arr[top]; 67 | } 68 | 69 | void print() 70 | { 71 | int i; 72 | if(top == -1) 73 | { 74 | printf("Stack underflow\n"); 75 | return; 76 | } 77 | 78 | for(i=top; i >=0; i--) 79 | printf("%d ", stack_arr[i]); 80 | printf("\n"); 81 | } 82 | int main() 83 | { 84 | int choice, data; 85 | 86 | while(1) 87 | { 88 | printf("\n"); 89 | printf("1. Push\n"); 90 | printf("2. Pop\n"); 91 | printf("3. Print the top element\n"); 92 | printf("4. Print all the elements of the Stack\n"); 93 | printf("5. Quit\n"); 94 | printf("Please enter your choice: "); 95 | scanf("%d", &choice); 96 | 97 | switch(choice){ 98 | case 1: 99 | printf("Enter the element to be pushed: "); 100 | scanf("%d", &data); 101 | push(data); 102 | break; 103 | case 2: 104 | data = pop(); 105 | printf("Deleted element is %d\n", data); 106 | break; 107 | case 3: 108 | printf("The topmost element of the stack is %d\n", peek()); 109 | break; 110 | case 4: 111 | print(); 112 | break; 113 | case 5: 114 | exit(1); 115 | default: 116 | printf("Wrong Choice\n"); 117 | 118 | } 119 | } 120 | return 0; 121 | } 122 | -------------------------------------------------------------------------------- /Sorting_Algorithm.c: -------------------------------------------------------------------------------- 1 | /*INTRODUCTION TO SORTING 2 | 3 | SORTING: Sorting is arranging the elements in a list or collection in increasing or decreasing order of some property 4 | 5 | *Unsorted: Linear Search 6 | *Sorted: Binary Search 7 | 8 | ==> Different types of Sorting Algorithms we will be looking at: 9 | 1. Bubble sort 10 | 2. Selection sort 11 | 3. Insertion sort 12 | 4. Merge sort 13 | 5. Quick sort 14 | 6. Heap sort 15 | 7. Counting Sort 16 | 8. Radix Sort 17 | 18 | ==> Classification of sorting based on parameter: 19 | 1. Time complexity 20 | 2. Space Complexity or memory usage 21 | *in place, constant memory 22 | *Memory usage grows with input-size 23 | 3. Stability 24 | 4. Internal sort(All records in main memory or RAM) or External sort(records are on disk/tapes) 25 | 5. Recursive or Non- recursive 26 | */ 27 | 28 | #include 29 | #include 30 | void insertion_sort(int a[], int length){ 31 | for(int i = 1; i < length; i++){ 32 | int key = a[i]; 33 | int j = i - 1; 34 | 35 | while (j >= 0 && a[j] > key){ 36 | a[j + 1] = a[j]; 37 | j = j - 1; 38 | } 39 | a[j + 1] = key; 40 | } 41 | } 42 | int main() 43 | { 44 | int a[] = {9, 5, 6, 3, 8, 7, 2, 10}; 45 | insertion_sort(a, 8); 46 | for(int i = 0; i < 8; i++){ 47 | printf("a[%d] = %d\n", i, a[i]); 48 | }printf("\n"); 49 | } 50 | /* 51 | THE BUBBLE SORT ALGORITHM: 52 | ==> The bubble sort algorithm is the fundamental snd simplest form of an algorithm 53 | 54 | ==> The bubble sort algorithm moves through a sequence of data and rearranges them into ascending or descending order one number at a time. 55 | 56 | ==> Bubble sort algorithm is also known as sinking sort algorithm 57 | 58 | ==> Bubble sort algorithm does not search an array as a whole, it works by comparing two adjacent pairs of elements in an array. 59 | 60 | ==> If the elements are not in the correct order, they are swapped so that largest of two moves up, and this process continues until the most significant elements bubble up to the highest position 61 | 62 | ==> After this occurs, the search for the next most significant object starts, and the swapping continues until the whole array is in the correct position. 63 | 64 | ==>How does the Bubble Sort Algorithm Works: 65 | n = Number of elements in the array 66 | n-1 = Number of time the comparison takes place. 67 | e.g 5-1 = 4 68 | ==> Variation of Bubble Sort Algorithm 69 | 1. Odd-even sort is a parallel version of bubble sort for the message passing system. 70 | 71 | 2. Cocktail Shaker sort is a bi-directional bubble sort that first goes from beginnig to end and then ends to the beginning. 72 | 73 | ==> Complexity of Bubble Sort Algorithm 74 | i. Best case performance(O(n)) 75 | ii. Average case performance(O(n*n)) 76 | iii. Worst case performance(O(n*n)) 77 | */ 78 | 79 | #include 80 | #include 81 | 82 | int main(){ 83 | int arr[50], num, a, b, temp; 84 | printf("Enter the number of elements\n"); 85 | scanf("%d", &num); 86 | 87 | printf("Enter the element", num); 88 | for(a = 0; a < num; a++) 89 | scanf("%d", &arr[a]); 90 | 91 | /*First for loop for the number of rotation */ 92 | for (a = 0; a < num - 1; a++){ 93 | /* Second for loop for the number of PASS */ 94 | for (b = 0; b < num - a - 1; b++){ 95 | /* If the next element is greater than the next consecutive element*/ 96 | if (arr[b] > arr[b + 1]){ 97 | temp = arr[b]; 98 | arr[b] = arr[b+1]; 99 | arr[b+1] = temp; 100 | } 101 | } 102 | } 103 | /*Printing all the sorted elements*/ 104 | printf("Sorted array is \n"); 105 | for (a = 0; a < num; a++) 106 | printf("%d\n", arr[a]); 107 | 108 | return 0; 109 | } 110 | 111 | //Beginning 112 | #include 113 | #include 114 | #include 115 | /* Unsorted or linear Search using Intergers 116 | 117 | int main() 118 | { 119 | int arr[] = {4, 2, 5, 9, 6, 13}; 120 | 121 | for (int i = 0; i<5; i++){ 122 | if (arr[i] == 0){ 123 | printf("Found\n"); 124 | } 125 | } 126 | printf("Not found\n"); 127 | }*/ 128 | 129 | int main() 130 | { 131 | char names[] = {"Innocent"}; 132 | for (int i = 0; i<3; i++){ 133 | if (strcmp(&names[i], "George")){ 134 | printf("Found\n"); 135 | } 136 | } 137 | printf("Not found\n"); 138 | } 139 | -------------------------------------------------------------------------------- /Hash_table.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | #define MAX_NAME 256 8 | #define TABLE_SIZE 10 9 | #define DELETED_NODE (person*)(0xFFFFFFFFFFFFFFFUL) 10 | 11 | 12 | // Lesson == Adding Hash Table 13 | typedef struct 14 | { 15 | char name[MAX_NAME]; 16 | int age; 17 | 18 | }person; 19 | 20 | person * hash_table[TABLE_SIZE]; 21 | 22 | /* Lets create an empty table */ 23 | void init_hash_table() 24 | { 25 | for(int i = 0; i < TABLE_SIZE; i++) 26 | hash_table[i] = NULL; 27 | } 28 | unsigned int hash(char *name) 29 | { 30 | int length = strnlen(name, MAX_NAME); 31 | unsigned int hash_value = 0; 32 | for(int i = 0; i < length; i++){ 33 | hash_value += name[i];//check it out 34 | 35 | hash_value = (hash_value * name[i]) % TABLE_SIZE; // TABLE_SIZE is define above @header 36 | } 37 | return hash_value; 38 | } 39 | //Transvering through the Table 40 | /*void print_table() 41 | { 42 | printf("Start\n"); 43 | for(int i = 0; i < TABLE_SIZE; i++) 44 | { 45 | if (hash_table[i] == NULL) 46 | { 47 | printf("\t%d\t---\n", i); 48 | } 49 | else{ 50 | printf("\t%d\t%s\n", i, hash_table[i]->name); 51 | } 52 | } 53 | printf("End\n"); 54 | }*/ 55 | //Updating print function for deletion 56 | void print_table() 57 | { 58 | printf("Start\n"); 59 | for(int i = 0; i < TABLE_SIZE; i++) 60 | { 61 | if (hash_table[i] == NULL) 62 | { 63 | printf("\t%i\t---\n", i); 64 | } 65 | else if (hash_table[i] == DELETED_NODE){ 66 | printf("\t%i\t---\n", i); 67 | } 68 | else{ 69 | printf("\t%i\t%s\n", i, hash_table[i]->name); 70 | } 71 | } 72 | printf("End\n"); 73 | } 74 | //Inserting a person in the table 75 | /*bool hash_table_insert(person *p){ 76 | if (p == NULL) 77 | return false; 78 | int index = hash(p->name); 79 | if(hash_table[index] != NULL){ 80 | return false; 81 | } 82 | hash_table[index] = p; 83 | return true; 84 | }*/ 85 | //Inserting a person in the table and treating Collusion 86 | //Handling Collusion (2 types: 1.Open addressing 2. external Chaining) 87 | bool hash_table_insert(person *p){ 88 | if (p == NULL) 89 | return false; 90 | int index = hash(p->name); 91 | for (int i = 0; i < TABLE_SIZE; i++){ 92 | int try = (i + index) % TABLE_SIZE; 93 | if (hash_table[try] == NULL || hash_table[try] == DELETED_NODE){ 94 | hash_table[try] = p; 95 | return true; 96 | } 97 | } 98 | return false; 99 | } 100 | 101 | //Find a person in the table by their name 102 | /*person *hash_table_lookup(char *name){ 103 | int index = hash(name); 104 | if (hash_table[index] != NULL && 105 | strncmp(hash_table[index]->name, name, TABLE_SIZE) ==0) 106 | { 107 | return hash_table[index]; 108 | } 109 | else{ 110 | return NULL; 111 | } 112 | }*/ 113 | //Managering collosion 114 | /*person *hash_table_lookup(char *name){ 115 | int index = hash(name); 116 | for (int i = 0; i < TABLE_SIZE; i++){ 117 | int try = (i + index) % TABLE_SIZE; 118 | if (hash_table[try] != NULL && 119 | strncmp(hash_table[index]->name, name, TABLE_SIZE) ==0){ 120 | return hash_table[try]; 121 | } 122 | } 123 | return NULL; 124 | }*/ 125 | //Updating Lookup Delete 126 | person *hash_table_lookup(char *name){ 127 | int index = hash(name); 128 | for (int i = 0; i < TABLE_SIZE; i++){ 129 | int try = (i + index) % TABLE_SIZE; 130 | if(hash_table[try] == NULL){ 131 | return false; //not here 132 | } 133 | if (hash_table[try] == DELETED_NODE) continue; 134 | if (strncmp(hash_table[index]->name, name, TABLE_SIZE) ==0){ 135 | return hash_table[try]; 136 | } 137 | } 138 | return NULL; 139 | } 140 | //Deleting a Person Out of the table 141 | /*person *hash_table_delete(char *name){ 142 | int index = hash(name); 143 | if (hash_table[index] != NULL && 144 | strncmp(hash_table[index]->name, name, TABLE_SIZE) ==0) 145 | { 146 | person *tmp = hash_table[index]; 147 | hash_table[index] = NULL; 148 | return hash_table[index]; 149 | } 150 | else{ 151 | return NULL; 152 | } 153 | }*/ 154 | //Deletion using Collision 155 | /*person *hash_table_delete(char *name){ 156 | int index = hash(name); 157 | for (int i = 0; i < TABLE_SIZE; i++){ 158 | int try = (i + index) % TABLE_SIZE; 159 | if (hash_table[try] != NULL && 160 | strncmp(hash_table[index]->name, name, TABLE_SIZE) ==0){ 161 | person* tmp = hash_table[try]; 162 | hash_table[try] = DELETED_NODE; 163 | return tmp; 164 | } 165 | } 166 | return NULL; 167 | }*/ 168 | //Updating Lookup Delete 169 | person *hash_table_delete(char *name){ 170 | int index = hash(name); 171 | for (int i = 0; i < TABLE_SIZE; i++){ 172 | int try = (i + index) % TABLE_SIZE; 173 | if (hash_table[try] == NULL) return NULL; 174 | if (hash_table[try] == DELETED_NODE) continue; 175 | if (strncmp(hash_table[index]->name, name, TABLE_SIZE) ==0){ 176 | person* tmp = hash_table[try]; 177 | hash_table[try] = DELETED_NODE; 178 | return tmp; 179 | } 180 | } 181 | return NULL; 182 | } 183 | 184 | int main() 185 | { 186 | init_hash_table(); 187 | 188 | person Jacob = {.name="Jacob", .age=34}; 189 | person Peter = {.name="Peter", .age=23}; 190 | person Daniel = {.name="Daniel", .age=56}; 191 | person max = {.name="max", .age=25}; 192 | person Gideon = {.name="Gideon", .age=2}; 193 | person Isaac = {.name="Isaac", .age=5}; 194 | person Kelvin = {.name="Kelvin", .age=6}; 195 | person Obed = {.name="Obed", .age=9}; 196 | person Mary = {.name="Mary", .age=67}; 197 | 198 | hash_table_insert(&Jacob); 199 | hash_table_insert(&Peter); 200 | hash_table_insert(&Daniel); 201 | hash_table_insert(&max); 202 | hash_table_insert(&Gideon); 203 | hash_table_insert(&Isaac); 204 | hash_table_insert(&Kelvin); 205 | hash_table_insert(&Obed); 206 | hash_table_insert(&Mary); 207 | 208 | print_table(); 209 | 210 | person *tmp = hash_table_lookup("Innocent"); 211 | if(tmp == NULL){ 212 | printf("Not found!\n"); 213 | } 214 | else{ 215 | printf("Found %s.\n", tmp->name); 216 | } 217 | 218 | tmp = hash_table_lookup("Jacob"); 219 | if(tmp == NULL){ 220 | printf("Not found!\n"); 221 | } 222 | else{ 223 | printf("Found %s.\n", tmp->name); 224 | } 225 | 226 | hash_table_delete("Jacob"); 227 | tmp = hash_table_lookup("Jacob"); 228 | if(tmp == NULL){ 229 | printf("Not found!\n"); 230 | } 231 | else{ 232 | printf("Found %s.\n", tmp->name); 233 | } 234 | 235 | 236 | return 0; 237 | } 238 | 239 | //Lesson 1 == Intro 240 | /*typedef struct 241 | { 242 | char name[MAX_NAME]; 243 | int age; 244 | 245 | }person; 246 | 247 | unsigned int hash(char *name) 248 | { 249 | int length = strnlen(name, MAX_NAME); 250 | unsigned int hash_value = 0; 251 | for(int i = 0; i < length; i++){ 252 | hash_value += name[i];//check it out 253 | 254 | hash_value = (hash_value * name[i]) % TABLE_SIZE; // TABLE_SIZE is define above @header 255 | } 256 | return hash_value; 257 | } 258 | 259 | int main() 260 | { 261 | printf("Jacob => %u\n", hash("Jacob")); 262 | printf("Dan => %u\n", hash("Daniel")); 263 | printf("Moses => %u\n", hash("Moses")); 264 | printf("Peter => %u\n", hash("Peter")); 265 | printf("Innocent => %u\n", hash("Innocent")); 266 | return 0; 267 | }* 268 | --------------------------------------------------------------------------------