├── 0x13-more_singly_linked_lists ├── cc.cc ├── a ├── b ├── c ├── d ├── e ├── f ├── g ├── h ├── i ├── j ├── k ├── l ├── m ├── n ├── o ├── .vscode │ └── settings.json ├── _putchar.c ├── 8-sum_listint.c ├── 1-listint_len.c ├── 2-main.c ├── 3-main.c ├── 0-print_listint.c ├── 1-main.c ├── 4-main.c ├── 0-main.c ├── 5-main.c ├── 8-main.c ├── 100-main.c ├── 5-free_listint2.c ├── 4-free_listint.c ├── 9-main.c ├── 7-main.c └── 7-get_nodeint.c ├── 0x14-bit_manipulation ├── 101-password ├── a ├── b ├── c ├── d ├── e ├── f ├── h ├── crackme3 ├── 100-main.c ├── _putchar.c ├── 2-main.c ├── 3-main.c ├── 4-main.c ├── 1-main.c ├── 5-main.c ├── 100-get_endianness.c ├── 0-main.c ├── main.h ├── 1-print_binary.c ├── 2-get_bit.c ├── 3-set_bit.c └── 4-clear_bit.c ├── 0x15-file_io ├── hello ├── a ├── b ├── c ├── cp ├── .vscode │ ├── settings.json │ └── c_cpp_properties.json ├── incitatous ├── _putchar.c ├── 1-main.c ├── 2-main.c ├── 0-main.c ├── main.h └── Requiescat ├── 0x1E-search_algorithms ├── 2-O ├── 3-O ├── 5-O ├── 6-O ├── 4-O ├── 0-linear ├── 1-binary ├── search_algos.h ├── 1-main.c └── 0-main.c ├── 0x09-static_libraries ├── .gitignore ├── a.out ├── quote ├── libmy.a ├── liball.a └── create_static_lib.sh ├── 0x17-doubly_linked_lists ├── 102-result ├── a ├── b ├── c ├── d ├── e ├── h ├── i ├── j ├── k ├── 1-dlistint_len.c ├── 0-print_dlistint.c ├── 4-free_dlistint.c ├── 6-sum_dlistint.c ├── 2-main.c ├── 3-main.c ├── 4-main.c ├── 6-main.c ├── 1-main.c ├── 0-main.c ├── 5-main.c └── 7-main.c ├── 0x18-dynamic_libraries ├── .gitignore ├── 1-create_dynamic_lib.sh ├── len ├── liball.so ├── libdynamic.so ├── 100-operations.so └── 100-tests.py ├── 0x07-pointers_arrays_strings ├── 101-crackme_password ├── .vscode │ └── settings.json ├── 0-memset ├── 1-memcpy ├── 2-strchr ├── 3-strspn ├── 5-strstr ├── crackme2 ├── 4-strpbrk ├── 100-set_string ├── 7-print_chessboard ├── 8-print_diagsums ├── _putchar.c ├── 4-main.c ├── 3-main.c ├── 2-main.c ├── 5-main.c ├── 100-main.c ├── 100-set_string.c ├── 7-print_chessboard.c ├── 0-memset.c ├── 1-memcpy.c ├── main.h ├── 8-main.c ├── 7-main.c ├── 2-strchr.c ├── 8-print_diagsums.c └── 5-strstr.c ├── 0x00-hello_world ├── 0-preprocessor ├── 3-name ├── q ├── 1-compiler ├── 2-assembler ├── 100-intel ├── a.out ├── quote ├── size32 ├── size64 ├── 4-puts.c ├── 5-printf.c ├── 101-quote.c └── 6-size.c ├── 0x1C-makefiles ├── 0-Makefile ├── 1-Makefile ├── main.o ├── school ├── school.o ├── 2-Makefile ├── m.h ├── main.c ├── 3-Makefile ├── 4-Makefile ├── 5-main.py ├── 100-Makefile └── 5-island_perimeter.py ├── 0x08-recursion ├── .vscode │ ├── settings.json │ └── c_cpp_properties.json ├── 4-pow ├── 5-sqrt ├── 6-prime ├── 101-wildcmp ├── 3-factorial ├── 100-palindrome ├── 0-puts_recursion ├── 2-strlen_recursion ├── 1-print_rev_recursion ├── 0-main.c ├── 1-main.c ├── 2-main.c ├── _putchar.c ├── 1-print_rev_recursion.c ├── 2-strlen_recursion.c ├── 3-main.c ├── 0-puts_recursion.c ├── 3-factorial.c ├── 100-main.c ├── 4-pow_recursion.c ├── main.h ├── 5-main.c ├── 4-main.c └── 6-main.c ├── 0x0A-argc_argv ├── .vscode │ └── settings.json ├── add ├── args ├── mul ├── change ├── nargs ├── mynewnameis ├── main.h ├── _putchar.c ├── 2-args.c ├── 1-args.c ├── 0-whatsmyname.c └── 3-mul.c ├── 0x0B-malloc_free ├── .vscode │ └── settings.json ├── a ├── c ├── f ├── g ├── s ├── args ├── strtow ├── _putchar.c ├── 100-main.c ├── 2-main.c ├── 1-main.c ├── main.h ├── 4-free_grid.c ├── 0-create_array.c └── 101-main.c ├── 0x0D-preprocessor ├── a ├── b ├── c ├── d ├── e ├── cc ├── 1-pi.h ├── 4-sum.h ├── 0-object_like_macro.h ├── 3-function_like_macro.h ├── 02-main.c ├── 2-main.c ├── 4-main.c ├── 0-main.c ├── 1-main.c └── 3-main.c ├── 0x1A-hash_tables ├── a ├── b ├── c ├── d ├── e ├── f ├── g ├── sht ├── 0-main.c ├── 3-main.c ├── 1-djb2.c ├── 1-main.c ├── 2-key_index.c ├── 0-hash_table_create.c ├── 5-main.c ├── 5-hash_table_print.c └── 6-hash_table_delete.c ├── 0x03-debugging ├── 1-main ├── 2-main ├── 3-main_a ├── 3-main_b ├── 0-main.c ├── main.h ├── 1-main.c ├── 2-main.c ├── 3-main_a.c ├── 3-main_b.c └── 2-largest_number.c ├── 0x0C-more_malloc_free ├── a ├── 101-mul ├── 2-calloc ├── 100-realloc ├── 3-array_range ├── 1-string_nconcat ├── _putchar.c ├── 1-main.c ├── main.h ├── 0-malloc_checked.c └── 0-main.c ├── 0x0F-function_pointers ├── .vscode │ └── settings.json ├── a ├── b ├── c ├── calc ├── _putchar.c ├── 0-print_name.c ├── function_pointers.h ├── 3-calc.h ├── 1-array_iterator.c └── 2-int_index.c ├── .vscode └── settings.json ├── 0x06-pointers_arrays_strings ├── .vscode │ └── settings.json ├── 6-cap ├── 0-strcat ├── 103-add ├── 3-strcmp ├── 7-1337 ├── 1-strncat ├── 100-rot13 ├── 104-buffer ├── 2-strncpy ├── 4-rev_array ├── 101-print_numbers ├── 5-string_toupper ├── _putchar.c ├── 5-main.c ├── 3-main.c ├── 7-main.c ├── 3-strcmp.c ├── 101-main.c ├── 0-strcat.c ├── 0-main.c ├── 6-main.c ├── 2-strncpy.c ├── 1-strncat.c ├── 104-main.c ├── 4-rev_array.c ├── 1-main.c ├── 102-magic.c ├── cccc.c ├── 5-string_toupper.c ├── 101-print_number.c ├── main.h └── 6-cap_string.c ├── 0x0E-structures_typedef ├── a ├── b ├── c ├── d ├── e ├── f ├── 2-main.c ├── 4-main.c ├── 1-main.c ├── 5-free_dog.c ├── 5-main.c ├── 3-main.c ├── 0-main.c ├── 1-init_dog.c └── dog.h ├── 0x10-variadic_functions ├── a ├── b ├── c ├── d ├── 2-main.c ├── 3-main.c ├── 1-main.c ├── _putchar.c ├── 0-main.c ├── variadic_functions.h └── 0-sum_them_all.c ├── 0x12-singly_linked_lists ├── a ├── b ├── c ├── d ├── first ├── hello ├── .vscode │ └── settings.json ├── 101-hello_holberton.o ├── 100-main.c ├── 100-first.c ├── 1-list_len.c ├── 4-main.c ├── 1-main.c └── lists.h ├── 0x02-functions_nested_loops ├── 101 ├── 102 ├── 103 ├── 104 ├── 8-24 ├── 10-add ├── 6-abs ├── a.out ├── 0-putchar ├── 3-islower ├── 4-isalpha ├── .vscode │ └── settings.json ├── 1-alphabet ├── 2-alphabet_x10 ├── 7-last_digit ├── 9-times_table ├── 100-times_table ├── 8-main.c ├── 9-main.c ├── 1-main.c ├── 2-main.c ├── 11-main.c ├── 10-main.c ├── 6-abs.c ├── 10-add.c ├── _putchar.c ├── 7-main.c ├── 100-main.c ├── 3-main.c ├── 0-putchar.c ├── 0-putchar2.c ├── 6-main.c ├── main.h ├── 4-main.c ├── 3-islower.c ├── 4-isalpha.c ├── 7-print_last_digit.c ├── 1-alphabet.c ├── 101-natural.c ├── 2-print_alphabet_x10.c ├── 8-24_hours.c ├── 103-fibonacci.c ├── 5-sign.c ├── 5-main.c └── 102-fibonacci.c ├── 0x05-pointers_arrays_strings ├── 0-98 ├── 1-swap ├── 100-atoi ├── 2-strlen ├── 3-puts ├── 6-puts2 ├── 9-strcpy ├── 101-keygen ├── 101-crackme ├── 4-print_rev ├── 5-rev_string ├── 7-puts_half ├── 8-print_array ├── .vscode │ └── settings.json ├── 6-main.c ├── 7-main.c ├── 3-main.c ├── 4-main.c ├── 0-main.c ├── 5-main.c ├── 1-swap.c ├── 0-reset_to_98.c ├── 2-main.c ├── _putchar.c ├── 8-main.c ├── 1-main.c ├── 9-main.c ├── string_length.c ├── 3-puts.c ├── main.h ├── 2-strlen.c ├── 4-print_rev.c ├── 9-strcpy.c ├── 7-puts_half.c └── 8-print_array.c ├── 0x04-more_functions_nested_loops ├── 2-mul ├── 0-isuper ├── 1-isdigit ├── 6-lines ├── 8-squares ├── 7-diagonals ├── 9-fizz_buzz ├── 10-triangles ├── 5-more_numbers ├── 100-prime_factor ├── 3-print_numbers ├── 101-print_numbers ├── 4-print_most_numbers ├── 3-main.c ├── 5-main.c ├── 4-main.c ├── 8-main.c ├── 6-main.c ├── 10-main.c ├── 2-main.c ├── 7-main.c ├── 2-mul.c ├── 0-isupper.c ├── 1-isdigit.c ├── _putchar.c ├── 1-main.c ├── 0-main.c ├── main.h ├── 101-main.c ├── 3-print_numbers.c ├── 4-print_most_numbers.c ├── 5-more_numbers.c ├── 6-print_line.c ├── 101-print_number.c ├── 100-prime_factor.c ├── 8-print_square.c ├── 9-fizz_buzz.c └── 7-print_diagonal.c ├── 0x01-variables_if_else_while ├── 9-print_comb ├── 100-print_comb3 ├── 101-print_comb4 ├── 102-print_comb5 ├── 5-print_numbers ├── 6-print_numberz ├── 8-print_base16 ├── 7-print_tebahpla ├── 5-print_numbers.c ├── 2-print_alphabet.c ├── 7-print_tebahpla.c ├── 6-print_numberz.c ├── 8-print_base16.c ├── 4-print_alphabt.c └── 3-print_alphabets.c └── .gitignore /0x13-more_singly_linked_lists/cc.cc: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /0x14-bit_manipulation/101-password: -------------------------------------------------------------------------------- 1 | Hol -------------------------------------------------------------------------------- /0x15-file_io/hello: -------------------------------------------------------------------------------- 1 | Hello World! 2 | -------------------------------------------------------------------------------- /0x1E-search_algorithms/2-O: -------------------------------------------------------------------------------- 1 | O(n) 2 | -------------------------------------------------------------------------------- /0x1E-search_algorithms/3-O: -------------------------------------------------------------------------------- 1 | O(1) 2 | -------------------------------------------------------------------------------- /0x1E-search_algorithms/5-O: -------------------------------------------------------------------------------- 1 | O(1) 2 | -------------------------------------------------------------------------------- /0x1E-search_algorithms/6-O: -------------------------------------------------------------------------------- 1 | O(nm) 2 | -------------------------------------------------------------------------------- /0x09-static_libraries/.gitignore: -------------------------------------------------------------------------------- 1 | *.c 2 | *.o -------------------------------------------------------------------------------- /0x17-doubly_linked_lists/102-result: -------------------------------------------------------------------------------- 1 | 906609 -------------------------------------------------------------------------------- /0x1E-search_algorithms/4-O: -------------------------------------------------------------------------------- 1 | O(log(n)) 2 | -------------------------------------------------------------------------------- /0x18-dynamic_libraries/.gitignore: -------------------------------------------------------------------------------- 1 | *.c 2 | *.o -------------------------------------------------------------------------------- /0x07-pointers_arrays_strings/101-crackme_password: -------------------------------------------------------------------------------- 1 | abc123 -------------------------------------------------------------------------------- /0x00-hello_world/0-preprocessor: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | gcc -E $CFILE >c 3 | -------------------------------------------------------------------------------- /0x00-hello_world/3-name: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | gcc -o $CFILE > cisfun 3 | -------------------------------------------------------------------------------- /0x00-hello_world/q: -------------------------------------------------------------------------------- 1 | and that piece of art is useful" - Dora Korpar, 2015-10-19 2 | -------------------------------------------------------------------------------- /0x00-hello_world/1-compiler: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | gcc -c $CFILE > $( echo $CFILE | cut -d "." -f1).o 3 | -------------------------------------------------------------------------------- /0x1C-makefiles/0-Makefile: -------------------------------------------------------------------------------- 1 | all: school 2 | school: school.o 3 | gcc main.c school.c -o school 4 | -------------------------------------------------------------------------------- /0x00-hello_world/2-assembler: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | gcc -S $CFILE > $( echo $CFILE | cut -d "." -f1).s 3 | -------------------------------------------------------------------------------- /0x15-file_io/a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x15-file_io/a -------------------------------------------------------------------------------- /0x15-file_io/b: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x15-file_io/b -------------------------------------------------------------------------------- /0x15-file_io/c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x15-file_io/c -------------------------------------------------------------------------------- /0x1C-makefiles/1-Makefile: -------------------------------------------------------------------------------- 1 | CC=gcc 2 | SRC=main.c school.c 3 | 4 | all: 5 | $(CC) $(SRC) -o school 6 | -------------------------------------------------------------------------------- /0x15-file_io/cp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x15-file_io/cp -------------------------------------------------------------------------------- /0x00-hello_world/100-intel: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | gcc -S -masm=intel $CFILE > $( echo $CFILE | cut -d "." -f1).s 3 | -------------------------------------------------------------------------------- /0x08-recursion/.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "files.associations": { 3 | "main.h": "c" 4 | } 5 | } -------------------------------------------------------------------------------- /0x0A-argc_argv/.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "files.associations": { 3 | "main.h": "c" 4 | } 5 | } -------------------------------------------------------------------------------- /0x0A-argc_argv/add: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x0A-argc_argv/add -------------------------------------------------------------------------------- /0x0A-argc_argv/args: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x0A-argc_argv/args -------------------------------------------------------------------------------- /0x0A-argc_argv/mul: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x0A-argc_argv/mul -------------------------------------------------------------------------------- /0x0B-malloc_free/.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "files.associations": { 3 | "main.h": "c" 4 | } 5 | } -------------------------------------------------------------------------------- /0x0B-malloc_free/a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x0B-malloc_free/a -------------------------------------------------------------------------------- /0x0B-malloc_free/c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x0B-malloc_free/c -------------------------------------------------------------------------------- /0x0B-malloc_free/f: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x0B-malloc_free/f -------------------------------------------------------------------------------- /0x0B-malloc_free/g: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x0B-malloc_free/g -------------------------------------------------------------------------------- /0x0B-malloc_free/s: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x0B-malloc_free/s -------------------------------------------------------------------------------- /0x0D-preprocessor/a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x0D-preprocessor/a -------------------------------------------------------------------------------- /0x0D-preprocessor/b: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x0D-preprocessor/b -------------------------------------------------------------------------------- /0x0D-preprocessor/c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x0D-preprocessor/c -------------------------------------------------------------------------------- /0x0D-preprocessor/d: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x0D-preprocessor/d -------------------------------------------------------------------------------- /0x0D-preprocessor/e: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x0D-preprocessor/e -------------------------------------------------------------------------------- /0x15-file_io/.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "files.associations": { 3 | "stdio.h": "c" 4 | } 5 | } -------------------------------------------------------------------------------- /0x1A-hash_tables/a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x1A-hash_tables/a -------------------------------------------------------------------------------- /0x1A-hash_tables/b: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x1A-hash_tables/b -------------------------------------------------------------------------------- /0x1A-hash_tables/c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x1A-hash_tables/c -------------------------------------------------------------------------------- /0x1A-hash_tables/d: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x1A-hash_tables/d -------------------------------------------------------------------------------- /0x1A-hash_tables/e: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x1A-hash_tables/e -------------------------------------------------------------------------------- /0x1A-hash_tables/f: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x1A-hash_tables/f -------------------------------------------------------------------------------- /0x1A-hash_tables/g: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x1A-hash_tables/g -------------------------------------------------------------------------------- /0x00-hello_world/a.out: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x00-hello_world/a.out -------------------------------------------------------------------------------- /0x00-hello_world/quote: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x00-hello_world/quote -------------------------------------------------------------------------------- /0x03-debugging/1-main: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x03-debugging/1-main -------------------------------------------------------------------------------- /0x03-debugging/2-main: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x03-debugging/2-main -------------------------------------------------------------------------------- /0x08-recursion/4-pow: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x08-recursion/4-pow -------------------------------------------------------------------------------- /0x08-recursion/5-sqrt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x08-recursion/5-sqrt -------------------------------------------------------------------------------- /0x08-recursion/6-prime: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x08-recursion/6-prime -------------------------------------------------------------------------------- /0x0A-argc_argv/change: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x0A-argc_argv/change -------------------------------------------------------------------------------- /0x0A-argc_argv/nargs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x0A-argc_argv/nargs -------------------------------------------------------------------------------- /0x0B-malloc_free/args: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x0B-malloc_free/args -------------------------------------------------------------------------------- /0x0D-preprocessor/cc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x0D-preprocessor/cc -------------------------------------------------------------------------------- /0x1A-hash_tables/sht: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x1A-hash_tables/sht -------------------------------------------------------------------------------- /0x1C-makefiles/main.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x1C-makefiles/main.o -------------------------------------------------------------------------------- /0x1C-makefiles/school: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x1C-makefiles/school -------------------------------------------------------------------------------- /0x00-hello_world/size32: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x00-hello_world/size32 -------------------------------------------------------------------------------- /0x00-hello_world/size64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x00-hello_world/size64 -------------------------------------------------------------------------------- /0x03-debugging/3-main_a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x03-debugging/3-main_a -------------------------------------------------------------------------------- /0x03-debugging/3-main_b: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x03-debugging/3-main_b -------------------------------------------------------------------------------- /0x0B-malloc_free/strtow: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x0B-malloc_free/strtow -------------------------------------------------------------------------------- /0x0C-more_malloc_free/a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x0C-more_malloc_free/a -------------------------------------------------------------------------------- /0x0F-function_pointers/.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "files.associations": { 3 | "stdio.h": "c" 4 | } 5 | } -------------------------------------------------------------------------------- /0x0F-function_pointers/a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x0F-function_pointers/a -------------------------------------------------------------------------------- /0x0F-function_pointers/b: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x0F-function_pointers/b -------------------------------------------------------------------------------- /0x0F-function_pointers/c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x0F-function_pointers/c -------------------------------------------------------------------------------- /0x14-bit_manipulation/a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x14-bit_manipulation/a -------------------------------------------------------------------------------- /0x14-bit_manipulation/b: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x14-bit_manipulation/b -------------------------------------------------------------------------------- /0x14-bit_manipulation/c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x14-bit_manipulation/c -------------------------------------------------------------------------------- /0x14-bit_manipulation/d: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x14-bit_manipulation/d -------------------------------------------------------------------------------- /0x14-bit_manipulation/e: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x14-bit_manipulation/e -------------------------------------------------------------------------------- /0x14-bit_manipulation/f: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x14-bit_manipulation/f -------------------------------------------------------------------------------- /0x14-bit_manipulation/h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x14-bit_manipulation/h -------------------------------------------------------------------------------- /0x18-dynamic_libraries/1-create_dynamic_lib.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | gcc -Wall -fPIC -c *.c 3 | gcc -shared -o liball.so *.o 4 | -------------------------------------------------------------------------------- /0x1C-makefiles/school.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x1C-makefiles/school.o -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "files.associations": { 3 | "stdlib.h": "c", 4 | "main.h": "c" 5 | } 6 | } -------------------------------------------------------------------------------- /0x06-pointers_arrays_strings/.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "files.associations": { 3 | "stdio.h": "c" 4 | } 5 | } -------------------------------------------------------------------------------- /0x07-pointers_arrays_strings/.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "files.associations": { 3 | "stdio.h": "c" 4 | } 5 | } -------------------------------------------------------------------------------- /0x08-recursion/101-wildcmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x08-recursion/101-wildcmp -------------------------------------------------------------------------------- /0x08-recursion/3-factorial: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x08-recursion/3-factorial -------------------------------------------------------------------------------- /0x09-static_libraries/a.out: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x09-static_libraries/a.out -------------------------------------------------------------------------------- /0x09-static_libraries/quote: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x09-static_libraries/quote -------------------------------------------------------------------------------- /0x0A-argc_argv/mynewnameis: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x0A-argc_argv/mynewnameis -------------------------------------------------------------------------------- /0x0D-preprocessor/1-pi.h: -------------------------------------------------------------------------------- 1 | #ifndef _PI_H_ 2 | #define _PI_H_ 3 | 4 | #define PI 3.14159265359 5 | 6 | #endif /* _PI_H_ */ 7 | -------------------------------------------------------------------------------- /0x0E-structures_typedef/a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x0E-structures_typedef/a -------------------------------------------------------------------------------- /0x0E-structures_typedef/b: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x0E-structures_typedef/b -------------------------------------------------------------------------------- /0x0E-structures_typedef/c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x0E-structures_typedef/c -------------------------------------------------------------------------------- /0x0E-structures_typedef/d: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x0E-structures_typedef/d -------------------------------------------------------------------------------- /0x0E-structures_typedef/e: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x0E-structures_typedef/e -------------------------------------------------------------------------------- /0x0E-structures_typedef/f: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x0E-structures_typedef/f -------------------------------------------------------------------------------- /0x0F-function_pointers/calc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x0F-function_pointers/calc -------------------------------------------------------------------------------- /0x10-variadic_functions/a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x10-variadic_functions/a -------------------------------------------------------------------------------- /0x10-variadic_functions/b: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x10-variadic_functions/b -------------------------------------------------------------------------------- /0x10-variadic_functions/c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x10-variadic_functions/c -------------------------------------------------------------------------------- /0x10-variadic_functions/d: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x10-variadic_functions/d -------------------------------------------------------------------------------- /0x12-singly_linked_lists/a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x12-singly_linked_lists/a -------------------------------------------------------------------------------- /0x12-singly_linked_lists/b: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x12-singly_linked_lists/b -------------------------------------------------------------------------------- /0x12-singly_linked_lists/c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x12-singly_linked_lists/c -------------------------------------------------------------------------------- /0x12-singly_linked_lists/d: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x12-singly_linked_lists/d -------------------------------------------------------------------------------- /0x17-doubly_linked_lists/a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x17-doubly_linked_lists/a -------------------------------------------------------------------------------- /0x17-doubly_linked_lists/b: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x17-doubly_linked_lists/b -------------------------------------------------------------------------------- /0x17-doubly_linked_lists/c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x17-doubly_linked_lists/c -------------------------------------------------------------------------------- /0x17-doubly_linked_lists/d: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x17-doubly_linked_lists/d -------------------------------------------------------------------------------- /0x17-doubly_linked_lists/e: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x17-doubly_linked_lists/e -------------------------------------------------------------------------------- /0x17-doubly_linked_lists/h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x17-doubly_linked_lists/h -------------------------------------------------------------------------------- /0x17-doubly_linked_lists/i: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x17-doubly_linked_lists/i -------------------------------------------------------------------------------- /0x17-doubly_linked_lists/j: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x17-doubly_linked_lists/j -------------------------------------------------------------------------------- /0x17-doubly_linked_lists/k: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x17-doubly_linked_lists/k -------------------------------------------------------------------------------- /0x18-dynamic_libraries/len: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x18-dynamic_libraries/len -------------------------------------------------------------------------------- /0x08-recursion/100-palindrome: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x08-recursion/100-palindrome -------------------------------------------------------------------------------- /0x09-static_libraries/libmy.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x09-static_libraries/libmy.a -------------------------------------------------------------------------------- /0x0C-more_malloc_free/101-mul: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x0C-more_malloc_free/101-mul -------------------------------------------------------------------------------- /0x02-functions_nested_loops/101: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x02-functions_nested_loops/101 -------------------------------------------------------------------------------- /0x02-functions_nested_loops/102: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x02-functions_nested_loops/102 -------------------------------------------------------------------------------- /0x02-functions_nested_loops/103: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x02-functions_nested_loops/103 -------------------------------------------------------------------------------- /0x02-functions_nested_loops/104: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x02-functions_nested_loops/104 -------------------------------------------------------------------------------- /0x02-functions_nested_loops/8-24: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x02-functions_nested_loops/8-24 -------------------------------------------------------------------------------- /0x08-recursion/0-puts_recursion: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x08-recursion/0-puts_recursion -------------------------------------------------------------------------------- /0x09-static_libraries/liball.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x09-static_libraries/liball.a -------------------------------------------------------------------------------- /0x0C-more_malloc_free/2-calloc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x0C-more_malloc_free/2-calloc -------------------------------------------------------------------------------- /0x0D-preprocessor/4-sum.h: -------------------------------------------------------------------------------- 1 | #ifndef _SUM_H_ 2 | #define _SUM_H_ 3 | 4 | #define SUM(x, y) ((x) + (y)) 5 | 6 | #endif /* _SUM_H_ */ 7 | -------------------------------------------------------------------------------- /0x12-singly_linked_lists/first: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x12-singly_linked_lists/first -------------------------------------------------------------------------------- /0x12-singly_linked_lists/hello: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x12-singly_linked_lists/hello -------------------------------------------------------------------------------- /0x13-more_singly_linked_lists/a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x13-more_singly_linked_lists/a -------------------------------------------------------------------------------- /0x13-more_singly_linked_lists/b: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x13-more_singly_linked_lists/b -------------------------------------------------------------------------------- /0x13-more_singly_linked_lists/c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x13-more_singly_linked_lists/c -------------------------------------------------------------------------------- /0x13-more_singly_linked_lists/d: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x13-more_singly_linked_lists/d -------------------------------------------------------------------------------- /0x13-more_singly_linked_lists/e: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x13-more_singly_linked_lists/e -------------------------------------------------------------------------------- /0x13-more_singly_linked_lists/f: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x13-more_singly_linked_lists/f -------------------------------------------------------------------------------- /0x13-more_singly_linked_lists/g: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x13-more_singly_linked_lists/g -------------------------------------------------------------------------------- /0x13-more_singly_linked_lists/h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x13-more_singly_linked_lists/h -------------------------------------------------------------------------------- /0x13-more_singly_linked_lists/i: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x13-more_singly_linked_lists/i -------------------------------------------------------------------------------- /0x13-more_singly_linked_lists/j: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x13-more_singly_linked_lists/j -------------------------------------------------------------------------------- /0x13-more_singly_linked_lists/k: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x13-more_singly_linked_lists/k -------------------------------------------------------------------------------- /0x13-more_singly_linked_lists/l: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x13-more_singly_linked_lists/l -------------------------------------------------------------------------------- /0x13-more_singly_linked_lists/m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x13-more_singly_linked_lists/m -------------------------------------------------------------------------------- /0x13-more_singly_linked_lists/n: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x13-more_singly_linked_lists/n -------------------------------------------------------------------------------- /0x13-more_singly_linked_lists/o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x13-more_singly_linked_lists/o -------------------------------------------------------------------------------- /0x14-bit_manipulation/crackme3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x14-bit_manipulation/crackme3 -------------------------------------------------------------------------------- /0x18-dynamic_libraries/liball.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x18-dynamic_libraries/liball.so -------------------------------------------------------------------------------- /0x1E-search_algorithms/0-linear: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x1E-search_algorithms/0-linear -------------------------------------------------------------------------------- /0x1E-search_algorithms/1-binary: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x1E-search_algorithms/1-binary -------------------------------------------------------------------------------- /0x02-functions_nested_loops/10-add: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x02-functions_nested_loops/10-add -------------------------------------------------------------------------------- /0x02-functions_nested_loops/6-abs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x02-functions_nested_loops/6-abs -------------------------------------------------------------------------------- /0x02-functions_nested_loops/a.out: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x02-functions_nested_loops/a.out -------------------------------------------------------------------------------- /0x05-pointers_arrays_strings/0-98: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x05-pointers_arrays_strings/0-98 -------------------------------------------------------------------------------- /0x06-pointers_arrays_strings/6-cap: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x06-pointers_arrays_strings/6-cap -------------------------------------------------------------------------------- /0x08-recursion/2-strlen_recursion: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x08-recursion/2-strlen_recursion -------------------------------------------------------------------------------- /0x0C-more_malloc_free/100-realloc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x0C-more_malloc_free/100-realloc -------------------------------------------------------------------------------- /0x02-functions_nested_loops/0-putchar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x02-functions_nested_loops/0-putchar -------------------------------------------------------------------------------- /0x02-functions_nested_loops/3-islower: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x02-functions_nested_loops/3-islower -------------------------------------------------------------------------------- /0x02-functions_nested_loops/4-isalpha: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x02-functions_nested_loops/4-isalpha -------------------------------------------------------------------------------- /0x05-pointers_arrays_strings/1-swap: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x05-pointers_arrays_strings/1-swap -------------------------------------------------------------------------------- /0x05-pointers_arrays_strings/100-atoi: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x05-pointers_arrays_strings/100-atoi -------------------------------------------------------------------------------- /0x05-pointers_arrays_strings/2-strlen: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x05-pointers_arrays_strings/2-strlen -------------------------------------------------------------------------------- /0x05-pointers_arrays_strings/3-puts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x05-pointers_arrays_strings/3-puts -------------------------------------------------------------------------------- /0x05-pointers_arrays_strings/6-puts2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x05-pointers_arrays_strings/6-puts2 -------------------------------------------------------------------------------- /0x05-pointers_arrays_strings/9-strcpy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x05-pointers_arrays_strings/9-strcpy -------------------------------------------------------------------------------- /0x06-pointers_arrays_strings/0-strcat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x06-pointers_arrays_strings/0-strcat -------------------------------------------------------------------------------- /0x06-pointers_arrays_strings/103-add: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x06-pointers_arrays_strings/103-add -------------------------------------------------------------------------------- /0x06-pointers_arrays_strings/3-strcmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x06-pointers_arrays_strings/3-strcmp -------------------------------------------------------------------------------- /0x06-pointers_arrays_strings/7-1337: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x06-pointers_arrays_strings/7-1337 -------------------------------------------------------------------------------- /0x07-pointers_arrays_strings/0-memset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x07-pointers_arrays_strings/0-memset -------------------------------------------------------------------------------- /0x07-pointers_arrays_strings/1-memcpy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x07-pointers_arrays_strings/1-memcpy -------------------------------------------------------------------------------- /0x07-pointers_arrays_strings/2-strchr: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x07-pointers_arrays_strings/2-strchr -------------------------------------------------------------------------------- /0x07-pointers_arrays_strings/3-strspn: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x07-pointers_arrays_strings/3-strspn -------------------------------------------------------------------------------- /0x07-pointers_arrays_strings/5-strstr: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x07-pointers_arrays_strings/5-strstr -------------------------------------------------------------------------------- /0x07-pointers_arrays_strings/crackme2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x07-pointers_arrays_strings/crackme2 -------------------------------------------------------------------------------- /0x08-recursion/1-print_rev_recursion: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x08-recursion/1-print_rev_recursion -------------------------------------------------------------------------------- /0x0C-more_malloc_free/3-array_range: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x0C-more_malloc_free/3-array_range -------------------------------------------------------------------------------- /0x18-dynamic_libraries/libdynamic.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x18-dynamic_libraries/libdynamic.so -------------------------------------------------------------------------------- /0x02-functions_nested_loops/.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "files.associations": { 3 | "main.h": "c", 4 | "stdio.h": "c" 5 | } 6 | } -------------------------------------------------------------------------------- /0x02-functions_nested_loops/1-alphabet: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x02-functions_nested_loops/1-alphabet -------------------------------------------------------------------------------- /0x04-more_functions_nested_loops/2-mul: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x04-more_functions_nested_loops/2-mul -------------------------------------------------------------------------------- /0x05-pointers_arrays_strings/101-keygen: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x05-pointers_arrays_strings/101-keygen -------------------------------------------------------------------------------- /0x06-pointers_arrays_strings/1-strncat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x06-pointers_arrays_strings/1-strncat -------------------------------------------------------------------------------- /0x06-pointers_arrays_strings/100-rot13: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x06-pointers_arrays_strings/100-rot13 -------------------------------------------------------------------------------- /0x06-pointers_arrays_strings/104-buffer: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x06-pointers_arrays_strings/104-buffer -------------------------------------------------------------------------------- /0x06-pointers_arrays_strings/2-strncpy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x06-pointers_arrays_strings/2-strncpy -------------------------------------------------------------------------------- /0x07-pointers_arrays_strings/4-strpbrk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x07-pointers_arrays_strings/4-strpbrk -------------------------------------------------------------------------------- /0x09-static_libraries/create_static_lib.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | gcc -Wall -pedantic -Werror -Wextra -c *.c 3 | ar -rc liball.a *.o 4 | ranlib liball.a 5 | -------------------------------------------------------------------------------- /0x0C-more_malloc_free/1-string_nconcat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x0C-more_malloc_free/1-string_nconcat -------------------------------------------------------------------------------- /0x12-singly_linked_lists/.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "files.associations": { 3 | "lists.h": "c", 4 | "stdio.h": "c" 5 | } 6 | } -------------------------------------------------------------------------------- /0x1C-makefiles/2-Makefile: -------------------------------------------------------------------------------- 1 | CC=gcc 2 | SRC= main.c school.c 3 | OBJ=$(SRC:.c=.o) 4 | NAME=school 5 | 6 | all : $(OBJ) 7 | $(CC) $(SRC) -o $(NAME) 8 | -------------------------------------------------------------------------------- /0x01-variables_if_else_while/9-print_comb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x01-variables_if_else_while/9-print_comb -------------------------------------------------------------------------------- /0x02-functions_nested_loops/2-alphabet_x10: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x02-functions_nested_loops/2-alphabet_x10 -------------------------------------------------------------------------------- /0x02-functions_nested_loops/7-last_digit: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x02-functions_nested_loops/7-last_digit -------------------------------------------------------------------------------- /0x02-functions_nested_loops/9-times_table: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x02-functions_nested_loops/9-times_table -------------------------------------------------------------------------------- /0x04-more_functions_nested_loops/0-isuper: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x04-more_functions_nested_loops/0-isuper -------------------------------------------------------------------------------- /0x04-more_functions_nested_loops/1-isdigit: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x04-more_functions_nested_loops/1-isdigit -------------------------------------------------------------------------------- /0x04-more_functions_nested_loops/6-lines: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x04-more_functions_nested_loops/6-lines -------------------------------------------------------------------------------- /0x04-more_functions_nested_loops/8-squares: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x04-more_functions_nested_loops/8-squares -------------------------------------------------------------------------------- /0x05-pointers_arrays_strings/101-crackme: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x05-pointers_arrays_strings/101-crackme -------------------------------------------------------------------------------- /0x05-pointers_arrays_strings/4-print_rev: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x05-pointers_arrays_strings/4-print_rev -------------------------------------------------------------------------------- /0x05-pointers_arrays_strings/5-rev_string: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x05-pointers_arrays_strings/5-rev_string -------------------------------------------------------------------------------- /0x05-pointers_arrays_strings/7-puts_half: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x05-pointers_arrays_strings/7-puts_half -------------------------------------------------------------------------------- /0x05-pointers_arrays_strings/8-print_array: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x05-pointers_arrays_strings/8-print_array -------------------------------------------------------------------------------- /0x06-pointers_arrays_strings/4-rev_array: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x06-pointers_arrays_strings/4-rev_array -------------------------------------------------------------------------------- /0x13-more_singly_linked_lists/.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "files.associations": { 3 | "stdlib.h": "c", 4 | "lists.h": "c" 5 | } 6 | } -------------------------------------------------------------------------------- /0x18-dynamic_libraries/100-operations.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x18-dynamic_libraries/100-operations.so -------------------------------------------------------------------------------- /0x01-variables_if_else_while/100-print_comb3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x01-variables_if_else_while/100-print_comb3 -------------------------------------------------------------------------------- /0x01-variables_if_else_while/101-print_comb4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x01-variables_if_else_while/101-print_comb4 -------------------------------------------------------------------------------- /0x01-variables_if_else_while/102-print_comb5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x01-variables_if_else_while/102-print_comb5 -------------------------------------------------------------------------------- /0x01-variables_if_else_while/5-print_numbers: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x01-variables_if_else_while/5-print_numbers -------------------------------------------------------------------------------- /0x01-variables_if_else_while/6-print_numberz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x01-variables_if_else_while/6-print_numberz -------------------------------------------------------------------------------- /0x01-variables_if_else_while/8-print_base16: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x01-variables_if_else_while/8-print_base16 -------------------------------------------------------------------------------- /0x02-functions_nested_loops/100-times_table: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x02-functions_nested_loops/100-times_table -------------------------------------------------------------------------------- /0x04-more_functions_nested_loops/7-diagonals: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x04-more_functions_nested_loops/7-diagonals -------------------------------------------------------------------------------- /0x04-more_functions_nested_loops/9-fizz_buzz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x04-more_functions_nested_loops/9-fizz_buzz -------------------------------------------------------------------------------- /0x07-pointers_arrays_strings/100-set_string: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x07-pointers_arrays_strings/100-set_string -------------------------------------------------------------------------------- /0x01-variables_if_else_while/7-print_tebahpla: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x01-variables_if_else_while/7-print_tebahpla -------------------------------------------------------------------------------- /0x04-more_functions_nested_loops/10-triangles: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x04-more_functions_nested_loops/10-triangles -------------------------------------------------------------------------------- /0x04-more_functions_nested_loops/5-more_numbers: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x04-more_functions_nested_loops/5-more_numbers -------------------------------------------------------------------------------- /0x05-pointers_arrays_strings/.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "editor.detectIndentation": false, 3 | "files.associations": { 4 | "main.h": "c" 5 | } 6 | } -------------------------------------------------------------------------------- /0x06-pointers_arrays_strings/101-print_numbers: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x06-pointers_arrays_strings/101-print_numbers -------------------------------------------------------------------------------- /0x06-pointers_arrays_strings/5-string_toupper: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x06-pointers_arrays_strings/5-string_toupper -------------------------------------------------------------------------------- /0x07-pointers_arrays_strings/7-print_chessboard: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x07-pointers_arrays_strings/7-print_chessboard -------------------------------------------------------------------------------- /0x07-pointers_arrays_strings/8-print_diagsums: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x07-pointers_arrays_strings/8-print_diagsums -------------------------------------------------------------------------------- /0x12-singly_linked_lists/101-hello_holberton.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x12-singly_linked_lists/101-hello_holberton.o -------------------------------------------------------------------------------- /0x04-more_functions_nested_loops/100-prime_factor: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x04-more_functions_nested_loops/100-prime_factor -------------------------------------------------------------------------------- /0x04-more_functions_nested_loops/3-print_numbers: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x04-more_functions_nested_loops/3-print_numbers -------------------------------------------------------------------------------- /0x1C-makefiles/m.h: -------------------------------------------------------------------------------- 1 | #ifndef __M_H__ 2 | #define __M_H__ 3 | 4 | #include 5 | #include 6 | 7 | void print_school(void); 8 | 9 | #endif 10 | -------------------------------------------------------------------------------- /0x04-more_functions_nested_loops/101-print_numbers: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x04-more_functions_nested_loops/101-print_numbers -------------------------------------------------------------------------------- /0x0D-preprocessor/0-object_like_macro.h: -------------------------------------------------------------------------------- 1 | #ifndef _OBJECT_LIKE_MACRO_H_ 2 | #define _OBJECT_LIKE_MACRO_H_ 3 | 4 | #define SIZE 1024 5 | 6 | #endif /* _OBJECT_LIKE_MACRO_H_ */ 7 | -------------------------------------------------------------------------------- /0x04-more_functions_nested_loops/4-print_most_numbers: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wendymunyasi/alx-low_level_programming/HEAD/0x04-more_functions_nested_loops/4-print_most_numbers -------------------------------------------------------------------------------- /0x15-file_io/incitatous: -------------------------------------------------------------------------------- 1 | Why you should think twice before putting pictures on social media. 2 | (What you always wanted to know about @Incitatous) 3 | #PrivacyAware 4 | http://imgur.com/a/Mq1tc 5 | -------------------------------------------------------------------------------- /0x0D-preprocessor/3-function_like_macro.h: -------------------------------------------------------------------------------- 1 | #ifndef _FUNCTION_LIKE_MACRO_H_ 2 | #define _FUNCTION_LIKE_MACRO_H_ 3 | 4 | #define ABS(x) ((x < 0) ? -(x) : (x)) 5 | 6 | #endif /* _FUNCTION_LIKE_MACRO_H_ */ 7 | -------------------------------------------------------------------------------- /0x1C-makefiles/main.c: -------------------------------------------------------------------------------- 1 | #include "m.h" 2 | 3 | /** 4 | * main - Entry point 5 | * 6 | * Return: Always 7 | */ 8 | int main(void) 9 | { 10 | print_school(); 11 | return (EXIT_SUCCESS); 12 | } 13 | -------------------------------------------------------------------------------- /0x02-functions_nested_loops/8-main.c: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | 3 | /** 4 | * main - check the code 5 | * 6 | * Return: Always 0. 7 | */ 8 | int main(void) 9 | { 10 | jack_bauer(); 11 | return (0); 12 | } 13 | -------------------------------------------------------------------------------- /0x02-functions_nested_loops/9-main.c: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | 3 | /** 4 | * main - check the code 5 | * 6 | * Return: Always 0. 7 | */ 8 | int main(void) 9 | { 10 | times_table(); 11 | return (0); 12 | } 13 | -------------------------------------------------------------------------------- /0x02-functions_nested_loops/1-main.c: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | 3 | /** 4 | * main - check the code 5 | * 6 | * Return: Always 0. 7 | */ 8 | int main(void) 9 | { 10 | print_alphabet(); 11 | return (0); 12 | } 13 | -------------------------------------------------------------------------------- /0x04-more_functions_nested_loops/3-main.c: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | 3 | /** 4 | * main - check the code 5 | * 6 | * Return: Always 0. 7 | */ 8 | int main(void) 9 | { 10 | print_numbers(); 11 | return (0); 12 | } 13 | -------------------------------------------------------------------------------- /0x04-more_functions_nested_loops/5-main.c: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | 3 | /** 4 | * main - check the code 5 | * 6 | * Return: Always 0. 7 | */ 8 | int main(void) 9 | { 10 | more_numbers(); 11 | return (0); 12 | } 13 | -------------------------------------------------------------------------------- /0x02-functions_nested_loops/2-main.c: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | 3 | /** 4 | * main - check the code. 5 | * 6 | * Return: Always 0. 7 | */ 8 | int main(void) 9 | { 10 | print_alphabet_x10(); 11 | return (0); 12 | } 13 | -------------------------------------------------------------------------------- /0x04-more_functions_nested_loops/4-main.c: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | 3 | /** 4 | * main - check the code 5 | * 6 | * Return: Always 0. 7 | */ 8 | int main(void) 9 | { 10 | print_most_numbers(); 11 | return (0); 12 | } 13 | -------------------------------------------------------------------------------- /0x08-recursion/0-main.c: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | 3 | /** 4 | * main - check the code 5 | * 6 | * Return: Always 0. 7 | */ 8 | int main(void) 9 | { 10 | _puts_recursion("Puts with recursion"); 11 | return (0); 12 | } 13 | -------------------------------------------------------------------------------- /0x08-recursion/1-main.c: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | 3 | /** 4 | * main - check the code 5 | * 6 | * Return: Always 0. 7 | */ 8 | int main(void) 9 | { 10 | _print_rev_recursion("\nColton Walker"); 11 | return (0); 12 | } 13 | -------------------------------------------------------------------------------- /0x10-variadic_functions/2-main.c: -------------------------------------------------------------------------------- 1 | #include "variadic_functions.h" 2 | 3 | /** 4 | * main - check the code 5 | * 6 | * Return: Always 0. 7 | */ 8 | int main(void) 9 | { 10 | print_strings(", ", 2, "Jay", "Django"); 11 | return (0); 12 | } 13 | -------------------------------------------------------------------------------- /0x10-variadic_functions/3-main.c: -------------------------------------------------------------------------------- 1 | #include "variadic_functions.h" 2 | 3 | /** 4 | * main - check the code 5 | * 6 | * Return: Always 0. 7 | */ 8 | int main(void) 9 | { 10 | print_all("ceis", 'B', 3, "stSchool"); 11 | return (0); 12 | } 13 | -------------------------------------------------------------------------------- /0x10-variadic_functions/1-main.c: -------------------------------------------------------------------------------- 1 | #include "variadic_functions.h" 2 | 3 | /** 4 | * main - check the code 5 | * 6 | * Return: Always 0. 7 | */ 8 | int main(void) 9 | { 10 | print_numbers(", ", 4, 0, 98, -1024, 402); 11 | return (0); 12 | } 13 | -------------------------------------------------------------------------------- /0x05-pointers_arrays_strings/6-main.c: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | 3 | /** 4 | * main - check the code 5 | * 6 | * Return: Always 0. 7 | */ 8 | int main(void) 9 | { 10 | char *str; 11 | 12 | str = "Holberton!"; 13 | puts2(str); 14 | return (0); 15 | } 16 | -------------------------------------------------------------------------------- /0x05-pointers_arrays_strings/7-main.c: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | 3 | /** 4 | * main - check the code 5 | * 6 | * Return: Always 0. 7 | */ 8 | int main(void) 9 | { 10 | char *str; 11 | 12 | str = "0123456789"; 13 | puts_half(str); 14 | return (0); 15 | } 16 | -------------------------------------------------------------------------------- /0x04-more_functions_nested_loops/8-main.c: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | 3 | /** 4 | * main - check the code 5 | * 6 | * Return: Always 0. 7 | */ 8 | int main(void) 9 | { 10 | print_square(2); 11 | print_square(10); 12 | print_square(0); 13 | return (0); 14 | } 15 | -------------------------------------------------------------------------------- /0x02-functions_nested_loops/11-main.c: -------------------------------------------------------------------------------- 1 | /** 2 | * main - check the code 3 | * 4 | * Return: Always 0. 5 | */ 6 | int main(void) 7 | { 8 | print_to_98(0); 9 | print_to_98(98); 10 | print_to_98(111); 11 | print_to_98(81); 12 | print_to_98(-10); 13 | return (0); 14 | } 15 | -------------------------------------------------------------------------------- /0x0D-preprocessor/02-main.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | /** 4 | * main - program that prints the name of the file it was compiled from. 5 | * 6 | * Return: 0 (Success) 7 | */ 8 | 9 | 10 | int main(void) 11 | { 12 | printf("%s\n", __FILE__); 13 | return (0); 14 | } 15 | -------------------------------------------------------------------------------- /0x0D-preprocessor/2-main.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | /** 4 | * main - program that prints the name of the file it was compiled from. 5 | * 6 | * Return: 0 (Success) 7 | */ 8 | 9 | 10 | int main(void) 11 | { 12 | printf("%s\n", __FILE__); 13 | return (0); 14 | } 15 | -------------------------------------------------------------------------------- /0x02-functions_nested_loops/10-main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "main.h" 3 | 4 | /** 5 | * main - check the code 6 | * 7 | * Return: Always 0. 8 | */ 9 | int main(void) 10 | { 11 | int n; 12 | 13 | n = add(89, 9); 14 | printf("%d\n", n); 15 | return (0); 16 | } 17 | -------------------------------------------------------------------------------- /0x03-debugging/0-main.c: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | 3 | /** 4 | * main - tests function that prints if integer is positive or negative 5 | * Return: 0 6 | */ 7 | 8 | int main(void) 9 | { 10 | int i; 11 | 12 | i = 0; 13 | positive_or_negative(i); 14 | 15 | return (0); 16 | } 17 | -------------------------------------------------------------------------------- /0x04-more_functions_nested_loops/6-main.c: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | 3 | /** 4 | * main - check the code 5 | * 6 | * Return: Always 0. 7 | */ 8 | int main(void) 9 | { 10 | print_line(0); 11 | print_line(2); 12 | print_line(10); 13 | print_line(-4); 14 | return (0); 15 | } 16 | -------------------------------------------------------------------------------- /0x08-recursion/2-main.c: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | #include 3 | 4 | /** 5 | * main - check the code 6 | * 7 | * Return: Always 0. 8 | */ 9 | int main(void) 10 | { 11 | int n; 12 | 13 | n = _strlen_recursion("Corbin Coleman"); 14 | printf("%d\n", n); 15 | return (0); 16 | } 17 | -------------------------------------------------------------------------------- /0x04-more_functions_nested_loops/10-main.c: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | 3 | /** 4 | * main - check the code 5 | * 6 | * Return: Always 0. 7 | */ 8 | int main(void) 9 | { 10 | print_triangle(2); 11 | print_triangle(10); 12 | print_triangle(1); 13 | print_triangle(0); 14 | return (0); 15 | } 16 | -------------------------------------------------------------------------------- /0x04-more_functions_nested_loops/2-main.c: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | #include 3 | 4 | /** 5 | * main - check the code 6 | * 7 | * Return: Always 0. 8 | */ 9 | int main(void) 10 | { 11 | printf("%d\n", mul(98, 1024)); 12 | printf("%d\n", mul(-402, 4096)); 13 | return (0); 14 | } 15 | -------------------------------------------------------------------------------- /0x04-more_functions_nested_loops/7-main.c: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | 3 | /** 4 | * main - check the code 5 | * 6 | * Return: Always 0. 7 | */ 8 | int main(void) 9 | { 10 | print_diagonal(0); 11 | print_diagonal(2); 12 | print_diagonal(10); 13 | print_diagonal(-4); 14 | return (0); 15 | } 16 | -------------------------------------------------------------------------------- /0x0D-preprocessor/4-main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "4-sum.h" 3 | #include "4-sum.h" 4 | 5 | /** 6 | * main - check the code 7 | * 8 | * Return: Always 0. 9 | */ 10 | int main(void) 11 | { 12 | int s; 13 | 14 | s = SUM(98, 1024); 15 | printf("%d\n", s); 16 | return (0); 17 | } 18 | -------------------------------------------------------------------------------- /0x12-singly_linked_lists/100-main.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | /** 4 | * main - check the code 5 | * 6 | * Return: Always 0. 7 | */ 8 | int main(void) 9 | { 10 | printf("(A tortoise, having pretty good sense of a hare's nature, challenges one to a race.)\n"); 11 | return (0); 12 | } 13 | -------------------------------------------------------------------------------- /0x03-debugging/main.h: -------------------------------------------------------------------------------- 1 | #ifndef MAIN_H 2 | #define MAIN_H 3 | 4 | #include 5 | 6 | void positive_or_negative(int i); 7 | int largest_number(int a, int b, int c); 8 | int convert_day(int month, int day); 9 | void print_remaining_days(int month, int day, int year); 10 | 11 | #endif /* MAIN_H */ -------------------------------------------------------------------------------- /0x04-more_functions_nested_loops/2-mul.c: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | 3 | /** 4 | * mul - Function that multiplies two integers. 5 | * @a: first number. 6 | * @b: second number. 7 | * 8 | * Return: the result of multiplication. 9 | */ 10 | int mul(int a, int b) 11 | { 12 | return (a * b); 13 | } 14 | -------------------------------------------------------------------------------- /0x14-bit_manipulation/100-main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "main.h" 3 | 4 | int main(void) 5 | { 6 | int n; 7 | 8 | n = get_endianness(); 9 | if (n != 0) 10 | { 11 | printf("Little Endian\n"); 12 | } 13 | else 14 | { 15 | printf("Big Endian\n"); 16 | } 17 | return (0); 18 | } 19 | -------------------------------------------------------------------------------- /0x05-pointers_arrays_strings/3-main.c: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | 3 | /** 4 | * main - check the code 5 | * 6 | * Return: Always 0. 7 | */ 8 | int main(void) 9 | { 10 | char *str; 11 | 12 | str = "I do not fear computers. I fear the lack of them - Isaac Asimov"; 13 | _puts(str); 14 | return (0); 15 | } 16 | -------------------------------------------------------------------------------- /0x0A-argc_argv/main.h: -------------------------------------------------------------------------------- 1 | #ifndef MAIH_H 2 | #define MAIN_H 3 | 4 | int main(int argc __attribute__((unused)), char *argv[]); 5 | int main(int argc, char *argv[]__attribute__((unused))); 6 | int main(int argc, char *argv[]); 7 | int main(int argc, char *argv[]); 8 | int main(int argc, char *argv[]); 9 | 10 | #endif -------------------------------------------------------------------------------- /0x1C-makefiles/3-Makefile: -------------------------------------------------------------------------------- 1 | CC=gcc 2 | SRC = main.c school.c 3 | OBJ =$(SRC:.c=.o) 4 | NAME=school 5 | RM=rm 6 | 7 | all : $(OBJ) 8 | $(CC) $(SRC) -o $(NAME) 9 | 10 | clean : 11 | -$(RM) -f *~ $(NAME) 12 | 13 | oclean : 14 | -$(RM) -f $(OBJ) 15 | 16 | fclean : clean oclean 17 | 18 | re : oclean all 19 | -------------------------------------------------------------------------------- /0x04-more_functions_nested_loops/0-isupper.c: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | 3 | /** 4 | * _isupper - Function that checks for uppercase character. 5 | * @c: character to classify. 6 | * 7 | * Return: 1 if uppercase or 0 otherwise. 8 | */ 9 | 10 | int _isupper(int c) 11 | { 12 | return (c >= 65 && c <= 90); 13 | } 14 | -------------------------------------------------------------------------------- /0x04-more_functions_nested_loops/1-isdigit.c: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | /** 3 | * _isdigit - Function that checks for a digit (0 through 9). 4 | * @c: character to classify. 5 | * 6 | * Return: 1 if c is a digit and 0 otherwise. 7 | */ 8 | 9 | int _isdigit(int c) 10 | { 11 | return (c >= 48 && c <= 57); 12 | } 13 | -------------------------------------------------------------------------------- /0x05-pointers_arrays_strings/4-main.c: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | 3 | /** 4 | * main - check the code 5 | * 6 | * Return: Always 0. 7 | */ 8 | int main(void) 9 | { 10 | char *str; 11 | 12 | str = "I do not fear computers. I fear the lack of them - Isaac Asimov"; 13 | print_rev(str); 14 | return (0); 15 | } 16 | -------------------------------------------------------------------------------- /0x0D-preprocessor/0-main.c: -------------------------------------------------------------------------------- 1 | #include "0-object_like_macro.h" 2 | #include "0-object_like_macro.h" 3 | #include 4 | 5 | /** 6 | * main - check the code 7 | * 8 | * Return: Always 0. 9 | */ 10 | int main(void) 11 | { 12 | int s; 13 | 14 | s = 98 + SIZE; 15 | printf("%d\n", s); 16 | return (0); 17 | } 18 | -------------------------------------------------------------------------------- /0x05-pointers_arrays_strings/0-main.c: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | #include 3 | 4 | /** 5 | * main - check the code 6 | * 7 | * Return: Always 0. 8 | */ 9 | int main(void) 10 | { 11 | int n; 12 | 13 | n = 402; 14 | printf("n=%d\n", n); 15 | reset_to_98(&n); 16 | printf("n=%d\n", n); 17 | return (0); 18 | } 19 | -------------------------------------------------------------------------------- /0x05-pointers_arrays_strings/5-main.c: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | #include 3 | 4 | /** 5 | * main - check the code 6 | * 7 | * Return: Always 0. 8 | */ 9 | int main(void) 10 | { 11 | char s[10] = "My School"; 12 | 13 | printf("%s\n", s); 14 | rev_string(s); 15 | printf("%s\n", s); 16 | return (0); 17 | } 18 | -------------------------------------------------------------------------------- /0x08-recursion/_putchar.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | /** 4 | * _putchar - writes the character c to stdout 5 | * @c: The character to print 6 | * 7 | * Return: On success 1. 8 | * On error, -1 is returned, and errno is set appropriately. 9 | */ 10 | int _putchar(char c) 11 | { 12 | return (write(1, &c, 1)); 13 | } 14 | -------------------------------------------------------------------------------- /0x0A-argc_argv/_putchar.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | /** 4 | * _putchar - writes the character c to stdout 5 | * @c: The character to print 6 | * 7 | * Return: On success 1. 8 | * On error, -1 is returned, and errno is set appropriately. 9 | */ 10 | int _putchar(char c) 11 | { 12 | return (write(1, &c, 1)); 13 | } 14 | -------------------------------------------------------------------------------- /0x0D-preprocessor/1-main.c: -------------------------------------------------------------------------------- 1 | #include "1-pi.h" 2 | #include "1-pi.h" 3 | #include 4 | 5 | /** 6 | * main - check the code 7 | * 8 | * Return: Always 0. 9 | */ 10 | int main(void) 11 | { 12 | float a; 13 | float r; 14 | 15 | r = 98; 16 | a = PI * r * r; 17 | printf("%.3f\n", a); 18 | return (0); 19 | } 20 | -------------------------------------------------------------------------------- /0x15-file_io/_putchar.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | /** 4 | * _putchar - writes the character c to stdout 5 | * @c: The character to print 6 | * 7 | * Return: On success 1. 8 | * On error, -1 is returned, and errno is set appropriately. 9 | */ 10 | int _putchar(char c) 11 | { 12 | return (write(1, &c, 1)); 13 | } 14 | -------------------------------------------------------------------------------- /0x05-pointers_arrays_strings/1-swap.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "main.h" 3 | 4 | /** 5 | * swap_int - Function that swaps two integers. 6 | * @a: integer 7 | * @b: integer 8 | * 9 | * Return: No return. 10 | */ 11 | 12 | void swap_int(int *a, int *b) 13 | { 14 | int num = *a; 15 | *a = *b; 16 | *b = num; 17 | } 18 | -------------------------------------------------------------------------------- /0x0B-malloc_free/_putchar.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | /** 4 | * _putchar - writes the character c to stdout 5 | * @c: The character to print 6 | * 7 | * Return: On success 1. 8 | * On error, -1 is returned, and errno is set appropriately. 9 | */ 10 | int _putchar(char c) 11 | { 12 | return (write(1, &c, 1)); 13 | } 14 | -------------------------------------------------------------------------------- /0x02-functions_nested_loops/6-abs.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "main.h" 4 | 5 | /** 6 | * _abs- Function that computes the absolute value of an integer. 7 | * @n: integer value. 8 | * 9 | * Return: 0 or 1 depending on the answer 10 | */ 11 | 12 | int _abs(int n) 13 | { 14 | return (abs(n)); 15 | } 16 | -------------------------------------------------------------------------------- /0x05-pointers_arrays_strings/0-reset_to_98.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "main.h" 3 | 4 | /** 5 | * reset_to_98 - function that takes a pointer to an int as parameter and, 6 | * updates value to 98. 7 | * @n: integer 8 | * 9 | * Return: No return. 10 | */ 11 | 12 | void reset_to_98(int *n) 13 | { 14 | *n = 98; 15 | } 16 | -------------------------------------------------------------------------------- /0x05-pointers_arrays_strings/2-main.c: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | #include 3 | 4 | /** 5 | * main - check the code 6 | * 7 | * Return: Always 0. 8 | */ 9 | int main(void) 10 | { 11 | char *str; 12 | int len; 13 | 14 | str = "My first strlen!"; 15 | len = _strlen(str); 16 | printf("%d\n", len); 17 | return (0); 18 | } 19 | -------------------------------------------------------------------------------- /0x0C-more_malloc_free/_putchar.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | /** 4 | * _putchar - writes the character c to stdout 5 | * @c: The character to print 6 | * 7 | * Return: On success 1. 8 | * On error, -1 is returned, and errno is set appropriately. 9 | */ 10 | int _putchar(char c) 11 | { 12 | return (write(1, &c, 1)); 13 | } 14 | -------------------------------------------------------------------------------- /0x0F-function_pointers/_putchar.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | /** 4 | * _putchar - writes the character c to stdout 5 | * @c: The character to print 6 | * 7 | * Return: On success 1. 8 | * On error, -1 is returned, and errno is set appropriately. 9 | */ 10 | int _putchar(char c) 11 | { 12 | return (write(1, &c, 1)); 13 | } 14 | -------------------------------------------------------------------------------- /0x10-variadic_functions/_putchar.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | /** 4 | * _putchar - writes the character c to stdout 5 | * @c: The character to print 6 | * 7 | * Return: On success 1. 8 | * On error, -1 is returned, and errno is set appropriately. 9 | */ 10 | int _putchar(char c) 11 | { 12 | return (write(1, &c, 1)); 13 | } 14 | -------------------------------------------------------------------------------- /0x14-bit_manipulation/_putchar.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | /** 4 | * _putchar - writes the character c to stdout 5 | * @c: The character to print 6 | * 7 | * Return: On success 1. 8 | * On error, -1 is returned, and errno is set appropriately. 9 | */ 10 | int _putchar(char c) 11 | { 12 | return (write(1, &c, 1)); 13 | } 14 | -------------------------------------------------------------------------------- /0x02-functions_nested_loops/10-add.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "main.h" 4 | 5 | /** 6 | * add - A function that adds two integers. 7 | * @a: integer number 8 | * @b: integer number 9 | * 10 | * Return: Result of the addition. 11 | */ 12 | 13 | int add(int a, int b) 14 | { 15 | return (a + b); 16 | } 17 | -------------------------------------------------------------------------------- /0x02-functions_nested_loops/_putchar.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | /** 4 | * _putchar - writes the character c to stdout 5 | * @c: The character to print 6 | * 7 | * Return: On success 1. 8 | * On error, -1 is returned, and errno is set appropriately. 9 | */ 10 | int _putchar(char c) 11 | { 12 | return (write(1, &c, 1)); 13 | } 14 | -------------------------------------------------------------------------------- /0x05-pointers_arrays_strings/_putchar.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | /** 4 | * _putchar - writes the character c to stdout 5 | * @c: The character to print 6 | * 7 | * Return: On success 1. 8 | * On error, -1 is returned, and errno is set appropriately. 9 | */ 10 | int _putchar(char c) 11 | { 12 | return (write(1, &c, 1)); 13 | } 14 | -------------------------------------------------------------------------------- /0x06-pointers_arrays_strings/_putchar.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | /** 4 | * _putchar - writes the character c to stdout 5 | * @c: The character to print 6 | * 7 | * Return: On success 1. 8 | * On error, -1 is returned, and errno is set appropriately. 9 | */ 10 | int _putchar(char c) 11 | { 12 | return (write(1, &c, 1)); 13 | } 14 | -------------------------------------------------------------------------------- /0x07-pointers_arrays_strings/_putchar.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | /** 4 | * _putchar - writes the character c to stdout 5 | * @c: The character to print 6 | * 7 | * Return: On success 1. 8 | * On error, -1 is returned, and errno is set appropriately. 9 | */ 10 | int _putchar(char c) 11 | { 12 | return (write(1, &c, 1)); 13 | } 14 | -------------------------------------------------------------------------------- /0x13-more_singly_linked_lists/_putchar.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | /** 4 | * _putchar - writes the character c to stdout 5 | * @c: The character to print 6 | * 7 | * Return: On success 1. 8 | * On error, -1 is returned, and errno is set appropriately. 9 | */ 10 | int _putchar(char c) 11 | { 12 | return (write(1, &c, 1)); 13 | } 14 | -------------------------------------------------------------------------------- /0x1C-makefiles/4-Makefile: -------------------------------------------------------------------------------- 1 | CC=gcc 2 | SRC=main.c school.c 3 | OBJ=$(SRC:%.c=%.o) 4 | NAME=school 5 | RM=rm -f 6 | CFLAGS=-Wall -Werror -Wextra -pedantic 7 | 8 | all: $(OBJ) 9 | $(CC) $(OBJ) -o $(NAME) 10 | 11 | clean: 12 | $(RM) *~ $(NAME) 13 | 14 | oclean: 15 | $(RM) $(OBJ) 16 | 17 | fclean: clean oclean 18 | 19 | re: oclean all 20 | -------------------------------------------------------------------------------- /0x02-functions_nested_loops/7-main.c: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | 3 | /** 4 | * main - check the code 5 | * 6 | * Return: Always 0. 7 | */ 8 | int main(void) 9 | { 10 | int r; 11 | 12 | print_last_digit(98); 13 | print_last_digit(0); 14 | r = print_last_digit(-1024); 15 | _putchar('0' + r); 16 | _putchar('\n'); 17 | return (0); 18 | } 19 | -------------------------------------------------------------------------------- /0x04-more_functions_nested_loops/_putchar.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | /** 4 | * _putchar - writes the character c to stdout 5 | * @c: The character to print 6 | * 7 | * Return: On success 1. 8 | * On error, -1 is returned, and errno is set appropriately. 9 | */ 10 | int _putchar(char c) 11 | { 12 | return (write(1, &c, 1)); 13 | } 14 | -------------------------------------------------------------------------------- /0x07-pointers_arrays_strings/4-main.c: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | #include 3 | 4 | /** 5 | * main - check the code 6 | * 7 | * Return: Always 0. 8 | */ 9 | int main(void) 10 | { 11 | char *s = "hello, world"; 12 | char *f = "world"; 13 | char *t; 14 | 15 | t = _strpbrk(s, f); 16 | printf("%s\n", t); 17 | return (0); 18 | } 19 | -------------------------------------------------------------------------------- /0x0E-structures_typedef/2-main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "dog.h" 3 | 4 | /** 5 | * main - check the code 6 | * 7 | * Return: Always 0. 8 | */ 9 | int main(void) 10 | { 11 | struct dog my_dog; 12 | 13 | my_dog.name = "Poppy"; 14 | my_dog.age = 3.5; 15 | my_dog.owner = "Bob"; 16 | print_dog(&my_dog); 17 | return (0); 18 | } 19 | -------------------------------------------------------------------------------- /0x0F-function_pointers/0-print_name.c: -------------------------------------------------------------------------------- 1 | #include "function_pointers.h" 2 | 3 | /** 4 | * print_name - function that prints a name. 5 | * @name: pointer to name. 6 | * @f: pointer to function. 7 | * 8 | * Return: No return. 9 | */ 10 | 11 | void print_name(char *name, void (*f)(char *)) 12 | { 13 | if (name && f) 14 | f(name); 15 | } 16 | -------------------------------------------------------------------------------- /0x04-more_functions_nested_loops/1-main.c: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | #include 3 | 4 | /** 5 | * main - check the code 6 | * 7 | * Return: Always 0. 8 | */ 9 | int main(void) 10 | { 11 | char c; 12 | 13 | c = '0'; 14 | printf("%c: %d\n", c, _isdigit(c)); 15 | c = 'a'; 16 | printf("%c: %d\n", c, _isdigit(c)); 17 | return (0); 18 | } 19 | -------------------------------------------------------------------------------- /0x07-pointers_arrays_strings/3-main.c: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | #include 3 | 4 | /** 5 | * main - check the code 6 | * 7 | * Return: Always 0. 8 | */ 9 | int main(void) 10 | { 11 | char *s = "hello, world"; 12 | char *f = "oleh"; 13 | unsigned int n; 14 | 15 | n = _strspn(s, f); 16 | printf("%u\n", n); 17 | return (0); 18 | } 19 | -------------------------------------------------------------------------------- /0x04-more_functions_nested_loops/0-main.c: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | #include 3 | 4 | /** 5 | * main - check the code. 6 | * 7 | * Return: Always 0. 8 | */ 9 | int main(void) 10 | { 11 | char c; 12 | 13 | c = 'A'; 14 | printf("%c: %d\n", c, _isupper(c)); 15 | c = 'a'; 16 | printf("%c: %d\n", c, _isupper(c)); 17 | return (0); 18 | } 19 | -------------------------------------------------------------------------------- /0x06-pointers_arrays_strings/5-main.c: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | #include 3 | 4 | /** 5 | * main - check the code 6 | * 7 | * Return: Always 0. 8 | */ 9 | int main(void) 10 | { 11 | char str[] = "Look up!\n"; 12 | char *ptr; 13 | 14 | ptr = string_toupper(str); 15 | printf("%s", ptr); 16 | printf("%s", str); 17 | return (0); 18 | } 19 | -------------------------------------------------------------------------------- /0x07-pointers_arrays_strings/2-main.c: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | #include 3 | 4 | /** 5 | * main - check the code 6 | * 7 | * Return: Always 0. 8 | */ 9 | int main(void) 10 | { 11 | char *s = "hello"; 12 | char *f; 13 | 14 | f = _strchr(s, 'l'); 15 | 16 | if (f != NULL) 17 | { 18 | printf("%s\n", f); 19 | } 20 | return (0); 21 | } 22 | -------------------------------------------------------------------------------- /0x05-pointers_arrays_strings/8-main.c: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | 3 | /** 4 | * main - check the code for 5 | * 6 | * Return: Always 0. 7 | */ 8 | int main(void) 9 | { 10 | int array[5]; 11 | 12 | array[0] = 98; 13 | array[1] = 402; 14 | array[2] = -198; 15 | array[3] = 298; 16 | array[4] = -1024; 17 | print_array(array, 5); 18 | return (0); 19 | } 20 | -------------------------------------------------------------------------------- /0x00-hello_world/4-puts.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | /** 4 | * main - Entry point. 5 | * 6 | * Use the function puts. 7 | * You are not allowed to use printf. 8 | * Your program should end with the value 0 9 | * 10 | * Return: 0 11 | */ 12 | int main(void) 13 | { 14 | puts("\"Programming is like building a multilingual puzzle"); 15 | return (0); 16 | } 17 | -------------------------------------------------------------------------------- /0x0C-more_malloc_free/1-main.c: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | #include 3 | #include 4 | 5 | /** 6 | * main - check the code 7 | * 8 | * Return: Always 0. 9 | */ 10 | int main(void) 11 | { 12 | char *concat; 13 | 14 | concat = string_nconcat("Best ", "School !!!", 6); 15 | printf("%s\n", concat); 16 | free(concat); 17 | return (0); 18 | } 19 | -------------------------------------------------------------------------------- /0x0E-structures_typedef/4-main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "dog.h" 3 | 4 | /** 5 | * main - check the code 6 | * 7 | * Return: Always 0. 8 | */ 9 | int main(void) 10 | { 11 | dog_t *my_dog; 12 | 13 | my_dog = new_dog("Poppy", 3.5, "Bob"); 14 | printf("My name is %s, and I am %.1f :) - Woof!\n", my_dog->name, my_dog->age); 15 | return (0); 16 | } 17 | -------------------------------------------------------------------------------- /0x02-functions_nested_loops/100-main.c: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | 3 | /** 4 | * main - check the code. 5 | * 6 | * Return: Always 0. 7 | */ 8 | int main(void) 9 | { 10 | print_times_table(3); 11 | _putchar('\n'); 12 | print_times_table(5); 13 | _putchar('\n'); 14 | print_times_table(98); 15 | _putchar('\n'); 16 | print_times_table(12); 17 | return (0); 18 | } 19 | -------------------------------------------------------------------------------- /0x05-pointers_arrays_strings/1-main.c: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | #include 3 | 4 | /** 5 | * main - check the code 6 | * 7 | * Return: Always 0. 8 | */ 9 | int main(void) 10 | { 11 | int a; 12 | int b; 13 | 14 | a = 98; 15 | b = 42; 16 | printf("a=%d, b=%d\n", a, b); 17 | swap_int(&a, &b); 18 | printf("a=%d, b=%d\n", a, b); 19 | return (0); 20 | } 21 | -------------------------------------------------------------------------------- /0x07-pointers_arrays_strings/5-main.c: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | #include 3 | 4 | /** 5 | * main - check the code 6 | * 7 | * Return: Always 0. 8 | */ 9 | int main(void) 10 | { 11 | char *s = "Techie Delight Ace the Technical Interviews"; 12 | char *f = "Ace"; 13 | char *t; 14 | 15 | t = _strstr(s, f); 16 | printf("%s\n", t); 17 | return (0); 18 | } 19 | -------------------------------------------------------------------------------- /0x0E-structures_typedef/1-main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "dog.h" 3 | 4 | /** 5 | * main - check the code 6 | * 7 | * Return: Always 0. 8 | */ 9 | int main(void) 10 | { 11 | struct dog my_dog; 12 | 13 | init_dog(&my_dog, "Poppy", 3.5, "Bob"); 14 | printf("My name is %s, and I am %.1f :) - Woof!\n", my_dog.name, my_dog.age); 15 | return (0); 16 | } 17 | -------------------------------------------------------------------------------- /0x0F-function_pointers/function_pointers.h: -------------------------------------------------------------------------------- 1 | #ifndef _FUNCTION_POINTERS_H_ 2 | #define _FUNCTION_POINTERS_H_ 3 | 4 | #include 5 | 6 | int _putchar(char c); 7 | void print_name(char *name, void (*f)(char *)); 8 | void array_iterator(int *array, size_t size, void (*action)(int)); 9 | int int_index(int *array, int size, int (*cmp)(int)); 10 | 11 | #endif 12 | -------------------------------------------------------------------------------- /0x0D-preprocessor/3-main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "3-function_like_macro.h" 3 | #include "3-function_like_macro.h" 4 | 5 | /** 6 | * main - check the code 7 | * 8 | * Return: Always 0. 9 | */ 10 | int main(void) 11 | { 12 | int i; 13 | int j; 14 | 15 | i = ABS(-98) * 10; 16 | j = ABS(98) * 10; 17 | printf("%d, %d\n", i, j); 18 | return (0); 19 | } 20 | -------------------------------------------------------------------------------- /0x1C-makefiles/5-main.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 2 | """ 3 | 5-main 4 | """ 5 | island_perimeter = __import__('5-island_perimeter').island_perimeter 6 | 7 | if __name__ == "__main__": 8 | grid = [ 9 | [0, 0, 0, 0, 0, 0], 10 | [0, 1, 0, 0, 0, 0], 11 | [0, 1, 0, 0, 0, 0], 12 | [0, 1, 1, 1, 0, 0], 13 | [0, 0, 0, 0, 0, 0] 14 | ] 15 | print(island_perimeter(grid)) 16 | -------------------------------------------------------------------------------- /0x02-functions_nested_loops/3-main.c: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | 3 | /** 4 | * main - check the code. 5 | * 6 | * Return: Always 0. 7 | */ 8 | int main(void) 9 | { 10 | int r; 11 | 12 | r = _islower('H'); 13 | _putchar(r + '0'); 14 | r = _islower('o'); 15 | _putchar(r + '0'); 16 | r = _islower(108); 17 | _putchar(r + '0'); 18 | _putchar('\n'); 19 | return (0); 20 | } 21 | -------------------------------------------------------------------------------- /0x05-pointers_arrays_strings/9-main.c: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | #include 3 | 4 | /** 5 | * main - check the code 6 | * 7 | * Return: Always 0. 8 | */ 9 | int main(void) 10 | { 11 | char s1[98]; 12 | char *ptr; 13 | 14 | ptr = _strcpy(s1, "First, solve the problem. Then, write the code\n"); 15 | printf("%s", s1); 16 | printf("%s", ptr); 17 | return (0); 18 | } 19 | -------------------------------------------------------------------------------- /0x07-pointers_arrays_strings/100-main.c: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | #include 3 | 4 | /** 5 | * main - check the code 6 | * 7 | * Return: Always 0. 8 | */ 9 | int main(void) 10 | { 11 | char *s0 = "Bob Dylan"; 12 | char *s1 = "Robert Allen"; 13 | 14 | printf("%s, %s\n", s0, s1); 15 | set_string(&s1, s0); 16 | printf("%s, %s\n", s0, s1); 17 | return (0); 18 | } 19 | -------------------------------------------------------------------------------- /0x0E-structures_typedef/5-free_dog.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "dog.h" 4 | 5 | 6 | /** 7 | * free_dog - function that frees dogs. 8 | * @d: pointer to dog to free. 9 | * 10 | * Return: No return. 11 | */ 12 | 13 | void free_dog(dog_t *d) 14 | { 15 | if (d) 16 | { 17 | free(d->name); 18 | free(d->owner); 19 | free(d); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /0x1C-makefiles/100-Makefile: -------------------------------------------------------------------------------- 1 | CC=gcc 2 | SRC=main.c school.c 3 | OBJ=$(SRC:%.c=%.o) 4 | NAME=school 5 | CFLAGS=-Wall -Werror -Wextra -pedantic 6 | 7 | .PHONY: all clean oclean fclean re 8 | 9 | all: m.h $(OBJ) 10 | $(CC) $(OBJ) -o $(NAME) 11 | 12 | clean: 13 | $(RM) *~ $(NAME) 14 | 15 | oclean: 16 | $(RM) $(OBJ) 17 | 18 | fclean: clean oclean 19 | 20 | re: oclean all 21 | -------------------------------------------------------------------------------- /0x14-bit_manipulation/2-main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "main.h" 3 | 4 | /** 5 | * main - check the code 6 | * 7 | * Return: Always 0. 8 | */ 9 | int main(void) 10 | { 11 | int n; 12 | 13 | n = get_bit(1024, 10); 14 | printf("%d\n", n); 15 | n = get_bit(98, 1); 16 | printf("%d\n", n); 17 | n = get_bit(1024, 0); 18 | printf("%d\n", n); 19 | return (0); 20 | } 21 | -------------------------------------------------------------------------------- /0x1A-hash_tables/0-main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "hash_tables.h" 5 | 6 | /** 7 | * main - check the code for 8 | * 9 | * Return: Always EXIT_SUCCESS. 10 | */ 11 | int main(void) 12 | { 13 | hash_table_t *ht; 14 | 15 | ht = hash_table_create(1024); 16 | printf("%p\n", (void *)ht); 17 | return (EXIT_SUCCESS); 18 | } 19 | -------------------------------------------------------------------------------- /0x03-debugging/1-main.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | /** 4 | * main - causes an infinite loop 5 | * Return: 0 6 | */ 7 | 8 | int main(void) 9 | { 10 | int i; 11 | 12 | printf("Infinite loop incoming :(\n"); 13 | 14 | i = 0; 15 | 16 | /*while (i < 10)*/ 17 | /*{*/ 18 | /*putchar(i);*/ 19 | /*}*/ 20 | 21 | printf("Infinite loop avoided! \\o/\n"); 22 | 23 | return (0); 24 | } 25 | -------------------------------------------------------------------------------- /0x06-pointers_arrays_strings/3-main.c: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | #include 3 | 4 | /** 5 | * main - check the code 6 | * 7 | * Return: Always 0. 8 | */ 9 | int main(void) 10 | { 11 | char s1[] = "Hello"; 12 | char s2[] = "World!"; 13 | 14 | printf("%d\n", _strcmp(s1, s2)); 15 | printf("%d\n", _strcmp(s2, s1)); 16 | printf("%d\n", _strcmp(s1, s1)); 17 | return (0); 18 | } 19 | -------------------------------------------------------------------------------- /0x06-pointers_arrays_strings/7-main.c: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | #include 3 | 4 | /** 5 | * main - check the code for 6 | * 7 | * Return: Always 0. 8 | */ 9 | int main(void) 10 | { 11 | char s[] = "Expect the best. Prepare for the worst. Capitalize on what comes.\n"; 12 | char *p; 13 | 14 | p = leet(s); 15 | printf("%s", p); 16 | printf("%s", s); 17 | return (0); 18 | } 19 | -------------------------------------------------------------------------------- /0x0E-structures_typedef/5-main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "dog.h" 3 | 4 | /** 5 | * main - check the code 6 | * 7 | * Return: Always 0. 8 | */ 9 | int main(void) 10 | { 11 | dog_t *my_dog; 12 | 13 | my_dog = new_dog("Poppy", 3.5, "Bob"); 14 | printf("My name is %s, and I am %.1f :) - Woof!\n", my_dog->name, my_dog->age); 15 | free_dog(my_dog); 16 | return (0); 17 | } 18 | -------------------------------------------------------------------------------- /0x10-variadic_functions/0-main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "variadic_functions.h" 3 | 4 | /** 5 | * main - check the code 6 | * 7 | * Return: Always 0. 8 | */ 9 | int main(void) 10 | { 11 | int sum; 12 | 13 | sum = sum_them_all(2, 98, 1024); 14 | printf("%d\n", sum); 15 | sum = sum_them_all(4, 98, 1024, 402, -1024); 16 | printf("%d\n", sum); 17 | return (0); 18 | } 19 | -------------------------------------------------------------------------------- /0x1A-hash_tables/3-main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "hash_tables.h" 5 | 6 | /** 7 | * main - check the code 8 | * 9 | * Return: Always EXIT_SUCCESS. 10 | */ 11 | int main(void) 12 | { 13 | hash_table_t *ht; 14 | 15 | ht = hash_table_create(1024); 16 | hash_table_set(ht, "betty", "cool"); 17 | return (EXIT_SUCCESS); 18 | } 19 | -------------------------------------------------------------------------------- /0x07-pointers_arrays_strings/100-set_string.c: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | #include 3 | 4 | /** 5 | * set_string - function that sets the value of a pointer to a char. 6 | * of a square matrix of integers. 7 | * @s: pointer to change. 8 | * @to: pointer to change to. 9 | * 10 | * Return: no return. 11 | */ 12 | 13 | void set_string(char **s, char *to) 14 | { 15 | *s = to; 16 | } 17 | -------------------------------------------------------------------------------- /0x0E-structures_typedef/3-main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "dog.h" 3 | 4 | /** 5 | * main - check the code 6 | * 7 | * Return: Always 0. 8 | */ 9 | int main(void) 10 | { 11 | dog_t my_dog; 12 | 13 | my_dog.name = "Poppy"; 14 | my_dog.age = 3.5; 15 | my_dog.owner = "Bob"; 16 | printf("My name is %s, and I am %.1f :) - Woof!\n", my_dog.name, my_dog.age); 17 | return (0); 18 | } 19 | -------------------------------------------------------------------------------- /0x02-functions_nested_loops/0-putchar.c: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | 3 | /** 4 | * main - Entry point 5 | * Description: prints _putchar followed by new line 6 | * Return: 0 7 | */ 8 | 9 | int main(void) 10 | { 11 | int str[] = {95, 112, 117, 116, 99, 104, 97, 114}; 12 | int i; 13 | 14 | for (i = 0; i < 8; i++) 15 | { 16 | _putchar(str[i]); 17 | } 18 | _putchar('\n'); 19 | return (0); 20 | } 21 | -------------------------------------------------------------------------------- /0x02-functions_nested_loops/0-putchar2.c: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | 3 | /** 4 | * main - Entry point 5 | * Description: prints _putchar followed by new line 6 | * Return: 0 7 | */ 8 | 9 | int main(void) 10 | { 11 | int str[] = {95, 112, 117, 116, 99, 104, 97, 114}; 12 | int i; 13 | 14 | for (i = 0; i < 8; i++) 15 | { 16 | _putchar(str[i]); 17 | } 18 | _putchar('\n'); 19 | return (0); 20 | } 21 | -------------------------------------------------------------------------------- /0x03-debugging/2-main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "main.h" 3 | 4 | /** 5 | * main - prints the largest of 3 integers 6 | * Return: 0 7 | */ 8 | 9 | int main(void) 10 | { 11 | int a, b, c; 12 | int largest; 13 | 14 | a = 972; 15 | b = -98; 16 | c = 0; 17 | 18 | largest = largest_number(a, b, c); 19 | 20 | printf("%d is the largest number\n", largest); 21 | 22 | return (0); 23 | } 24 | -------------------------------------------------------------------------------- /0x08-recursion/1-print_rev_recursion.c: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | #include 3 | 4 | /** 5 | * _print_rev_recursion - function that prints a string in reverse. 6 | * @s: pointer to the string to be reversed. 7 | * 8 | * Return: no return. 9 | */ 10 | 11 | void _print_rev_recursion(char *s) 12 | { 13 | if (*s) 14 | { 15 | _print_rev_recursion(s + 1); 16 | _putchar(*s); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /0x0E-structures_typedef/0-main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "dog.h" 3 | 4 | /** 5 | * main - check the code 6 | * 7 | * Return: Always 0. 8 | */ 9 | int main(void) 10 | { 11 | struct dog my_dog; 12 | 13 | my_dog.name = "Poppy"; 14 | my_dog.age = 3.5; 15 | my_dog.owner = "Bob"; 16 | printf("My name is %s, and I am %.1f :) - Woof!\n", my_dog.name, my_dog.age); 17 | return (0); 18 | } 19 | -------------------------------------------------------------------------------- /0x12-singly_linked_lists/100-first.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "lists.h" 4 | 5 | /** 6 | * before_main - funcion that prints a specific string before the main, 7 | * function in executed. 8 | * 9 | * Return: no return. 10 | */ 11 | 12 | 13 | void before_main(void) 14 | { 15 | printf("You're beat! and yet, you must allow,\n"); 16 | printf("I bore my house upon my back!\n"); 17 | } 18 | -------------------------------------------------------------------------------- /0x01-variables_if_else_while/5-print_numbers.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | /** 5 | * main - Program that prints all single digit numbers of base 10 starting, 6 | * from 0, followed by a new line. 7 | * 8 | * Return: 0 9 | */ 10 | 11 | int main(void) 12 | { 13 | int i; 14 | 15 | for (i = 0; i <= 9; i++) 16 | printf("%i", i); 17 | printf("\n"); 18 | 19 | return (0); 20 | } 21 | -------------------------------------------------------------------------------- /0x02-functions_nested_loops/6-main.c: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | #include 3 | 4 | /** 5 | * main - check the code 6 | * 7 | * Return: Always 0. 8 | */ 9 | int main(void) 10 | { 11 | int r; 12 | 13 | r = _abs(-1); 14 | printf("%d\n", r); 15 | r = _abs(0); 16 | printf("%d\n", r); 17 | r = _abs(1); 18 | printf("%d\n", r); 19 | r = _abs(-98); 20 | printf("%d\n", r); 21 | return (0); 22 | } 23 | -------------------------------------------------------------------------------- /0x06-pointers_arrays_strings/3-strcmp.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "main.h" 4 | 5 | /** 6 | * _strcmp - function that compares two strings. 7 | * @s1: pointer to null-terminated first string. 8 | * @s2: pointer to null-terminated second string. 9 | * 10 | * Return: 0 (Success) 11 | */ 12 | 13 | int _strcmp(char *s1, char *s2) 14 | { 15 | return (strcmp(s1, s2)); 16 | } 17 | -------------------------------------------------------------------------------- /0x0B-malloc_free/100-main.c: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | #include 3 | #include 4 | 5 | /** 6 | * main - check the code for ALX School students. 7 | * 8 | * Return: Always 0. 9 | */ 10 | int main(int ac, char *av[]) 11 | { 12 | char *s; 13 | 14 | s = argstostr(ac, av); 15 | if (s == NULL) 16 | { 17 | return (1); 18 | } 19 | printf("%s", s); 20 | free(s); 21 | return (0); 22 | } 23 | -------------------------------------------------------------------------------- /0x02-functions_nested_loops/main.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | int _putchar(char); 4 | void print_alphabet(void); 5 | void print_alphabet_x10(void); 6 | int _islower(int c); 7 | int _isalpha(int c); 8 | int print_sign(int n); 9 | int _abs(int); 10 | int print_last_digit(int); 11 | void jack_bauer(void); 12 | void times_table(void); 13 | int add(int, int); 14 | void print_to_98(int n); 15 | void print_times_table(int n); -------------------------------------------------------------------------------- /0x04-more_functions_nested_loops/main.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | int _putchar(char c); 4 | int _isupper(int c); 5 | int _isdigit(int c); 6 | int mul(int a, int b); 7 | void print_numbers(void); 8 | void print_most_numbers(void); 9 | void more_numbers(void); 10 | void print_line(int n); 11 | void print_diagonal(int n); 12 | void print_square(int size); 13 | void print_triangle(int size); 14 | void print_number(int n); -------------------------------------------------------------------------------- /0x08-recursion/2-strlen_recursion.c: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | #include 3 | 4 | /** 5 | *_strlen_recursion - function that returns the length of a string. 6 | * @s: pointer to the null-terminated byte string to be examined. 7 | * 8 | * Return: length of the string. 9 | */ 10 | 11 | int _strlen_recursion(char *s) 12 | { 13 | if (*s) 14 | return (1 + _strlen_recursion(s + 1)); 15 | return (0); 16 | } 17 | -------------------------------------------------------------------------------- /0x08-recursion/3-main.c: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | #include 3 | 4 | /** 5 | * main - check the code 6 | * 7 | * Return: Always 0. 8 | */ 9 | int main(void) 10 | { 11 | int r; 12 | 13 | r = factorial(1); 14 | printf("%d\n", r); 15 | r = factorial(5); 16 | printf("%d\n", r); 17 | r = factorial(10); 18 | printf("%d\n", r); 19 | r = factorial(-1024); 20 | printf("%d\n", r); 21 | return (0); 22 | } 23 | -------------------------------------------------------------------------------- /0x06-pointers_arrays_strings/101-main.c: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | 3 | /** 4 | * main - check the code 5 | * 6 | * Return: Always 0. 7 | */ 8 | int main(void) 9 | { 10 | print_number(98); 11 | _putchar('\n'); 12 | print_number(402); 13 | _putchar('\n'); 14 | print_number(1024); 15 | _putchar('\n'); 16 | print_number(0); 17 | _putchar('\n'); 18 | print_number(-98); 19 | _putchar('\n'); 20 | return (0); 21 | } 22 | -------------------------------------------------------------------------------- /0x08-recursion/0-puts_recursion.c: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | #include 3 | 4 | /** 5 | * _puts_recursion - function that prints a string, followed by a new line. 6 | * @s: pointer to string to be printed. 7 | * 8 | * Return: no return. 9 | */ 10 | 11 | void _puts_recursion(char *s) 12 | { 13 | if (*s) 14 | { 15 | _putchar(*s); 16 | _puts_recursion(s + 1); 17 | } 18 | else 19 | _putchar('\n'); 20 | } 21 | -------------------------------------------------------------------------------- /0x0A-argc_argv/2-args.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "main.h" 3 | 4 | /** 5 | * main - program that prints the name of the program. 6 | * @argc: number of arguments passed to the function. 7 | * @argv: argument vector of pointers to strings. 8 | * 9 | * Return: 0 (Success) 10 | */ 11 | 12 | int main(int argc, char *argv[]) 13 | { 14 | while (argc--) 15 | printf("%s\n", *argv++); 16 | return (0); 17 | } 18 | -------------------------------------------------------------------------------- /0x02-functions_nested_loops/4-main.c: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | 3 | /** 4 | * main - check the code. 5 | * 6 | * Return: Always 0. 7 | */ 8 | int main(void) 9 | { 10 | int r; 11 | 12 | r = _isalpha('H'); 13 | _putchar(r + '0'); 14 | r = _isalpha('o'); 15 | _putchar(r + '0'); 16 | r = _isalpha(108); 17 | _putchar(r + '0'); 18 | r = _isalpha(';'); 19 | _putchar(r + '0'); 20 | _putchar('\n'); 21 | return (0); 22 | } 23 | -------------------------------------------------------------------------------- /0x04-more_functions_nested_loops/101-main.c: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | 3 | /** 4 | * main - check the code 5 | * 6 | * Return: Always 0. 7 | */ 8 | int main(void) 9 | { 10 | print_number(98); 11 | _putchar('\n'); 12 | print_number(402); 13 | _putchar('\n'); 14 | print_number(1024); 15 | _putchar('\n'); 16 | print_number(0); 17 | _putchar('\n'); 18 | print_number(-98); 19 | _putchar('\n'); 20 | return (0); 21 | } 22 | -------------------------------------------------------------------------------- /0x04-more_functions_nested_loops/3-print_numbers.c: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | 3 | /** 4 | * print_numbers - Function tha prints numbers between 0 to 9, 5 | * followed by a new line. 6 | * 7 | * You can only use _putchar twice in your code. 8 | * 9 | * Return: no return. 10 | */ 11 | 12 | void print_numbers(void) 13 | { 14 | int ch; 15 | 16 | for (ch = 48; ch < 58; ch++) 17 | _putchar(ch); 18 | _putchar('\n'); 19 | } 20 | -------------------------------------------------------------------------------- /0x05-pointers_arrays_strings/string_length.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | 4 | /** 5 | * rev_string - function that reverses a string 6 | * string_length - function that reverses a string 7 | * @s: string to be reversed 8 | * Return: 0 string in reversed 9 | */ 10 | 11 | int string_length(char *s) 12 | { 13 | int length = 0; 14 | 15 | while (*(s + length) != '\0') 16 | length++; 17 | 18 | return (length); 19 | } 20 | -------------------------------------------------------------------------------- /0x14-bit_manipulation/3-main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "main.h" 3 | 4 | /** 5 | * main - check the code 6 | * 7 | * Return: Always 0. 8 | */ 9 | int main(void) 10 | { 11 | unsigned long int n; 12 | 13 | n = 1024; 14 | set_bit(&n, 5); 15 | printf("%lu\n", n); 16 | n = 0; 17 | set_bit(&n, 10); 18 | printf("%lu\n", n); 19 | n = 98; 20 | set_bit(&n, 0); 21 | printf("%lu\n", n); 22 | return (0); 23 | } 24 | -------------------------------------------------------------------------------- /0x1E-search_algorithms/search_algos.h: -------------------------------------------------------------------------------- 1 | #ifndef _search_algos_ 2 | #define _search_algos_ 3 | 4 | #include 5 | #include 6 | 7 | int linear_search(int *array, size_t size, int value); 8 | int binary_search(int *array, size_t size, int value); 9 | void print_array(int *array, size_t l, size_t r); 10 | int binary_search_index(int *array, size_t l, size_t r, int value); 11 | 12 | #endif /* _search_algos_ */ 13 | -------------------------------------------------------------------------------- /0x01-variables_if_else_while/2-print_alphabet.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | /** 5 | * main - Entry point 6 | * Description: prints all alphabet in lower case 7 | * Return: 0 8 | */ 9 | 10 | int main(void) 11 | { 12 | int x; 13 | int lower_x; 14 | 15 | for (x = 'A'; x <= 'Z'; x++) 16 | { 17 | lower_x = tolower(x); 18 | putchar(lower_x); 19 | } 20 | putchar('\n'); 21 | 22 | return (0); 23 | } 24 | -------------------------------------------------------------------------------- /0x02-functions_nested_loops/3-islower.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "main.h" 4 | 5 | /** 6 | * _islower - Function that checks for lowercase character. 7 | * @c: character to classify. 8 | * 9 | * Return: 1 if c is lowercase or otherwise 0. 10 | * 11 | */ 12 | 13 | int _islower(int c) 14 | { 15 | if islower(c) 16 | { 17 | return (1); 18 | } 19 | else 20 | { 21 | return (0); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /0x0A-argc_argv/1-args.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "main.h" 3 | 4 | /** 5 | * main - program that prints the number of args passed to it. 6 | * @argc: number of arguments passed to the function. 7 | * @argv: argument vector of pointers to strings. 8 | * 9 | * Return: 0 (Success) 10 | */ 11 | 12 | int main(int argc, char *argv[]__attribute__((unused))) 13 | { 14 | printf("%d\n", argc - 1); 15 | return (0); 16 | } 17 | -------------------------------------------------------------------------------- /0x14-bit_manipulation/4-main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "main.h" 3 | 4 | /** 5 | * main - check the code 6 | * 7 | * Return: Always 0. 8 | */ 9 | int main(void) 10 | { 11 | unsigned long int n; 12 | 13 | n = 1024; 14 | clear_bit(&n, 10); 15 | printf("%lu\n", n); 16 | n = 0; 17 | clear_bit(&n, 10); 18 | printf("%lu\n", n); 19 | n = 98; 20 | clear_bit(&n, 1); 21 | printf("%lu\n", n); 22 | return (0); 23 | } 24 | -------------------------------------------------------------------------------- /0x15-file_io/1-main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "main.h" 4 | 5 | /** 6 | * main - check the code 7 | * 8 | * Return: Always 0. 9 | */ 10 | int main(int ac, char **av) 11 | { 12 | int res; 13 | 14 | if (ac != 3) 15 | { 16 | dprintf(2, "Usage: %s filename text\n", av[0]); 17 | exit(1); 18 | } 19 | res = create_file(av[1], av[2]); 20 | printf("-> %i)\n", res); 21 | return (0); 22 | } 23 | -------------------------------------------------------------------------------- /0x0B-malloc_free/2-main.c: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | #include 3 | #include 4 | 5 | /** 6 | * main - check the code for ALX School students. 7 | * 8 | * Return: Always 0. 9 | */ 10 | int main(void) 11 | { 12 | char *s; 13 | 14 | s = str_concat("Betty ", "Holberton"); 15 | if (s == NULL) 16 | { 17 | printf("failed\n"); 18 | return (1); 19 | } 20 | printf("%s\n", s); 21 | free(s); 22 | return (0); 23 | } 24 | -------------------------------------------------------------------------------- /0x14-bit_manipulation/1-main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "main.h" 3 | 4 | /** 5 | * main - check the code 6 | * 7 | * Return: Always 0. 8 | */ 9 | int main(void) 10 | { 11 | print_binary(0); 12 | printf("\n"); 13 | print_binary(1); 14 | printf("\n"); 15 | print_binary(98); 16 | printf("\n"); 17 | print_binary(1024); 18 | printf("\n"); 19 | print_binary((1 << 10) + 1); 20 | printf("\n"); 21 | return (0); 22 | } 23 | -------------------------------------------------------------------------------- /0x15-file_io/2-main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "main.h" 4 | 5 | /** 6 | * main - check the code 7 | * 8 | * Return: Always 0. 9 | */ 10 | int main(int ac, char **av) 11 | { 12 | int res; 13 | 14 | if (ac != 3) 15 | { 16 | dprintf(2, "Usage: %s filename text\n", av[0]); 17 | exit(1); 18 | } 19 | res = append_text_to_file(av[1], av[2]); 20 | printf("-> %i)\n", res); 21 | return (0); 22 | } 23 | -------------------------------------------------------------------------------- /0x02-functions_nested_loops/4-isalpha.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "main.h" 4 | 5 | /** 6 | * _isalpha - Function that checks for alphabetic character. 7 | * @c: character to classify. 8 | * 9 | * Return: 1 if c is a letter, lowercase or uppercase else 0. 10 | */ 11 | 12 | int _isalpha(int c) 13 | { 14 | if isalpha(c) 15 | { 16 | return (1); 17 | } 18 | else 19 | { 20 | return (0); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /0x06-pointers_arrays_strings/0-strcat.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | /** 5 | * _strcat - Function that concatenates two strings. 6 | * @dest: Pointer to the null-terminated byte string to append to. 7 | * @src: Pointer to the null-terminated byte string to copy from. 8 | * 9 | * Return: A pointer to the dest. 10 | */ 11 | 12 | char *_strcat(char *dest, char *src) 13 | { 14 | return (strcat(dest, src)); 15 | } 16 | -------------------------------------------------------------------------------- /0x0B-malloc_free/1-main.c: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | #include 3 | #include 4 | 5 | /** 6 | * main - check the code for ALX School students. 7 | * 8 | * Return: Always 0. 9 | */ 10 | int main(void) 11 | { 12 | char *s; 13 | 14 | s = _strdup("Holberton"); 15 | if (s == NULL) 16 | { 17 | printf("failed to allocate memory\n"); 18 | return (1); 19 | } 20 | printf("%s\n", s); 21 | free(s); 22 | return (0); 23 | } 24 | -------------------------------------------------------------------------------- /0x0B-malloc_free/main.h: -------------------------------------------------------------------------------- 1 | #ifndef MAIH_H 2 | #define MAIN_H 3 | 4 | int _putchar(char c); 5 | char *create_array(unsigned int size, char c); 6 | char *_strdup(char *str); 7 | char *str_concat(char *s1, char *s2); 8 | int **alloc_grid(int width, int height); 9 | void free_grid(int **grid, int height); 10 | char *argstostr(int ac, char **av); 11 | void ch_free_grid(char **grid, unsigned int height); 12 | char **strtow(char *str); 13 | 14 | #endif -------------------------------------------------------------------------------- /0x05-pointers_arrays_strings/3-puts.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "main.h" 3 | 4 | /** 5 | * _puts - Function that prints a string followed by a new line to the stdout. 6 | * @str: pointer to the string to be written. 7 | * 8 | * Return: No return. 9 | */ 10 | 11 | void _puts(char *str) 12 | { 13 | int len = 0; 14 | 15 | while (str[len] != '\0') 16 | { 17 | putchar(str[len]); 18 | len++; 19 | } 20 | putchar('\n'); 21 | } 22 | -------------------------------------------------------------------------------- /0x06-pointers_arrays_strings/0-main.c: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | #include 3 | 4 | /** 5 | * main - check the code 6 | * 7 | * Return: Always 0. 8 | */ 9 | int main(void) 10 | { 11 | char s1[98] = "Hello "; 12 | char s2[] = "World!\n"; 13 | char *ptr; 14 | 15 | printf("%s\n", s1); 16 | printf("%s", s2); 17 | ptr = _strcat(s1, s2); 18 | printf("%s", s1); 19 | printf("%s", s2); 20 | printf("%s", ptr); 21 | return (0); 22 | } 23 | -------------------------------------------------------------------------------- /0x08-recursion/3-factorial.c: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | #include 3 | 4 | /** 5 | * factorial - function that returns the factorial of a given number. 6 | * @n: pointer to the null-terminated byte string to be examined. 7 | * 8 | * Return: -1 if n is lower than 0 and 1 if n is 0. 9 | */ 10 | 11 | int factorial(int n) 12 | { 13 | if (n < 0) 14 | return (-1); 15 | if (n <= 1) 16 | return (1); 17 | return (n * factorial(n - 1)); 18 | } 19 | -------------------------------------------------------------------------------- /0x14-bit_manipulation/5-main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "main.h" 3 | 4 | /** 5 | * main - check the code 6 | * 7 | * Return: Always 0. 8 | */ 9 | int main(void) 10 | { 11 | unsigned int n; 12 | 13 | n = flip_bits(1024, 1); 14 | printf("%u\n", n); 15 | n = flip_bits(402, 98); 16 | printf("%u\n", n); 17 | n = flip_bits(1024, 3); 18 | printf("%u\n", n); 19 | n = flip_bits(1024, 1025); 20 | printf("%u\n", n); 21 | return (0); 22 | } 23 | -------------------------------------------------------------------------------- /0x05-pointers_arrays_strings/main.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | void reset_to_98(int *n); 4 | void swap_int(int *a, int *b); 5 | int _strlen(char *s); 6 | void _puts(char *str); 7 | void print_rev(char *s); 8 | void rev_string(char *s); 9 | void puts2(char *str); 10 | void puts_half(char *str); 11 | void print_array(int *a, int n); 12 | char *_strcpy(char *dest, char *src); 13 | int _atoi(char *s); 14 | int string_length(char*); 15 | void randomPasswordGeneration(int N); -------------------------------------------------------------------------------- /0x08-recursion/100-main.c: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | #include 3 | 4 | /** 5 | * main - check the code 6 | * 7 | * Return: Always 0. 8 | */ 9 | int main(void) 10 | { 11 | int r; 12 | 13 | r = is_palindrome("level"); 14 | printf("%d\n", r); 15 | r = is_palindrome("redder"); 16 | printf("%d\n", r); 17 | r = is_palindrome("test"); 18 | printf("%d\n", r); 19 | r = is_palindrome("step on no pets"); 20 | printf("%d\n", r); 21 | return (0); 22 | } 23 | -------------------------------------------------------------------------------- /0x0A-argc_argv/0-whatsmyname.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "main.h" 3 | 4 | /** 5 | * main - program that prints the name of the program. 6 | * @argc: number of arguments passed to the function. 7 | * @argv: argument vector of pointers to strings. 8 | * 9 | * Return: 0 (Success) 10 | */ 11 | 12 | int main(int argc __attribute__((unused)), char *argv[]) 13 | { 14 | printf("%s\n", argv[0]); /* or printf("%s\n", *argv); */ 15 | return (0); 16 | } 17 | -------------------------------------------------------------------------------- /0x18-dynamic_libraries/100-tests.py: -------------------------------------------------------------------------------- 1 | import random 2 | import ctypes 3 | 4 | cops = ctypes.CDLL('./100-operations.so') 5 | a = random.randint(-111, 111) 6 | b = random.randint(-111, 111) 7 | print("{} + {} = {}".format(a, b, cops.add(a, b))) 8 | print("{} - {} = {}".format(a, b, cops.sub(a, b))) 9 | print("{} x {} = {}".format(a, b, cops.mul(a, b))) 10 | print("{} / {} = {}".format(a, b, cops.div(a, b))) 11 | print("{} % {} = {}".format(a, b, cops.mod(a, b))) 12 | -------------------------------------------------------------------------------- /0x05-pointers_arrays_strings/2-strlen.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "main.h" 3 | #include 4 | 5 | /** 6 | * _strlen - Function that returns the length of string. 7 | * @s: pointer to the null-terminated byte string to be examined. 8 | * 9 | * Return: The length of the null-terminated byte string s. 10 | */ 11 | 12 | int _strlen(char *s) 13 | { 14 | int len = 0; 15 | 16 | while (s[len] != '\0') 17 | len++; 18 | 19 | return (len); 20 | } 21 | -------------------------------------------------------------------------------- /0x00-hello_world/5-printf.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | /** 4 | * main - Entry point 5 | * 6 | * Use the function printf. 7 | * You are not allowed to use the function puts. 8 | * Your program should return 0. 9 | * Your program should compile without warning when using the -Wall, 10 | * gcc option. 11 | * 12 | * Return: 0 13 | */ 14 | 15 | int main(void) 16 | { 17 | printf("with proper grammar, but the outcome is a piece of art,\n"); 18 | return (0); 19 | } 20 | -------------------------------------------------------------------------------- /0x06-pointers_arrays_strings/6-main.c: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | #include 3 | 4 | /** 5 | * main - check the code 6 | * 7 | * Return: Always 0. 8 | */ 9 | int main(void) 10 | { 11 | char str[] = "Expect the best. Prepare for the worst. Capitalize on what comes.\nhello world! hello-world 0123456hello world\thello world.hello world\n"; 12 | char *ptr; 13 | 14 | ptr = cap_string(str); 15 | printf("%s", ptr); 16 | printf("%s", str); 17 | return (0); 18 | } 19 | -------------------------------------------------------------------------------- /0x07-pointers_arrays_strings/7-print_chessboard.c: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | #include 3 | 4 | /** 5 | * print_chessboard - function that prints the chess board. 6 | * @a: pointer to array of characters. 7 | * 8 | * Return: no return. 9 | */ 10 | 11 | void print_chessboard(char (*a)[8]) 12 | { 13 | unsigned int i, j; 14 | 15 | for (i = 0; i < 8; i++) 16 | { 17 | for (j = 0; j < 8; j++) 18 | _putchar(a[i][j]); 19 | 20 | _putchar('\n'); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /0x15-file_io/.vscode/c_cpp_properties.json: -------------------------------------------------------------------------------- 1 | { 2 | "configurations": [ 3 | { 4 | "name": "Linux", 5 | "includePath": [ 6 | "${workspaceFolder}/**" 7 | ], 8 | "defines": [], 9 | "compilerPath": "/usr/bin/gcc", 10 | "cStandard": "gnu17", 11 | "cppStandard": "c++17", 12 | "intelliSenseMode": "linux-gcc-x64" 13 | } 14 | ], 15 | "version": 4 16 | } -------------------------------------------------------------------------------- /0x02-functions_nested_loops/7-print_last_digit.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "main.h" 4 | 5 | /** 6 | * print_last_digit- A fucntion that prints last digit of a number. 7 | * @n: integer number. 8 | * 9 | * Return: value of last digit. 10 | */ 11 | 12 | int print_last_digit(int n) 13 | { 14 | int num; 15 | 16 | if (n < 0) 17 | num = -1 * (n % 10); 18 | else 19 | num = n % 10; 20 | 21 | _putchar(num + '0'); 22 | return (num); 23 | } 24 | -------------------------------------------------------------------------------- /0x06-pointers_arrays_strings/2-strncpy.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "main.h" 4 | 5 | /** 6 | * _strncpy - function that copies a string. 7 | * @dest: pointer to character array to copy to. 8 | * @src: pointer to character array to copy from. 9 | * @n: maximum number of characters to copy. 10 | * 11 | * Return: A copy of dest. 12 | */ 13 | 14 | char *_strncpy(char *dest, char *src, int n) 15 | { 16 | return (strncpy(dest, src, n)); 17 | } 18 | -------------------------------------------------------------------------------- /0x08-recursion/.vscode/c_cpp_properties.json: -------------------------------------------------------------------------------- 1 | { 2 | "configurations": [ 3 | { 4 | "name": "Linux", 5 | "includePath": [ 6 | "${workspaceFolder}/**" 7 | ], 8 | "defines": [], 9 | "compilerPath": "/usr/bin/gcc", 10 | "cStandard": "gnu17", 11 | "cppStandard": "gnu++14", 12 | "intelliSenseMode": "linux-gcc-x64" 13 | } 14 | ], 15 | "version": 4 16 | } -------------------------------------------------------------------------------- /0x12-singly_linked_lists/1-list_len.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "lists.h" 4 | 5 | 6 | /** 7 | * list_len - function that returns the number of elements in a linked list. 8 | * @h: pointer to singlt link list. 9 | * 10 | * Return: number of elements. * 11 | */ 12 | 13 | size_t list_len(const list_t *h) 14 | { 15 | size_t count = 0; 16 | 17 | while (h != NULL) 18 | { 19 | h = h->next; 20 | count++; 21 | } 22 | return (count); 23 | } 24 | -------------------------------------------------------------------------------- /0x10-variadic_functions/variadic_functions.h: -------------------------------------------------------------------------------- 1 | #ifndef _VARIADIC_FUNCTIONS_H_ 2 | #define _VARIADIC_FUNCTIONS_H_ 3 | 4 | #include 5 | #include 6 | 7 | int _putchar(char c); 8 | int sum_them_all(const unsigned int n, ...); 9 | void print_numbers(const char *separator, const unsigned int n, ...); 10 | void print_strings(const char *separator, const unsigned int n, ...); 11 | void print_all(const char * const format, ...); 12 | 13 | #endif /* _VARIADIC_FUNCTIONS_H_ */ 14 | -------------------------------------------------------------------------------- /0x1A-hash_tables/1-djb2.c: -------------------------------------------------------------------------------- 1 | #include "hash_tables.h" 2 | 3 | /** 4 | * hash_djb2 - hash function to implement djb2 algorithm. 5 | * @str: pointer to null-terminated byte string to be examined. 6 | * 7 | * Return: The new hash. 8 | */ 9 | unsigned long int hash_djb2(const unsigned char *str) 10 | { 11 | unsigned long int hash; 12 | int c; 13 | 14 | hash = 5381; 15 | while ((c = *str++)) 16 | { 17 | hash = ((hash << 5) + hash) + c; /* hash * 33 + c */ 18 | } 19 | return (hash); 20 | } 21 | -------------------------------------------------------------------------------- /0x06-pointers_arrays_strings/1-strncat.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "main.h" 4 | 5 | /** 6 | * _strncat - function that concatenates two strings 7 | * @dest: pointer to the null-terminated byte string to append to. 8 | * @src: pointer to the character array to copy from. 9 | * @n: maximum number of characters to copy. 10 | * 11 | * Return: pointer to dest. 12 | */ 13 | 14 | char *_strncat(char *dest, char *src, int n) 15 | { 16 | return (strncat(dest, src, n)); 17 | } 18 | -------------------------------------------------------------------------------- /0x17-doubly_linked_lists/1-dlistint_len.c: -------------------------------------------------------------------------------- 1 | #include "lists.h" 2 | 3 | /** 4 | * dlistint_len - function that returns the number of elements in a, 5 | * linked dlistint_t list. 6 | * @h: poiner to the head of the list 7 | * 8 | * Return: number of elements 9 | */ 10 | 11 | size_t dlistint_len(const dlistint_t *h) 12 | { 13 | size_t count = 0; 14 | 15 | /* while we have a pointer to the list */ 16 | while (h != NULL) 17 | { 18 | count++; 19 | h = h->next; 20 | } 21 | return (count); 22 | } 23 | -------------------------------------------------------------------------------- /0x02-functions_nested_loops/1-alphabet.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "main.h" 3 | 4 | /** 5 | * print_alphabet - Function that prints the alphabet, in lowercase, 6 | * followed by a new line. 7 | * 8 | * You can only use _putchar twice in your code. 9 | * 10 | * Return: 0. 11 | */ 12 | 13 | void print_alphabet(void) 14 | { 15 | 16 | int x; 17 | int lower_x; 18 | 19 | for (x = 'A'; x <= 'Z'; x++) 20 | { 21 | lower_x = tolower(x); 22 | _putchar(lower_x); 23 | } 24 | _putchar('\n'); 25 | } 26 | -------------------------------------------------------------------------------- /0x17-doubly_linked_lists/0-print_dlistint.c: -------------------------------------------------------------------------------- 1 | #include "lists.h" 2 | 3 | /** 4 | * print_dlistint - function that prints all the elemts of a doubly linked list 5 | * @h: poiner to the head of the list 6 | * 7 | * Return: number of nodes 8 | */ 9 | 10 | size_t print_dlistint(const dlistint_t *h) 11 | { 12 | size_t count = 0; 13 | 14 | /* while we have a pointer to the list */ 15 | while (h != NULL) 16 | { 17 | printf("%d\n", h->n); 18 | count++; 19 | h = h->next; 20 | } 21 | return (count); 22 | } 23 | -------------------------------------------------------------------------------- /0x17-doubly_linked_lists/4-free_dlistint.c: -------------------------------------------------------------------------------- 1 | #include "lists.h" 2 | 3 | /** 4 | * free_dlistint - function that frees a dbly, 5 | * linked list. 6 | * @head: pointer to head of list. 7 | * 8 | * Return: No return. 9 | */ 10 | 11 | void free_dlistint(dlistint_t *head) 12 | { 13 | /* check if head is NULL and return if so */ 14 | while (head != NULL) 15 | { 16 | /* traverse the list freeing each node */ 17 | dlistint_t *next = head->next; 18 | 19 | free(head); 20 | 21 | head = next; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /0x04-more_functions_nested_loops/4-print_most_numbers.c: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | 3 | /** 4 | * print_most_numbers - Function tha prints numbers between 0 to 9, 5 | * followed by a new line. 6 | * 7 | * Do not print 2 and 4. 8 | * You can only use _putchar twice in your code. 9 | * 10 | * Return: no return. 11 | */ 12 | 13 | void print_most_numbers(void) 14 | { 15 | 16 | int i; 17 | 18 | for (i = 0; i <= 9; i++) 19 | { 20 | if (i != 2 && i != 4) 21 | _putchar('0' + i); 22 | } 23 | _putchar('\n'); 24 | } 25 | -------------------------------------------------------------------------------- /0x08-recursion/4-pow_recursion.c: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | #include 3 | 4 | /** 5 | * _pow_recursion - function that returns the value of x 6 | * raised to the power of y. 7 | * @x: base value. 8 | * @y: exponent value. 9 | * 10 | * Return: x raised to the power of y or -1 if y < 0. 11 | */ 12 | 13 | int _pow_recursion(int x, int y) 14 | { 15 | if (y == 0) 16 | return (1); 17 | if (y < 0) 18 | return (-1); 19 | 20 | /* for all other cases */ 21 | return (x * _pow_recursion(x, y - 1)); 22 | } 23 | -------------------------------------------------------------------------------- /0x15-file_io/0-main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "main.h" 4 | 5 | /** 6 | * main - check the code 7 | * 8 | * Return: Always 0. 9 | */ 10 | int main(int ac, char **av) 11 | { 12 | ssize_t n; 13 | 14 | if (ac != 2) 15 | { 16 | dprintf(2, "Usage: %s filename\n", av[0]); 17 | exit(1); 18 | } 19 | n = read_textfile(av[1], 114); 20 | printf("\n(printed chars: %li)\n", n); 21 | n = read_textfile(av[1], 1024); 22 | printf("\n(printed chars: %li)\n", n); 23 | return (0); 24 | } 25 | -------------------------------------------------------------------------------- /0x15-file_io/main.h: -------------------------------------------------------------------------------- 1 | #ifndef _MAIN_H_ 2 | #define _MAIN_H_ 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | int _putchar(char c); 10 | ssize_t read_textfile(const char *filename, size_t letters); 11 | int create_file(const char *filename, char *text_content); 12 | int _strlen(const char *s); 13 | int append_text_to_file(const char *filename, char *text_content); 14 | char *create_buffer(char *file); 15 | void close_file(int fd); 16 | 17 | #endif /* _MAIN_H_ */ 18 | -------------------------------------------------------------------------------- /0x06-pointers_arrays_strings/104-main.c: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | #include 3 | 4 | /** 5 | * main - check the code 6 | * 7 | * Return: Always 0. 8 | */ 9 | int main(void) 10 | { 11 | char buffer[] = "This is a string!\0And this is the rest of the #buffer :)\1\2\3\4\5\6\7#cisfun\n\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x20\x21\x34\x56#pointersarefun #infernumisfun\n"; 12 | 13 | printf("%s\n", buffer); 14 | printf("---------------------------------\n"); 15 | print_buffer(buffer, sizeof(buffer)); 16 | return (0); 17 | } -------------------------------------------------------------------------------- /0x06-pointers_arrays_strings/4-rev_array.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "main.h" 4 | 5 | /** 6 | * reverse_array - function that reverses an array. 7 | * @a: pointer to the array to reverse. 8 | * @n: size of elements in the array. 9 | * 10 | * Return: No return. 11 | */ 12 | 13 | void reverse_array(int *a, int n) 14 | { 15 | int i, temp; 16 | 17 | i = temp = 0; 18 | n -= 1; 19 | 20 | while (i <= n) 21 | { 22 | temp = a[n]; 23 | a[n--] = a[i]; 24 | a[i++] = temp; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /0x08-recursion/main.h: -------------------------------------------------------------------------------- 1 | #ifndef MAIH_H 2 | #define MAIN_H 3 | 4 | int _putchar(char c); 5 | void _puts_recursion(char *s); 6 | void _print_rev_recursion(char *s); 7 | int _strlen_recursion(char *s); 8 | int factorial(int n); 9 | int _pow_recursion(int x, int y); 10 | int _sqr_root(int n, int j); 11 | int _sqrt_recursion(int n); 12 | int is_divisible(int num, int div); 13 | int is_prime_number(int n); 14 | int checker(char *s, int length, int a); 15 | int is_palindrome(char *s); 16 | int wildcmp(char *s1, char *s2); 17 | 18 | #endif -------------------------------------------------------------------------------- /0x0C-more_malloc_free/main.h: -------------------------------------------------------------------------------- 1 | #ifndef _MAIH_H_ 2 | #define _MAIH_H_ 3 | 4 | #include 5 | #include 6 | 7 | int _putchar(char c); 8 | void *malloc_checked(unsigned int b); 9 | char *string_nconcat(char *s1, char *s2, unsigned int n); 10 | void *_calloc(unsigned int nmemb, unsigned int size); 11 | int *array_range(int min, int max); 12 | void *_realloc(void *ptr, unsigned int old_size, unsigned int new_size); 13 | void errors(void); 14 | int _strlen(char *str); 15 | int is_digit(char *str); 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /0x05-pointers_arrays_strings/4-print_rev.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "main.h" 4 | 5 | /** 6 | * print_rev - function that prints a string in reverse followed by a new line. 7 | * @s: Pointer to the string to be reversed. 8 | * 9 | * Return: No return. 10 | */ 11 | 12 | void print_rev(char *s) 13 | { 14 | 15 | int len; 16 | 17 | for (len = 0; s[len] != '\0'; len++) 18 | {} 19 | 20 | for (len = len - 1; len >= 0; len--) 21 | { 22 | putchar(s[len]); 23 | } 24 | 25 | putchar('\n'); 26 | } 27 | -------------------------------------------------------------------------------- /0x07-pointers_arrays_strings/0-memset.c: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | #include 3 | 4 | /** 5 | * _memset - function that fills memory with a constant byte. 6 | * @s: pointer to the object to fill. 7 | * @b: fill byte. 8 | * @n: number of bytes to fill. 9 | * 10 | * Return: a pointer to the memory area s. 11 | */ 12 | 13 | char *_memset(char *s, char b, unsigned int n) 14 | { 15 | unsigned int i; 16 | 17 | i = 0; 18 | 19 | while (i < n) 20 | { 21 | *(s + i) = b; 22 | i++; 23 | } 24 | 25 | return (s); 26 | } 27 | -------------------------------------------------------------------------------- /0x0A-argc_argv/3-mul.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "main.h" 4 | 5 | /** 6 | * main - program that adds two numbers. 7 | * @argc: number of arguments passed to the function. 8 | * @argv: argument vector of pointers to strings. 9 | * 10 | * Return: 0 (Success) or 1 (Error) 11 | */ 12 | 13 | int main(int argc, char *argv[]) 14 | { 15 | if (argc != 3) 16 | { 17 | printf("Error\n"); 18 | return (1); 19 | } 20 | 21 | printf("%d\n", atoi(argv[1]) * atoi(argv[2])); 22 | 23 | return (0); 24 | } 25 | -------------------------------------------------------------------------------- /0x12-singly_linked_lists/4-main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "lists.h" 5 | 6 | /** 7 | * main - check the code 8 | * 9 | * Return: Always 0. 10 | */ 11 | int main(void) 12 | { 13 | list_t *head; 14 | 15 | head = NULL; 16 | add_node_end(&head, "Bob"); 17 | add_node_end(&head, "&"); 18 | add_node_end(&head, "Kris"); 19 | add_node_end(&head, "love"); 20 | add_node_end(&head, "asm"); 21 | print_list(head); 22 | free_list(head); 23 | head = NULL; 24 | return (0); 25 | } 26 | -------------------------------------------------------------------------------- /0x1A-hash_tables/1-main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "hash_tables.h" 5 | 6 | /** 7 | * main - check the code 8 | * 9 | * Return: Always EXIT_SUCCESS. 10 | */ 11 | int main(void) 12 | { 13 | char *s; 14 | 15 | s = "cisfun"; 16 | printf("%lu\n", hash_djb2((unsigned char *)s)); 17 | s = "Don't forget to tweet today"; 18 | printf("%lu\n", hash_djb2((unsigned char *)s)); 19 | s = "98"; 20 | printf("%lu\n", hash_djb2((unsigned char *)s)); 21 | return (EXIT_SUCCESS); 22 | } 23 | -------------------------------------------------------------------------------- /0x02-functions_nested_loops/101-natural.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | /** 4 | * main - Program that computes and prints the sum of all the multiples of, 5 | * 3 or 5 below 1024 (excluded), followed by a new line. 6 | * 7 | * You are allowed to use the standard library. 8 | * 9 | * Return: 0 if successful. 10 | */ 11 | 12 | int main(void) 13 | { 14 | int i, sum; 15 | 16 | for (i = 1; i < 1024; i++) 17 | { 18 | if ((i % 3) == 0 || (i % 5) == 0) 19 | sum += i; 20 | } 21 | printf("%d\n", sum); 22 | 23 | return (0); 24 | } 25 | -------------------------------------------------------------------------------- /0x03-debugging/3-main_a.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "main.h" 3 | 4 | /** 5 | * main - takes a date and prints how many days are left in the year, taking 6 | * leap years into account 7 | * Return: 0 8 | */ 9 | 10 | int main(void) 11 | { 12 | int month; 13 | int day; 14 | int year; 15 | 16 | month = 4; 17 | day = 01; 18 | year = 1997; 19 | 20 | printf("Date: %02d/%02d/%04d\n", month, day, year); 21 | 22 | day = convert_day(month, day); 23 | 24 | print_remaining_days(month, day, year); 25 | 26 | return (0); 27 | } 28 | -------------------------------------------------------------------------------- /0x03-debugging/3-main_b.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "main.h" 3 | 4 | /** 5 | * main - takes a date and prints how many days are left in the year, taking 6 | * leap years into account 7 | * Return: 0 8 | */ 9 | 10 | int main(void) 11 | { 12 | int month; 13 | int day; 14 | int year; 15 | 16 | month = 4; 17 | day = 01; 18 | year = 1997; 19 | 20 | printf("Date: %02d/%02d/%04d\n", month, day, year); 21 | 22 | day = convert_day(month, day); 23 | 24 | print_remaining_days(month, day, year); 25 | 26 | return (0); 27 | } 28 | -------------------------------------------------------------------------------- /0x14-bit_manipulation/100-get_endianness.c: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | 3 | /** 4 | * get_endianness - function that checks the endianness. 5 | * 6 | * Return: 0 if big endian, 1 if little endian. 7 | */ 8 | 9 | int get_endianness(void) 10 | { 11 | unsigned int n = 1; /* 00 00 00 01 */ 12 | char *c = (char *) &n; 13 | 14 | /** 15 | * if little endian, n will be stored in memory as 16 | * 01 00 00 00, so *c = 1 17 | */ 18 | if (*c) 19 | return (1); 20 | /* otherwise return 0 meaning it is big endian */ 21 | return (0); 22 | } 23 | -------------------------------------------------------------------------------- /0x03-debugging/2-largest_number.c: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | 3 | /** 4 | * largest_number - returns the largest of 3 numbers. 5 | * @a: first integer 6 | * @b: second integer 7 | * @c: third integer 8 | * 9 | * Return: largest number. 10 | */ 11 | 12 | int largest_number(int a, int b, int c) 13 | { 14 | int largest; 15 | 16 | if (a >= b && a >= c) 17 | { 18 | largest = a; 19 | } 20 | else if (b >= a && b >= c) 21 | { 22 | largest = b; 23 | } 24 | else 25 | { 26 | largest = c; 27 | } 28 | 29 | return (largest); 30 | } 31 | -------------------------------------------------------------------------------- /0x07-pointers_arrays_strings/1-memcpy.c: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | #include 3 | 4 | /** 5 | **_memcpy - function that copies memory area. 6 | * @dest: pointer to the object to copy to. 7 | * @src: pointer to the object to copy from. 8 | * @n: number of bytes to copy. 9 | * 10 | * Return: a pointer dest or 0 on success. 11 | */ 12 | 13 | char *_memcpy(char *dest, char *src, unsigned int n) 14 | { 15 | unsigned int i; 16 | 17 | for (i = 0; i < n; i++) 18 | { 19 | *(dest + i) = *(src + i); 20 | } 21 | return (dest); 22 | } 23 | -------------------------------------------------------------------------------- /0x13-more_singly_linked_lists/8-sum_listint.c: -------------------------------------------------------------------------------- 1 | #include "lists.h" 2 | #include 3 | 4 | /** 5 | * sum_listint - function that returns the sum of all the data (n) of a, 6 | * listint_t linked list. 7 | * @head: pointer to the head of linked list. 8 | * 9 | * Return: sum of all the data (n) of a linked list or 0 if list is empty. 10 | */ 11 | 12 | int sum_listint(listint_t *head) 13 | { 14 | int sum = 0; 15 | 16 | while (head != NULL) 17 | { 18 | sum += head->n; 19 | head = head->next; 20 | } 21 | return (sum); 22 | } 23 | -------------------------------------------------------------------------------- /0x00-hello_world/101-quote.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | /** 5 | * main - Entry point. 6 | * 7 | * You are not allowed to use any functions listed in the NAME section, 8 | * of the man (3) printf or man (3) puts. 9 | * Your program should return 1. 10 | * Your program should compile without any warnings when using the -Wall, 11 | * gcc option. 12 | * 13 | * Return: 0 14 | */ 15 | 16 | int main(void) 17 | { 18 | write(2, "and that piece of art is useful\" - Dora Korpar, 2015-10-19\n", 59); 19 | return (1); 20 | } 21 | -------------------------------------------------------------------------------- /0x08-recursion/5-main.c: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | #include 3 | 4 | /** 5 | * main - check the code 6 | * 7 | * Return: Always 0. 8 | */ 9 | int main(void) 10 | { 11 | int r; 12 | 13 | r = _sqrt_recursion(1); 14 | printf("%d\n", r); 15 | r = _sqrt_recursion(1024); 16 | printf("%d\n", r); 17 | r = _sqrt_recursion(16); 18 | printf("%d\n", r); 19 | r = _sqrt_recursion(17); 20 | printf("%d\n", r); 21 | r = _sqrt_recursion(25); 22 | printf("%d\n", r); 23 | r = _sqrt_recursion(-1); 24 | printf("%d\n", r); 25 | return (0); 26 | } 27 | -------------------------------------------------------------------------------- /0x0F-function_pointers/3-calc.h: -------------------------------------------------------------------------------- 1 | #ifndef _CALC_H_ 2 | #define _CALC_H_ 3 | 4 | #include 5 | #include 6 | 7 | /** 8 | * struct op - Struct op 9 | * 10 | * @op: The operator 11 | * @f: The function associated 12 | */ 13 | typedef struct op 14 | { 15 | char *op; 16 | int (*f)(int a, int b); 17 | } op_t; 18 | 19 | int op_add(int a, int b); 20 | int op_sub(int a, int b); 21 | int op_mul(int a, int b); 22 | int op_div(int a, int b); 23 | int op_mod(int a, int b); 24 | int (*get_op_func(char *s))(int, int); 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /0x14-bit_manipulation/0-main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "main.h" 3 | 4 | /** 5 | * main - check the code 6 | * 7 | * Return: Always 0. 8 | */ 9 | int main(void) 10 | { 11 | unsigned int n; 12 | 13 | n = binary_to_uint("1"); 14 | printf("%u\n", n); 15 | n = binary_to_uint("101"); 16 | printf("%u\n", n); 17 | n = binary_to_uint("1e01"); 18 | printf("%u\n", n); 19 | n = binary_to_uint("1100010"); 20 | printf("%u\n", n); 21 | n = binary_to_uint("0000000000000000000110010010"); 22 | printf("%u\n", n); 23 | return (0); 24 | } 25 | -------------------------------------------------------------------------------- /0x14-bit_manipulation/main.h: -------------------------------------------------------------------------------- 1 | #ifndef _MAIN_H_ 2 | #define _MAIN_H_ 3 | 4 | #include 5 | 6 | unsigned int binary_to_uint(const char *b); 7 | int _strlen(const char *s); 8 | void print_binary(unsigned long int n); 9 | int _putchar(char c); 10 | int get_bit(unsigned long int n, unsigned int index); 11 | int set_bit(unsigned long int *n, unsigned int index); 12 | int clear_bit(unsigned long int *n, unsigned int index); 13 | unsigned int flip_bits(unsigned long int n, unsigned long int m); 14 | int get_endianness(void); 15 | 16 | #endif 17 | -------------------------------------------------------------------------------- /0x06-pointers_arrays_strings/1-main.c: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | #include 3 | 4 | /** 5 | * main - check the code 6 | * 7 | * Return: Always 0. 8 | */ 9 | int main(void) 10 | { 11 | char s1[98] = "Hello "; 12 | char s2[] = "World!\n"; 13 | char *ptr; 14 | 15 | printf("%s\n", s1); 16 | printf("%s", s2); 17 | ptr = _strncat(s1, s2, 1); 18 | printf("%s\n", s1); 19 | printf("%s", s2); 20 | printf("%s\n", ptr); 21 | ptr = _strncat(s1, s2, 1024); 22 | printf("%s", s1); 23 | printf("%s", s2); 24 | printf("%s", ptr); 25 | return (0); 26 | } 27 | -------------------------------------------------------------------------------- /0x17-doubly_linked_lists/6-sum_dlistint.c: -------------------------------------------------------------------------------- 1 | #include "lists.h" 2 | 3 | /** 4 | * sum_dlistint - function that returns the sum of all the, 5 | * data (n) of a linked list. 6 | * @head: pointer to pointer to head of linked list. 7 | * 8 | * If the list is empty, return 0. 9 | * 10 | * Return: The sum. 11 | */ 12 | 13 | int sum_dlistint(dlistint_t *head) 14 | { 15 | int sum = 0; 16 | 17 | /* while we have a pointer to the list */ 18 | while (head != NULL) 19 | { 20 | sum += head->n; 21 | head = head->next; 22 | } 23 | return (sum); 24 | } 25 | -------------------------------------------------------------------------------- /0x04-more_functions_nested_loops/5-more_numbers.c: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | 3 | /** 4 | * more_numbers - Function that prints 10 times the numbers, from 0 to 14, 5 | * followed by a new line 6 | * 7 | * You can only use _putchar three times in your code. 8 | * 9 | * Return: No return. 10 | */ 11 | void more_numbers(void) 12 | { 13 | int i, j; 14 | 15 | for (i = 0; i < 10; i++) 16 | { 17 | for (j = 0; j < 15; j++) 18 | { 19 | if (j >= 10) 20 | _putchar(j / 10 + '0'); 21 | _putchar(j % 10 + '0'); 22 | } 23 | _putchar('\n'); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /0x08-recursion/4-main.c: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | #include 3 | 4 | /** 5 | * main - check the code 6 | * 7 | * Return: Always 0. 8 | */ 9 | int main(void) 10 | { 11 | int r; 12 | 13 | r = _pow_recursion(1, 10); 14 | printf("%d\n", r); 15 | r = _pow_recursion(1024, 0); 16 | printf("%d\n", r); 17 | r = _pow_recursion(2, 16); 18 | printf("%d\n", r); 19 | r = _pow_recursion(5, 2); 20 | printf("%d\n", r); 21 | r = _pow_recursion(5, -2); 22 | printf("%d\n", r); 23 | r = _pow_recursion(-5, 3); 24 | printf("%d\n", r); 25 | return (0); 26 | } 27 | -------------------------------------------------------------------------------- /0x13-more_singly_linked_lists/1-listint_len.c: -------------------------------------------------------------------------------- 1 | #include "lists.h" 2 | #include 3 | 4 | /** 5 | * listint_len - function that returns the number of elements in, 6 | * a linked listint_t list. 7 | * @h: pointer to the head of linked list. 8 | * 9 | * Format: see example. 10 | * You are allowed to use printf. 11 | * 12 | * Return: number of elements. 13 | */ 14 | 15 | size_t listint_len(const listint_t *h) 16 | { 17 | size_t count = 0; 18 | 19 | while (h != NULL) 20 | { 21 | h = h->next; 22 | count++; 23 | } 24 | return (count); 25 | } 26 | -------------------------------------------------------------------------------- /0x1A-hash_tables/2-key_index.c: -------------------------------------------------------------------------------- 1 | #include "hash_tables.h" 2 | 3 | /** 4 | * key_index - function that returns the index of a key. 5 | * @key: pointer to key to get index. 6 | * @size: size of the array of the hash table. 7 | * 8 | * This function should use the hash_djb2 function that you wrote earlier 9 | * 10 | * Return: index at which the key/value pair should be stored in the, 11 | * array of the hash table. 12 | */ 13 | unsigned long int key_index(const unsigned char *key, unsigned long int size) 14 | { 15 | return (hash_djb2(key) % size); 16 | } 17 | -------------------------------------------------------------------------------- /0x06-pointers_arrays_strings/102-magic.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(void) 4 | { 5 | int n; 6 | int a[5]; 7 | int *p; 8 | 9 | a[2] = 1024; 10 | p = &n; 11 | /* 12 | * write your line of code here... 13 | * Remember: 14 | * - you are not allowed to use a 15 | * - you are not allowed to modify p 16 | * - only one statement 17 | * - you are not allowed to code anything else than this line of code 18 | */ 19 | *(p + 5) = 98; 20 | /* ...so that this prints 98\n */ 21 | printf("a[2] = %d\n", a[2]); 22 | return (0); 23 | } 24 | -------------------------------------------------------------------------------- /0x04-more_functions_nested_loops/6-print_line.c: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | /** 3 | * print_line - Function that draws a straight line in the terminal. 4 | * @n: number of times to print _ character. 5 | * 6 | * You can only use _putchar function to print. 7 | * The line should end with a \n. 8 | * If n is 0 or less, the function should only print \n. 9 | * 10 | * Return: No return. 11 | */ 12 | 13 | void print_line(int n) 14 | { 15 | 16 | int i; 17 | 18 | if (n > 0) 19 | { 20 | for (i = 0; i < n; i++) 21 | _putchar('_'); 22 | } 23 | _putchar('\n'); 24 | } 25 | -------------------------------------------------------------------------------- /0x05-pointers_arrays_strings/9-strcpy.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "main.h" 3 | 4 | /** 5 | * _strcpy - Function that copies the string pointed to by src, including the, 6 | * terminating null byte (\0), to the buffer pointed to by dest. 7 | * @dest: Pointer to the character array to write to. 8 | * @src: Pointer to the null-terminated byte string to copy from. 9 | * 10 | * Return: A pointer to *dest. 11 | */ 12 | 13 | char *_strcpy(char *dest, char *src) 14 | { 15 | char *c = dest; 16 | 17 | while 18 | ((*dest++ = *src++)); 19 | 20 | return (c); 21 | } 22 | -------------------------------------------------------------------------------- /0x07-pointers_arrays_strings/main.h: -------------------------------------------------------------------------------- 1 | #ifndef MAIN_H 2 | #define MAIN_H 3 | 4 | int _putchar(char c); 5 | char *_memset(char *s, char b, unsigned int n); 6 | char *_memcpy(char *dest, char *src, unsigned int n); 7 | char *_strchr(char *s, char c); 8 | unsigned int _strspn(char *s, char *accept); 9 | char *_strpbrk(char *s, char *accept); 10 | int compare (char *haystack, char *needle); 11 | char *_strstr(char *haystack, char *needle); 12 | void print_chessboard(char (*a)[8]); 13 | void print_diagsums(int *a, int size); 14 | void set_string(char **s, char *to); 15 | 16 | #endif -------------------------------------------------------------------------------- /0x13-more_singly_linked_lists/2-main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "lists.h" 5 | 6 | /** 7 | * main - check the code 8 | * 9 | * Return: Always 0. 10 | */ 11 | int main(void) 12 | { 13 | listint_t *head; 14 | 15 | head = NULL; 16 | add_nodeint(&head, 0); 17 | add_nodeint(&head, 1); 18 | add_nodeint(&head, 2); 19 | add_nodeint(&head, 3); 20 | add_nodeint(&head, 4); 21 | add_nodeint(&head, 98); 22 | add_nodeint(&head, 402); 23 | add_nodeint(&head, 1024); 24 | print_listint(head); 25 | return (0); 26 | } 27 | -------------------------------------------------------------------------------- /0x14-bit_manipulation/1-print_binary.c: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | 3 | /** 4 | * print_binary - function that prints bin represenatation of a n. 5 | * @n: integer. 6 | * 7 | * You are not allowed to use arrays. 8 | * You are not allowed to use malloc. 9 | * You are not allowed to use the % or / operators. 10 | * 11 | * Return: no return. 12 | */ 13 | 14 | void print_binary(unsigned long int n) 15 | { 16 | if (n >> 0) 17 | { 18 | if (n >> 1) 19 | print_binary(n >> 1); 20 | _putchar((n & 1) + '0'); 21 | } 22 | else 23 | { 24 | _putchar('0'); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /0x0E-structures_typedef/1-init_dog.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "dog.h" 4 | 5 | 6 | /** 7 | * init_dog - function that initializes a variable of type struct dog. 8 | * @d: pointer to struct dog. 9 | * @age: age of the dog. 10 | * @owner: pointer to owner of the dog. 11 | * @name: pointer to the name of the dog. 12 | * 13 | * Return: No return. 14 | */ 15 | 16 | void init_dog(struct dog *d, char *name, float age, char *owner) 17 | { 18 | if (d) 19 | { 20 | d->name = name; 21 | d->age = age; 22 | d->owner = owner; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /0x0F-function_pointers/1-array_iterator.c: -------------------------------------------------------------------------------- 1 | #include "function_pointers.h" 2 | 3 | /** 4 | * array_iterator - function that executes a function given as a, 5 | * parameter on each element of an array. 6 | * @array: pointer to array. 7 | * @size: size of the array. 8 | * @action: pointer to the execution function 9 | * 10 | * Return: No return. 11 | */ 12 | 13 | void array_iterator(int *array, size_t size, void (*action)(int)) 14 | { 15 | unsigned int i; 16 | 17 | if (array && action) 18 | { 19 | for (i = 0; i < size; i++) 20 | action(*(array + i)); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /0x0C-more_malloc_free/0-malloc_checked.c: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | #include 3 | 4 | 5 | /** 6 | * malloc_checked - fucntion that allocates memory using malloc. 7 | * @b: Number of bytes to allocate. 8 | * 9 | * If malloc fails, the malloc_checked function should cause normal, 10 | * process termination with a status value of 98. 11 | * 12 | * Return: A pointer to the allocated memory. 13 | */ 14 | 15 | void *malloc_checked(unsigned int b) 16 | 17 | { 18 | void *p; 19 | 20 | p = malloc(b); 21 | 22 | if (p == NULL) 23 | exit(98); 24 | 25 | return (p); 26 | } 27 | -------------------------------------------------------------------------------- /0x02-functions_nested_loops/2-print_alphabet_x10.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "main.h" 3 | 4 | /** 5 | * print_alphabet_x10 - Function that prints 10 times the alphabet, 6 | * in lowercase, followed by a new line. 7 | * 8 | * You can only use _putchar twice in your code. 9 | * 10 | * Return: 0. 11 | */ 12 | 13 | void print_alphabet_x10(void) 14 | { 15 | 16 | int x, a; 17 | int lower_x; 18 | 19 | for (a = 0; a <= 9; a++) 20 | { 21 | for (x = 'A'; x <= 'Z'; x++) 22 | { 23 | lower_x = tolower(x); 24 | _putchar(lower_x); 25 | } 26 | _putchar('\n'); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /0x14-bit_manipulation/2-get_bit.c: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | 3 | /** 4 | * get_bit - func that returns the value of a bit at a given index. 5 | * @index: index of bit. 6 | * @n: integer. 7 | * 8 | * Return: the bit value or -1 if error occured. 9 | * 10 | */ 11 | 12 | int get_bit(unsigned long int n, unsigned int index) 13 | { 14 | int bit_value; 15 | /* in unsigned long int bit indexes range from 0 to 63 */ 16 | if (index > 63) 17 | return (-1); 18 | 19 | /* to get bit value */ 20 | bit_value = (n >> index) & 1; 21 | 22 | /* return bit value */ 23 | return (bit_value); 24 | } 25 | -------------------------------------------------------------------------------- /0x02-functions_nested_loops/8-24_hours.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "main.h" 4 | 5 | /** 6 | * jack_bauer - Function that prints time from 00:00 to 24:00. 7 | * 8 | * Return: No return. 9 | */ 10 | 11 | void jack_bauer(void) 12 | { 13 | int hr; 14 | int min; 15 | 16 | for (hr = 0; hr < 24; hr++) 17 | { 18 | for (min = 0; min < 60; min++) 19 | { 20 | _putchar((hr / 10) + '0'); 21 | _putchar((hr % 10) + '0'); 22 | _putchar(':'); 23 | _putchar((min / 10) + '0'); 24 | _putchar((min % 10) + '0'); 25 | _putchar('\n'); 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /0x17-doubly_linked_lists/2-main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "lists.h" 5 | 6 | /** 7 | * main - check the code 8 | * 9 | * Return: Always EXIT_SUCCESS. 10 | */ 11 | int main(void) 12 | { 13 | dlistint_t *head; 14 | 15 | head = NULL; 16 | add_dnodeint(&head, 0); 17 | add_dnodeint(&head, 1); 18 | add_dnodeint(&head, 2); 19 | add_dnodeint(&head, 3); 20 | add_dnodeint(&head, 4); 21 | add_dnodeint(&head, 98); 22 | add_dnodeint(&head, 402); 23 | add_dnodeint(&head, 1024); 24 | print_dlistint(head); 25 | return (EXIT_SUCCESS); 26 | } 27 | -------------------------------------------------------------------------------- /0x02-functions_nested_loops/103-fibonacci.c: -------------------------------------------------------------------------------- 1 | #include 2 | /** 3 | * main - A program that finds and prints the sum of the even-valued terms, 4 | * followed by a new line. 5 | * 6 | * Consider the terms in the Fibonacci sequence whose values do not exceed, 7 | * 4,000,000. 8 | * 9 | * Return: 0. 10 | */ 11 | 12 | int main(void) 13 | { 14 | int a = 0, b = 1, next = 0; 15 | int sum = 0; 16 | 17 | while (next < 4000000) 18 | { 19 | next = a + b; 20 | a = b; 21 | b = next; 22 | if (next % 2 == 0) 23 | sum += next; 24 | } 25 | printf("%i\n", sum); 26 | return (0); 27 | } 28 | -------------------------------------------------------------------------------- /0x10-variadic_functions/0-sum_them_all.c: -------------------------------------------------------------------------------- 1 | #include "variadic_functions.h" 2 | 3 | /** 4 | * sum_them_all - function that returns the sum of all its params 5 | * @n: number of params. 6 | * 7 | * If n == 0, return 0. 8 | * 9 | * Return: Sum of all its params. 10 | */ 11 | 12 | int sum_them_all(const unsigned int n, ...) 13 | { 14 | va_list valist; 15 | unsigned int i; 16 | int sum = 0; 17 | 18 | if (n == 0) 19 | return (0); 20 | 21 | va_start(valist, n); 22 | 23 | for (i = 0; i < n; i++) 24 | sum += va_arg(valist, int); 25 | 26 | va_end(valist); 27 | 28 | return (sum); 29 | } 30 | -------------------------------------------------------------------------------- /0x13-more_singly_linked_lists/3-main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "lists.h" 5 | 6 | /** 7 | * main - check the code 8 | * 9 | * Return: Always 0. 10 | */ 11 | int main(void) 12 | { 13 | listint_t *head; 14 | 15 | head = NULL; 16 | add_nodeint_end(&head, 0); 17 | add_nodeint_end(&head, 1); 18 | add_nodeint_end(&head, 2); 19 | add_nodeint_end(&head, 3); 20 | add_nodeint_end(&head, 4); 21 | add_nodeint_end(&head, 98); 22 | add_nodeint_end(&head, 402); 23 | add_nodeint_end(&head, 1024); 24 | print_listint(head); 25 | return (0); 26 | } 27 | -------------------------------------------------------------------------------- /0x06-pointers_arrays_strings/cccc.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "main.h" 3 | 4 | /** 5 | * print_number - function that prints an integer 6 | * @n: integer 7 | * Return: no return 8 | */ 9 | 10 | void print_number(int n) 11 | { 12 | unsigned int m, d, count; 13 | 14 | if (n < 0) 15 | { 16 | _putchar(45); 17 | m = n * -1; 18 | } 19 | else 20 | { 21 | m = n; 22 | } 23 | 24 | d = m; 25 | count = 1; 26 | 27 | while (d > 9) 28 | { 29 | d /= 10; 30 | count *= 10; 31 | } 32 | 33 | for (; count >= 1; count /= 10) 34 | { 35 | _putchar(((m / count) % 10) + 48); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /0x0B-malloc_free/4-free_grid.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "main.h" 4 | 5 | /** 6 | * free_grid - function that frees a 2-D grid previously created by, 7 | * my alloc_grid function. 8 | * @grid: 2-D array of integers. 9 | * @height: height of the 2D array or frid. 10 | * 11 | * Compilation will be done with the alloc_grid.c file. 12 | * 13 | * Return: No return. 14 | */ 15 | 16 | void free_grid(int **grid, int height) 17 | { 18 | if (grid != NULL && height != 0) 19 | { 20 | for (; height >= 0; height--) 21 | free(grid[height]); 22 | free(grid); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /0x15-file_io/Requiescat: -------------------------------------------------------------------------------- 1 | Requiescat 2 | by Oscar Wilde 3 | 4 | Tread lightly, she is near 5 | Under the snow, 6 | Speak gently, she can hear 7 | The daisies grow. 8 | 9 | All her bright golden hair 10 | Tarnished with rust, 11 | She that was young and fair 12 | Fallen to dust. 13 | 14 | Lily-like, white as snow, 15 | She hardly knew 16 | She was a woman, so 17 | Sweetly she grew. 18 | 19 | Coffin-board, heavy stone, 20 | Lie on her breast, 21 | I vex my heart alone, 22 | She is at rest. 23 | 24 | Peace, Peace, she cannot hear 25 | Lyre or sonnet, 26 | All my life's buried here, 27 | Heap earth upon it. 28 | -------------------------------------------------------------------------------- /0x1E-search_algorithms/1-main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "search_algos.h" 4 | 5 | /** 6 | * main - Entry point 7 | * 8 | * Return: Always EXIT_SUCCESS 9 | */ 10 | int main(void) 11 | { 12 | int array[] = { 13 | 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 14 | }; 15 | size_t size = sizeof(array) / sizeof(array[0]); 16 | 17 | printf("Found %d at index: %d\n\n", 2, binary_search(array, size, 2)); 18 | printf("Found %d at index: %d\n\n", 5, binary_search(array, 5, 5)); 19 | printf("Found %d at index: %d\n", 999, binary_search(array, size, 999)); 20 | return (EXIT_SUCCESS); 21 | } 22 | -------------------------------------------------------------------------------- /0x07-pointers_arrays_strings/8-main.c: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | #include 3 | 4 | /** 5 | * main - check the code 6 | * 7 | * Return: Always 0. 8 | */ 9 | int main(void) 10 | { 11 | int c3[3][3] = { 12 | {0, 1, 5}, 13 | {10, 11, 12}, 14 | {1000, 101, 102}, 15 | }; 16 | int c5[5][5] = { 17 | {0, 1, 5, 12124, 1234}, 18 | {10, 11, 12, 123521, 12512}, 19 | {1000, 101, 102, 12545, 214543435}, 20 | {100, 1012451, 11102, 12545, 214543435}, 21 | {10, 12401, 10452, 11542545, 1214543435}, 22 | }; 23 | print_diagsums((int *)c3, 3); 24 | print_diagsums((int *)c5, 5); 25 | return (0); 26 | } 27 | -------------------------------------------------------------------------------- /0x01-variables_if_else_while/7-print_tebahpla.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | /** 5 | * main - Program that prints the lowercase alphabet in reverse, 6 | * followed by a new line. 7 | * 8 | * You can only use the putchar function (every other function (printf, 9 | * puts, etc…) is forbidden). 10 | * All your code should be in the main function. 11 | * You can only use putchar twice in your code. 12 | 13 | * Return: 0. 14 | */ 15 | 16 | int main(void) 17 | { 18 | char chr; 19 | 20 | for (chr = 'z'; chr >= 'a'; --chr) 21 | putchar(chr); 22 | putchar('\n'); 23 | return (0); 24 | } 25 | -------------------------------------------------------------------------------- /0x02-functions_nested_loops/5-sign.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "main.h" 4 | 5 | /** 6 | * print_sign - Function that prints the sign of a number. 7 | * @n: number to be analyzed. 8 | * greater than, equal to or less than zero. 9 | * 10 | * Return: 0 or 1 or -1 depending on the answer 11 | */ 12 | 13 | 14 | int print_sign(int n) 15 | { 16 | if (n > 0) 17 | { 18 | _putchar(43); 19 | return (1); 20 | } 21 | else if (n < 0) 22 | { 23 | _putchar(45); 24 | return (-1); 25 | } 26 | else 27 | { 28 | _putchar(48); 29 | return (0); 30 | } 31 | _putchar('\n'); 32 | } 33 | -------------------------------------------------------------------------------- /0x1E-search_algorithms/0-main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "search_algos.h" 4 | 5 | /** 6 | * main - Entry point 7 | * 8 | * Return: Always EXIT_SUCCESS 9 | */ 10 | int main(void) 11 | { 12 | int array[] = { 13 | 10, 1, 42, 3, 4, 42, 6, 7, -1, 9 14 | }; 15 | size_t size = sizeof(array) / sizeof(array[0]); 16 | 17 | printf("Found %d at index: %d\n\n", 3, linear_search(array, size, 3)); 18 | printf("Found %d at index: %d\n\n", 42, linear_search(array, size, 42)); 19 | printf("Found %d at index: %d\n", 999, linear_search(array, size, 999)); 20 | return (EXIT_SUCCESS); 21 | } 22 | -------------------------------------------------------------------------------- /0x13-more_singly_linked_lists/0-print_listint.c: -------------------------------------------------------------------------------- 1 | #include "lists.h" 2 | #include 3 | 4 | /** 5 | * print_listint - function that prints all the elements of a listint_t list. 6 | * @h: pointer to the head of linked list. 7 | * 8 | * Format: see example. 9 | * You are allowed to use printf. 10 | * 11 | * Return: all the elements of the list. 12 | */ 13 | 14 | size_t print_listint(const listint_t *h) 15 | { 16 | size_t count = 0; 17 | 18 | /* while we have a pointer to head */ 19 | while (h != NULL) 20 | { 21 | printf("%d\n", h->n); 22 | h = h->next; 23 | count++; 24 | } 25 | return (count); 26 | } 27 | -------------------------------------------------------------------------------- /0x17-doubly_linked_lists/3-main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "lists.h" 5 | 6 | /** 7 | * main - check the code 8 | * 9 | * Return: Always EXIT_SUCCESS. 10 | */ 11 | int main(void) 12 | { 13 | dlistint_t *head; 14 | 15 | head = NULL; 16 | add_dnodeint_end(&head, 0); 17 | add_dnodeint_end(&head, 1); 18 | add_dnodeint_end(&head, 2); 19 | add_dnodeint_end(&head, 3); 20 | add_dnodeint_end(&head, 4); 21 | add_dnodeint_end(&head, 98); 22 | add_dnodeint_end(&head, 402); 23 | add_dnodeint_end(&head, 1024); 24 | print_dlistint(head); 25 | return (EXIT_SUCCESS); 26 | } 27 | -------------------------------------------------------------------------------- /0x00-hello_world/6-size.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | /** 4 | * main - Entry point 5 | * Description: prints "with proper grammar, but the outcome is a piece of art" 6 | * Return: 0 7 | */ 8 | 9 | int main(void) 10 | { 11 | char e; 12 | int f; 13 | long int b; 14 | long long int c; 15 | float d; 16 | 17 | printf("Size of a char: %d byte(s)\n", sizeof(e)); 18 | printf("Size of an int: %d byte(s)\n", sizeof(f)); 19 | printf("Size of a long int: %d byte(s)\n", sizeof(b)); 20 | printf("Size of a long long int: %d byte(s)\n", sizeof(c)); 21 | printf("Size of a float: %d byte(s)\n", sizeof(d)); 22 | 23 | return (0); 24 | } 25 | -------------------------------------------------------------------------------- /0x14-bit_manipulation/3-set_bit.c: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | 3 | /** 4 | * set_bit - func that ets the value of a bit to 1 at a given index. 5 | * @index: index of bit. 6 | * @n: pointer to integer . 7 | * 8 | * Return: 1 if it worked, or -1 if an error occurred. 9 | * 10 | */ 11 | 12 | int set_bit(unsigned long int *n, unsigned int index) 13 | { 14 | /* unsigned long int indexes go up to 63 because they have 64 nums*/ 15 | if (index > 63) 16 | { 17 | return (-1); 18 | } 19 | /* use bitwise OR | operator to set a bit */ 20 | /* use number |= 1UL << n to set a bit */ 21 | *n |= (1UL << index); 22 | 23 | return (1); 24 | } 25 | -------------------------------------------------------------------------------- /0x04-more_functions_nested_loops/101-print_number.c: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | /** 3 | * print_number - Function that prints an integer. 4 | * @n: integer to print. 5 | * 6 | * You can only use _putchar function to print. 7 | * You are not allowed to use long. 8 | * You are not allowed to use arrays or pointers. 9 | * You are not allowed to hard-code special values. 10 | * 11 | * Return: void. 12 | */ 13 | void print_number(int n) 14 | { 15 | unsigned int x; 16 | 17 | x = n; 18 | 19 | if (n < 0) 20 | { 21 | _putchar(45); 22 | x = -n; 23 | } 24 | if (x / 10) 25 | print_number(x / 10); 26 | _putchar((x % 10) + '0'); 27 | } 28 | -------------------------------------------------------------------------------- /0x14-bit_manipulation/4-clear_bit.c: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | 3 | /** 4 | * clear_bit - function that sets the value of a bit to 0 at a given index. 5 | * @index: index to set. 6 | * @n: unsigned long integer. 7 | * 8 | * Return: 1 if it worked or -1 if an error occured. 9 | */ 10 | 11 | int clear_bit(unsigned long int *n, unsigned int index) 12 | { 13 | /* unsigned long int indexes go up to 63 because they have 64 nums*/ 14 | if (index > 63) 15 | { 16 | return (-1); 17 | } 18 | /* use bitwise AND & operator to clear */ 19 | /* use number &= ~(1UL << n) clear a bit */ 20 | *n &= ~(1UL << index); 21 | 22 | return (1); 23 | } 24 | -------------------------------------------------------------------------------- /0x06-pointers_arrays_strings/5-string_toupper.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "main.h" 4 | 5 | /** 6 | * string_toupper - function that changes all lowercase letters of a string, 7 | * to uppercase. 8 | * @string: pointer to string to be converted to upper. 9 | * 10 | * Return: the string in upper case. 11 | */ 12 | 13 | char *string_toupper(char *string) 14 | { 15 | const char OFFSET = 'a' - 'A'; 16 | int i = 0; 17 | 18 | while (*(string + i)) 19 | { 20 | if (*(string + i) >= 'a' && *(string + i) <= 'z') 21 | { 22 | *(string + i) -= OFFSET; 23 | } 24 | i++; 25 | } 26 | return (string); 27 | } 28 | -------------------------------------------------------------------------------- /0x13-more_singly_linked_lists/1-main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "lists.h" 5 | 6 | /** 7 | * main - check the code 8 | * 9 | * Return: Always 0. 10 | */ 11 | int main(void) 12 | { 13 | listint_t *head; 14 | listint_t *new; 15 | listint_t hello = {8, NULL}; 16 | size_t n; 17 | 18 | head = &hello; 19 | new = malloc(sizeof(listint_t)); 20 | if (new == NULL) 21 | { 22 | printf("Error\n"); 23 | return (1); 24 | } 25 | new->n = 9; 26 | new->next = head; 27 | head = new; 28 | n = listint_len(head); 29 | printf("-> %lu elements\n", n); 30 | free(new); 31 | return (0); 32 | } 33 | -------------------------------------------------------------------------------- /0x13-more_singly_linked_lists/4-main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "lists.h" 5 | 6 | /** 7 | * main - check the code 8 | * 9 | * Return: Always 0. 10 | */ 11 | int main(void) 12 | { 13 | listint_t *head; 14 | 15 | head = NULL; 16 | add_nodeint_end(&head, 0); 17 | add_nodeint_end(&head, 1); 18 | add_nodeint_end(&head, 2); 19 | add_nodeint_end(&head, 3); 20 | add_nodeint_end(&head, 4); 21 | add_nodeint_end(&head, 98); 22 | add_nodeint_end(&head, 402); 23 | add_nodeint_end(&head, 1024); 24 | print_listint(head); 25 | free_listint(head); 26 | head = NULL; 27 | return (0); 28 | } 29 | -------------------------------------------------------------------------------- /0x13-more_singly_linked_lists/0-main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "lists.h" 5 | 6 | /** 7 | * main - check the code 8 | * 9 | * Return: Always 0. 10 | */ 11 | int main(void) 12 | { 13 | listint_t *head; 14 | listint_t *new; 15 | listint_t hello = {8, NULL}; 16 | size_t n; 17 | 18 | head = &hello; 19 | new = malloc(sizeof(listint_t)); 20 | if (new == NULL) 21 | { 22 | printf("Error\n"); 23 | return (1); 24 | } 25 | new->n = 9; 26 | new->next = head; 27 | head = new; 28 | n = print_listint(head); 29 | printf("-> %lu elements\n", n); 30 | free(new); 31 | return (0); 32 | } 33 | -------------------------------------------------------------------------------- /0x02-functions_nested_loops/5-main.c: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | 3 | /** 4 | * main - check the code. 5 | * 6 | * Return: Always 0. 7 | */ 8 | int main(void) 9 | { 10 | int r; 11 | 12 | r = print_sign(98); 13 | _putchar(','); 14 | _putchar(' '); 15 | _putchar(r + '0'); 16 | _putchar('\n'); 17 | r = print_sign(0); 18 | _putchar(','); 19 | _putchar(' '); 20 | _putchar(r + '0'); 21 | _putchar('\n'); 22 | r = print_sign(0xff); 23 | _putchar(','); 24 | _putchar(' '); 25 | _putchar(r + '0'); 26 | _putchar('\n'); 27 | r = print_sign(-1); 28 | _putchar(','); 29 | _putchar(' '); 30 | _putchar(r + '0'); 31 | _putchar('\n'); 32 | return (0); 33 | } 34 | -------------------------------------------------------------------------------- /0x08-recursion/6-main.c: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | #include 3 | 4 | /** 5 | * main - check the code 6 | * 7 | * Return: Always 0. 8 | */ 9 | int main(void) 10 | { 11 | int r; 12 | 13 | r = is_prime_number(1); 14 | printf("%d\n", r); 15 | r = is_prime_number(1024); 16 | printf("%d\n", r); 17 | r = is_prime_number(16); 18 | printf("%d\n", r); 19 | r = is_prime_number(17); 20 | printf("%d\n", r); 21 | r = is_prime_number(25); 22 | printf("%d\n", r); 23 | r = is_prime_number(-1); 24 | printf("%d\n", r); 25 | r = is_prime_number(113); 26 | printf("%d\n", r); 27 | r = is_prime_number(7919); 28 | printf("%d\n", r); 29 | return (0); 30 | } 31 | -------------------------------------------------------------------------------- /0x07-pointers_arrays_strings/7-main.c: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | #include 3 | 4 | /** 5 | * main - check the code 6 | * 7 | * Return: Always 0. 8 | */ 9 | int main(void) 10 | { 11 | char board[8][8] = { 12 | {'r', 'k', 'b', 'q', 'k', 'b', 'k', 'r'}, 13 | {'p', 'p', 'p', 'p', 'p', 'p', 'p', 'p'}, 14 | {' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '}, 15 | {' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '}, 16 | {' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '}, 17 | {' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '}, 18 | {'P', 'P', 'P', 'P', 'P', 'P', 'P', 'P'}, 19 | {'R', 'K', 'B', 'Q', 'K', 'B', 'K', 'R'}, 20 | }; 21 | print_chessboard(board); 22 | return (0); 23 | } 24 | -------------------------------------------------------------------------------- /0x0E-structures_typedef/dog.h: -------------------------------------------------------------------------------- 1 | #ifndef _DOG_H_ 2 | #define _DOG_H_ 3 | 4 | /** 5 | * dog_t - typedef for struct dog. 6 | * 7 | */ 8 | typedef struct dog dog_t; 9 | 10 | /** 11 | * struct dog - defines a new type struct dog. 12 | * @name: pointer to name of the dog. 13 | * @age: age of the dog. 14 | * @owner: pointer to owner of the dog. 15 | */ 16 | struct dog 17 | { 18 | char *name; 19 | float age; 20 | char *owner; 21 | }; 22 | 23 | void init_dog(struct dog *d, char *name, float age, char *owner); 24 | void print_dog(struct dog *d); 25 | dog_t *new_dog(char *name, float age, char *owner); 26 | void free_dog(dog_t *d); 27 | 28 | #endif /* _DOG_H_ */ 29 | -------------------------------------------------------------------------------- /0x13-more_singly_linked_lists/5-main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "lists.h" 5 | 6 | /** 7 | * main - check the code 8 | * 9 | * Return: Always 0. 10 | */ 11 | int main(void) 12 | { 13 | listint_t *head; 14 | 15 | head = NULL; 16 | add_nodeint_end(&head, 0); 17 | add_nodeint_end(&head, 1); 18 | add_nodeint_end(&head, 2); 19 | add_nodeint_end(&head, 3); 20 | add_nodeint_end(&head, 4); 21 | add_nodeint_end(&head, 98); 22 | add_nodeint_end(&head, 402); 23 | add_nodeint_end(&head, 1024); 24 | print_listint(head); 25 | free_listint2(&head); 26 | printf("%p\n", (void *)head); 27 | return (0); 28 | } 29 | -------------------------------------------------------------------------------- /0x06-pointers_arrays_strings/101-print_number.c: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | 3 | /** 4 | * print_number - function that prints an integer. 5 | * @n: integer. 6 | * 7 | * You can only use _putchar function to print. 8 | * You are not allowed to use long. 9 | * You are not allowed to use arrays or pointers. 10 | * You are not allowed to hard-code special values. 11 | * 12 | * Return: no return 13 | */ 14 | 15 | void print_number(int n) 16 | { 17 | unsigned int b; 18 | 19 | if (n < 0) 20 | { 21 | b = -n; 22 | _putchar('-'); 23 | } else 24 | { 25 | b = n; 26 | } 27 | 28 | if (b / 10) 29 | print_number(b / 10); 30 | 31 | _putchar((b % 10) + '0'); 32 | } 33 | -------------------------------------------------------------------------------- /0x07-pointers_arrays_strings/2-strchr.c: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | #include 3 | 4 | /** 5 | **_strchr - function that locates a character in a string. 6 | * @s: pointer to the null-terminated byte string to be analyzed. 7 | * @c: character to search for. 8 | * 9 | * Return: a pointer to first occurence of c. 10 | */ 11 | 12 | 13 | char *_strchr(char *s, char c) 14 | { 15 | unsigned int i = 0; 16 | 17 | /* loop through string s */ 18 | for (; *(s + i) != '\0'; i++) 19 | { 20 | /* check if a character in s is in c */ 21 | if (*(s + i) == c) 22 | return (s + i); 23 | } 24 | if (*(s + i) == c) 25 | return (s + i); 26 | 27 | return ('\0'); 28 | } 29 | -------------------------------------------------------------------------------- /0x17-doubly_linked_lists/4-main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "lists.h" 5 | 6 | /** 7 | * main - check the code 8 | * 9 | * Return: Always EXIT_SUCCESS. 10 | */ 11 | int main(void) 12 | { 13 | dlistint_t *head; 14 | 15 | head = NULL; 16 | add_dnodeint_end(&head, 0); 17 | add_dnodeint_end(&head, 1); 18 | add_dnodeint_end(&head, 2); 19 | add_dnodeint_end(&head, 3); 20 | add_dnodeint_end(&head, 4); 21 | add_dnodeint_end(&head, 98); 22 | add_dnodeint_end(&head, 402); 23 | add_dnodeint_end(&head, 1024); 24 | print_dlistint(head); 25 | free_dlistint(head); 26 | head = NULL; 27 | return (EXIT_SUCCESS); 28 | } 29 | -------------------------------------------------------------------------------- /.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 53 | -------------------------------------------------------------------------------- /0x01-variables_if_else_while/6-print_numberz.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | /** 5 | * main - Program that prints all single digit numbers of base 10 starting, 6 | * from 0, followed by a new line. 7 | * 8 | * You are not allowed to use any variable of type char. 9 | * You can only use the putchar function (every other function (printf 10 | * puts, etc…) is forbidden). 11 | * You can only use putchar twice in your code. 12 | * All your code should be in the main function. 13 | 14 | * Return: 0. 15 | */ 16 | 17 | int main(void) 18 | { 19 | int i; 20 | 21 | for (i = '0'; i <= '9'; ++i) 22 | putchar(i); 23 | putchar('\n'); 24 | return (0); 25 | } 26 | -------------------------------------------------------------------------------- /0x01-variables_if_else_while/8-print_base16.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | /** 5 | * main - Program that prints all the numbers of base 16 in lowercase, 6 | * followed by a new line. 7 | * 8 | * You can only use the putchar function (every other function (printf, 9 | * puts, etc…) is forbidden). 10 | * All your code should be in the main function. 11 | * You can only use putchar three times in your code. 12 | 13 | * Return: 0. 14 | */ 15 | 16 | int main(void) 17 | { 18 | int i; 19 | char a; 20 | 21 | for (i = '0'; i <= '9'; ++i) 22 | putchar(i); 23 | for (a = 'a'; a <= 'f'; ++a) 24 | putchar(a); 25 | putchar('\n'); 26 | return (0); 27 | } 28 | -------------------------------------------------------------------------------- /0x06-pointers_arrays_strings/main.h: -------------------------------------------------------------------------------- 1 | #ifndef MAIN_H 2 | #define MAIN_H 3 | 4 | int _putchar(char c); 5 | char *_strcat(char *dest, char *src); 6 | char *_strncat(char *dest, char *src, int n); 7 | char *_strncpy(char *dest, char *src, int n); 8 | int _strcmp(char *s1, char *s2); 9 | void reverse_array(int *a, int n); 10 | char *string_toupper(char *); 11 | char *cap_string(char *); 12 | char *leet(char *); 13 | char *rot13(char *); 14 | void print_number(int n); 15 | char *infinite_add(char *n1, char *n2, char *r, int size_r); 16 | void print_buffer(char *b, int size); 17 | void printASCII(char *b, int start, int end); 18 | void printHexes(char *b, int start, int end); 19 | 20 | #endif -------------------------------------------------------------------------------- /0x13-more_singly_linked_lists/8-main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "lists.h" 5 | 6 | /** 7 | * main - check the code 8 | * 9 | * Return: Always 0. 10 | */ 11 | int main(void) 12 | { 13 | listint_t *head; 14 | int sum; 15 | 16 | head = NULL; 17 | add_nodeint_end(&head, 0); 18 | add_nodeint_end(&head, 1); 19 | add_nodeint_end(&head, 2); 20 | add_nodeint_end(&head, 3); 21 | add_nodeint_end(&head, 4); 22 | add_nodeint_end(&head, 98); 23 | add_nodeint_end(&head, 402); 24 | add_nodeint_end(&head, 1024); 25 | sum = sum_listint(head); 26 | printf("sum = %d\n", sum); 27 | free_listint2(&head); 28 | return (0); 29 | } 30 | -------------------------------------------------------------------------------- /0x01-variables_if_else_while/4-print_alphabt.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | /** 5 | * main - Program that prints the alphabet in lowercase followed by a new line. 6 | * 7 | * Print all the letters except q and e. 8 | * You can only use the putchar function (every other function (printf, 9 | * puts, etc…) is forbidden). 10 | * All your code should be in the main function. 11 | * You can only use putchar twice in your code. 12 | 13 | * Return: 0 14 | */ 15 | 16 | int main(void) 17 | { 18 | int ch; 19 | 20 | for (ch = 'a'; ch <= 'z'; ch++) 21 | { 22 | if (ch != 'e' && ch != 'q') 23 | putchar(ch); 24 | } 25 | putchar('\n'); 26 | return (0); 27 | } 28 | -------------------------------------------------------------------------------- /0x0C-more_malloc_free/0-main.c: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | #include 3 | #include 4 | #include 5 | 6 | /** 7 | * main - check the code 8 | * 9 | * Return: Always 0. 10 | */ 11 | int main(void) 12 | { 13 | char *c; 14 | int *i; 15 | float *f; 16 | double *d; 17 | 18 | c = malloc_checked(sizeof(char) * 1024); 19 | printf("%p\n", (void *)c); 20 | i = malloc_checked(sizeof(int) * 402); 21 | printf("%p\n", (void *)i); 22 | f = malloc_checked(sizeof(float) * 100000000); 23 | printf("%p\n", (void *)f); 24 | d = malloc_checked(INT_MAX); 25 | printf("%p\n", (void *)d); 26 | free(c); 27 | free(i); 28 | free(f); 29 | free(d); 30 | return (0); 31 | } 32 | -------------------------------------------------------------------------------- /0x01-variables_if_else_while/3-print_alphabets.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | /** 5 | * main - Program that prints the alphabet in lowercase, and then in, 6 | * uppercase, followed by a new line. 7 | * 8 | * You can only use the putchar function (every other function (printf, 9 | * puts, etc…) is forbidden). 10 | * All your code should be in the main function. 11 | * You can only use putchar three times in your code. 12 | * 13 | * Return: 0 14 | */ 15 | 16 | int main(void) 17 | { 18 | int ch; 19 | 20 | for (ch = 'a'; ch <= 'z'; ch++) 21 | putchar(ch); 22 | for (ch = 'A'; ch <= 'Z'; ch++) 23 | putchar(ch); 24 | putchar('\n'); 25 | return (0); 26 | } 27 | -------------------------------------------------------------------------------- /0x13-more_singly_linked_lists/100-main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "lists.h" 5 | 6 | /** 7 | * main - check the code 8 | * 9 | * Return: Always 0. 10 | */ 11 | int main(void) 12 | { 13 | listint_t *head; 14 | 15 | head = NULL; 16 | add_nodeint_end(&head, 0); 17 | add_nodeint_end(&head, 1); 18 | add_nodeint_end(&head, 2); 19 | add_nodeint_end(&head, 3); 20 | add_nodeint_end(&head, 4); 21 | add_nodeint_end(&head, 98); 22 | add_nodeint_end(&head, 402); 23 | add_nodeint_end(&head, 1024); 24 | print_listint(head); 25 | reverse_listint(&head); 26 | print_listint(head); 27 | free_listint2(&head); 28 | return (0); 29 | } 30 | -------------------------------------------------------------------------------- /0x12-singly_linked_lists/1-main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "lists.h" 5 | 6 | /** 7 | * main - check the code 8 | * 9 | * Return: Always 0. 10 | */ 11 | int main(void) 12 | { 13 | list_t *head; 14 | list_t *new; 15 | list_t hello = {"World", 5, NULL}; 16 | size_t n; 17 | 18 | head = &hello; 19 | new = malloc(sizeof(list_t)); 20 | if (new == NULL) 21 | { 22 | printf("Error\n"); 23 | return (1); 24 | } 25 | new->str = strdup("Hello"); 26 | new->len = 5; 27 | new->next = head; 28 | head = new; 29 | n = list_len(head); 30 | printf("-> %lu elements\n", n); 31 | free(new->str); 32 | free(new); 33 | return (0); 34 | } 35 | -------------------------------------------------------------------------------- /0x1C-makefiles/5-island_perimeter.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 2 | """Function island_perimeter(grid)""" 3 | 4 | 5 | def island_perimeter(grid): 6 | """returns the perimeter of the island described in grid. 7 | 8 | Args: 9 | grid (list): grid 10 | """ 11 | m, n = len(grid), len(grid[0]) 12 | land, neighbour = 0, 0 13 | for i in range(m): 14 | for j in range(n): 15 | if grid[i][j] == 1: 16 | land += 1 17 | if i < m - 1 and grid[i+1][j] == 1: 18 | neighbour += 1 19 | if j < n - 1 and grid[i][j + 1] == 1: 20 | neighbour += 1 21 | return land * 4 - 2 * neighbour 22 | -------------------------------------------------------------------------------- /0x02-functions_nested_loops/102-fibonacci.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | /** 4 | * main - Program that prints the first 50 Fibonacci numbers, starting with, 5 | * 1 and 2, followed by a new line. 6 | * 7 | * The numbers must be separated by comma, followed by a space , . 8 | * You are allowed to use the standard library. 9 | * 10 | * Return: 0 if successful. 11 | */ 12 | 13 | int main(void) 14 | { 15 | int i = 0; 16 | long int a = 0, b = 1, next; 17 | 18 | while (i < 50) 19 | { 20 | next = a + b; 21 | a = b; 22 | b = next; 23 | printf("%lu", next); 24 | 25 | if (i < 49) 26 | { 27 | printf(", "); 28 | } 29 | i++; 30 | } 31 | putchar('\n'); 32 | return (0); 33 | } 34 | -------------------------------------------------------------------------------- /0x0B-malloc_free/0-create_array.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "main.h" 4 | 5 | /** 6 | * create_array - function that creates an array of chars, and initializes, 7 | * it with a specific char. 8 | * @size: size of array to create. 9 | * @c: specific character to initialize array with. 10 | * 11 | * Return: NULL if size = 0 (fails) or pointer to the array (success). 12 | */ 13 | 14 | char *create_array(unsigned int size, char c) 15 | { 16 | char *buffer = malloc(sizeof(c) * size); 17 | unsigned int i; 18 | 19 | if (size == 0 || buffer == NULL) 20 | return (NULL); 21 | 22 | for (i = 0; i < size; i++) 23 | buffer[i] = c; 24 | 25 | return (buffer); 26 | } 27 | -------------------------------------------------------------------------------- /0x13-more_singly_linked_lists/5-free_listint2.c: -------------------------------------------------------------------------------- 1 | #include "lists.h" 2 | #include 3 | 4 | /** 5 | * free_listint2 - function that frees a singly linked list. 6 | * @head: pointer to pointer to the head of linked list. 7 | * 8 | * Make sure there is no memory leaks. 9 | * The function sets the head to NULL. 10 | * 11 | * Return: No return. 12 | */ 13 | 14 | void free_listint2(listint_t **head) 15 | { 16 | listint_t *temp_variable; 17 | 18 | if (head == NULL) 19 | return; /* do not do anything */ 20 | while (*head != NULL) 21 | { 22 | temp_variable = *head; 23 | *head = (*head)->next; 24 | free(temp_variable); 25 | } 26 | /* *head = NULL; */ /* not needed */ 27 | } 28 | -------------------------------------------------------------------------------- /0x1A-hash_tables/0-hash_table_create.c: -------------------------------------------------------------------------------- 1 | #include "hash_tables.h" 2 | /** 3 | * hash_table_create - function that creates a hash table. 4 | * 5 | * If something went wrong, your function should return NULL. 6 | * 7 | * @size: size of the hash table/array. 8 | * Return: pointer to the newly created hash table. 9 | */ 10 | hash_table_t *hash_table_create(unsigned long int size) 11 | { 12 | hash_table_t *new = NULL; 13 | 14 | if (size == 0) 15 | return (NULL); 16 | new = malloc(sizeof(hash_table_t)); 17 | if (new == NULL) 18 | return (NULL); 19 | new->size = size; 20 | new->array = malloc(sizeof(hash_node_t *) * size); 21 | if (new->array == NULL) 22 | return (NULL); 23 | return (new); 24 | } 25 | -------------------------------------------------------------------------------- /0x1A-hash_tables/5-main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "hash_tables.h" 5 | 6 | /** 7 | * main - check the code 8 | * 9 | * Return: Always EXIT_SUCCESS. 10 | */ 11 | int main(void) 12 | { 13 | hash_table_t *ht; 14 | 15 | ht = hash_table_create(1024); 16 | hash_table_print(ht); 17 | hash_table_set(ht, "c", "fun"); 18 | hash_table_set(ht, "python", "awesome"); 19 | hash_table_set(ht, "Bob", "and Kris love asm"); 20 | hash_table_set(ht, "N", "queens"); 21 | hash_table_set(ht, "Asterix", "Obelix"); 22 | hash_table_set(ht, "Betty", "Cool"); 23 | hash_table_set(ht, "98", "Battery Street"); 24 | hash_table_print(ht); 25 | return (EXIT_SUCCESS); 26 | } 27 | -------------------------------------------------------------------------------- /0x04-more_functions_nested_loops/100-prime_factor.c: -------------------------------------------------------------------------------- 1 | #include 2 | /** 3 | * main - Program that finds and prints the largest prime factor of the, 4 | * number 612852475143, followed by a new line. 5 | * 6 | * You are allowed to use the standard library. 7 | * Your program will be compiled with this command: 8 | * gcc -Wall -pedantic -Werror -Wextra -std=gnu89 100-prime_factor.c -o 9 | * 100-prime_factor -lm 10 | * 11 | * Return: 0 12 | */ 13 | 14 | int main(void) 15 | { 16 | long i, number = 612852475143; 17 | 18 | for (i = 2; i <= number; i++) 19 | { 20 | if (number % i == 0) 21 | { 22 | number = number / i; 23 | i--; 24 | } 25 | } 26 | printf("%lu\n", i); 27 | return (0); 28 | } 29 | -------------------------------------------------------------------------------- /0x04-more_functions_nested_loops/8-print_square.c: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | 3 | /** 4 | * print_square - Function that prints a square, followed by a new line. 5 | * @size: size of the square. 6 | * 7 | * You can only use _putchar function to print. 8 | * Where size is the size of the square. 9 | * If size is 0 or less, the function should print only a new line. 10 | * Use the character # to print the square. 11 | * 12 | * Return: no return. 13 | */ 14 | 15 | void print_square(int size) 16 | { 17 | int i, j; 18 | 19 | for (i = 0; i < size; i++) 20 | { 21 | for (j = 0; j < size; j++) 22 | { 23 | _putchar(35); 24 | } 25 | if (i != size - 1) 26 | _putchar('\n'); 27 | } 28 | _putchar('\n'); 29 | } 30 | -------------------------------------------------------------------------------- /0x17-doubly_linked_lists/6-main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "lists.h" 5 | 6 | /** 7 | * main - check the code 8 | * 9 | * Return: Always EXIT_SUCCESS. 10 | */ 11 | int main(void) 12 | { 13 | dlistint_t *head; 14 | int sum; 15 | 16 | head = NULL; 17 | add_dnodeint_end(&head, 0); 18 | add_dnodeint_end(&head, 1); 19 | add_dnodeint_end(&head, 2); 20 | add_dnodeint_end(&head, 3); 21 | add_dnodeint_end(&head, 4); 22 | add_dnodeint_end(&head, 98); 23 | add_dnodeint_end(&head, 402); 24 | add_dnodeint_end(&head, 1024); 25 | sum = sum_dlistint(head); 26 | printf("sum = %d\n", sum); 27 | free_dlistint(head); 28 | head = NULL; 29 | return (EXIT_SUCCESS); 30 | } 31 | -------------------------------------------------------------------------------- /0x12-singly_linked_lists/lists.h: -------------------------------------------------------------------------------- 1 | #ifndef _LISTS_H_ 2 | #define _LISTS_H_ 3 | 4 | /** 5 | * struct list_s - singly linked list 6 | * @str: string - (malloc'ed string) 7 | * @len: length of the string 8 | * @next: points to the next node 9 | * 10 | * Description: singly linked list node structure 11 | */ 12 | typedef struct list_s 13 | { 14 | char *str; 15 | unsigned int len; 16 | struct list_s *next; 17 | } list_t; 18 | 19 | size_t print_list(const list_t *h); 20 | size_t list_len(const list_t *h); 21 | list_t *add_node(list_t **head, const char *str); 22 | list_t *add_node_end(list_t **head, const char *str); 23 | void free_list(list_t *head); 24 | void before_main() __attribute__((constructor)); 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /0x1A-hash_tables/5-hash_table_print.c: -------------------------------------------------------------------------------- 1 | #include "hash_tables.h" 2 | 3 | /** 4 | * hash_table_print - function that prints a hash table. 5 | * @ht: pointer to hash table to be printed. 6 | * 7 | * Return: No return. 8 | */ 9 | void hash_table_print(const hash_table_t *ht) 10 | { 11 | hash_node_t *test; 12 | unsigned long int i = 0, n = 0; 13 | 14 | if (ht == NULL) 15 | return; 16 | printf("{"); 17 | 18 | for (i = n; i < ht->size; i++) 19 | { 20 | if (ht->array[i] != NULL) 21 | { 22 | test = ht->array[i]; 23 | while (test) 24 | { 25 | printf("%s'%s': '%s'", n == 0 ? "" : ", ", 26 | test->key, test->value), n++; 27 | test = test->next; 28 | } 29 | } 30 | } 31 | printf("}\n"); 32 | } 33 | -------------------------------------------------------------------------------- /0x04-more_functions_nested_loops/9-fizz_buzz.c: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | #include 3 | /** 4 | * main - Program that prints the numbers from 1 to 100. 5 | * 6 | * Print Fizz if divisible by 3 and Buzz if divisible by 5. 7 | * Each number or word should be separated by a space. 8 | * You are allowed to use the standard library. 9 | * 10 | * Return: Always 0. 11 | */ 12 | 13 | int main(void) 14 | { 15 | int i; 16 | 17 | for (i = 1; i < 100; i++) 18 | { 19 | if ((i % 3 == 0) && (i % 5 == 0)) 20 | printf("FizzBuzz "); 21 | else if (i % 3 == 0) 22 | printf("Fizz "); 23 | else if (i % 5 == 0) 24 | printf("Buzz "); 25 | else 26 | printf("%d ", i); 27 | } 28 | printf("Buzz\n"); 29 | return (0); 30 | } 31 | -------------------------------------------------------------------------------- /0x06-pointers_arrays_strings/6-cap_string.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "main.h" 3 | 4 | /** 5 | * cap_string - func to capitalize all words of a string. 6 | * @string: pointer to string to be capitalized. 7 | * 8 | * Return: the capitalized string 9 | */ 10 | 11 | char *cap_string(char *string) 12 | { 13 | const char OFFSET = 'a' - 'A'; 14 | int j, i = 1; 15 | char sep[] = " \t\n,;.!?\"(){}"; 16 | 17 | i = 1; 18 | if (string[0] >= 'a' && string[0] <= 'z') 19 | string[0] -= OFFSET; 20 | while (string[i] != '\0') 21 | { 22 | for (j = 0; sep[j] != '\0'; j++) 23 | if (string[i - 1] == sep[j] && (string[i] >= 'a' && string[i] <= 'z')) 24 | string[i] -= OFFSET; 25 | i++; 26 | } 27 | return (string); 28 | } 29 | -------------------------------------------------------------------------------- /0x13-more_singly_linked_lists/4-free_listint.c: -------------------------------------------------------------------------------- 1 | #include "lists.h" 2 | #include 3 | 4 | /** 5 | * free_listint - function that frees a singly linked list. 6 | * @head: pointer to the head of linked list. 7 | * 8 | * Here we will use recursion unlike in the previous task. 9 | * Make sure there is no memory leaks. 10 | * 11 | * Return: No return. 12 | */ 13 | 14 | void free_listint(listint_t *head) 15 | { 16 | /* go to the end of the list then start freeing from there */ 17 | 18 | /* we have reached the end of the list */ 19 | if (head == NULL) 20 | return; 21 | /* free everything else */ 22 | free_listint(head->next); 23 | /* then free head */ 24 | free(head); 25 | /* elegante, eh? muy bien. 👏*/ 26 | } 27 | -------------------------------------------------------------------------------- /0x13-more_singly_linked_lists/9-main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "lists.h" 5 | 6 | /** 7 | * main - check the code 8 | * 9 | * Return: Always 0. 10 | */ 11 | int main(void) 12 | { 13 | listint_t *head; 14 | 15 | head = NULL; 16 | add_nodeint_end(&head, 0); 17 | add_nodeint_end(&head, 1); 18 | add_nodeint_end(&head, 2); 19 | add_nodeint_end(&head, 3); 20 | add_nodeint_end(&head, 4); 21 | add_nodeint_end(&head, 98); 22 | add_nodeint_end(&head, 402); 23 | add_nodeint_end(&head, 1024); 24 | print_listint(head); 25 | printf("-----------------\n"); 26 | insert_nodeint_at_index(&head, 5, 4096); 27 | print_listint(head); 28 | free_listint2(&head); 29 | return (0); 30 | } 31 | -------------------------------------------------------------------------------- /0x07-pointers_arrays_strings/8-print_diagsums.c: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | #include 3 | 4 | /** 5 | * print_diagsums - function that prints sum of the two diagonals, 6 | * of a square matrix of integers. 7 | * @a: pointer to array of characters. 8 | * @size: size of array. 9 | * 10 | * Return: no return. 11 | */ 12 | 13 | void print_diagsums(int *a, int size) 14 | { 15 | int i, max_size; 16 | int prinDiagonalSum = 0; 17 | int secDiagonalSum = 0; 18 | 19 | max_size = size * size; 20 | 21 | for (i = 0; i < max_size; i += size + 1) 22 | prinDiagonalSum += a[i]; 23 | 24 | for (i = size - 1; i < max_size - 1; i += size - 1) 25 | secDiagonalSum += a[i]; 26 | 27 | printf("%d, %d\n", prinDiagonalSum, secDiagonalSum); 28 | } 29 | -------------------------------------------------------------------------------- /0x05-pointers_arrays_strings/7-puts_half.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "main.h" 3 | 4 | /** 5 | * puts_half - Function that prints half of a string, followed by a new line. 6 | * @str: Pointer to the string. 7 | * 8 | * The function should print the second half of the string. 9 | * If the number of characters is odd, the function should print the last n 10 | * characters of the string, where n = (length_of_the_string - 1) / 2. 11 | * 12 | * Return: No return. 13 | */ 14 | 15 | void puts_half(char *str) 16 | { 17 | int j, i = 0; 18 | 19 | while (*(str + i)) 20 | i++; 21 | 22 | j = i / 2; 23 | if (i % 2) 24 | j += 1; 25 | 26 | while (j < i) 27 | { 28 | putchar(*(str + j)); 29 | j++; 30 | } 31 | putchar('\n'); 32 | } 33 | -------------------------------------------------------------------------------- /0x17-doubly_linked_lists/1-main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "lists.h" 5 | 6 | /** 7 | * main - check the code 8 | * 9 | * Return: Always EXIT_SUCCESS. 10 | */ 11 | int main(void) 12 | { 13 | dlistint_t *head; 14 | dlistint_t *new; 15 | dlistint_t hello = {8, NULL, NULL}; 16 | size_t n; 17 | 18 | head = &hello; 19 | new = malloc(sizeof(dlistint_t)); 20 | if (new == NULL) 21 | { 22 | dprintf(2, "Error: Can't malloc\n"); 23 | return (EXIT_FAILURE); 24 | } 25 | new->n = 9; 26 | head->prev = new; 27 | new->next = head; 28 | new->prev = NULL; 29 | head = new; 30 | n = dlistint_len(head); 31 | printf("-> %lu elements\n", n); 32 | free(new); 33 | return (EXIT_SUCCESS); 34 | } 35 | -------------------------------------------------------------------------------- /0x1A-hash_tables/6-hash_table_delete.c: -------------------------------------------------------------------------------- 1 | #include "hash_tables.h" 2 | 3 | /** 4 | * hash_table_delete - function that deletes a hash table. 5 | * @ht: pointer to hash table to be deleted. 6 | * 7 | * Return: No return. 8 | */ 9 | void hash_table_delete(hash_table_t *ht) 10 | { 11 | hash_node_t *current = NULL; 12 | unsigned long int i = 0; 13 | 14 | if (ht == NULL) 15 | return; 16 | 17 | for (i = 0; i < ht->size; i++) 18 | { 19 | if (ht->array[i] != NULL) 20 | { 21 | while (ht->array[i]) 22 | { 23 | current = ht->array[i]; 24 | free(current->key); 25 | free(current->value); 26 | ht->array[i] = ht->array[i]->next; 27 | free(current); 28 | } 29 | } 30 | } 31 | free(ht->array); 32 | free(ht); 33 | } 34 | -------------------------------------------------------------------------------- /0x0B-malloc_free/101-main.c: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | #include 3 | #include 4 | 5 | /** 6 | * print_tab - Prints an array of string 7 | * @tab: The array to print 8 | * 9 | * Return: nothing 10 | */ 11 | void print_tab(char **tab) 12 | { 13 | int i; 14 | 15 | for (i = 0; tab[i] != NULL; ++i) 16 | { 17 | printf("%s\n", tab[i]); 18 | } 19 | } 20 | 21 | /** 22 | * main - check the code for ALX School students. 23 | * 24 | * Return: 1 if an error occurred, 0 otherwise 25 | */ 26 | int main(void) 27 | { 28 | char **tab; 29 | 30 | tab = strtow(" Holberton School #cisfun "); 31 | if (tab == NULL) 32 | { 33 | printf("Failed\n"); 34 | return (1); 35 | } 36 | print_tab(tab); 37 | return (0); 38 | } 39 | -------------------------------------------------------------------------------- /0x13-more_singly_linked_lists/7-main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "lists.h" 5 | 6 | /** 7 | * main - check the code 8 | * 9 | * Return: Always 0. 10 | */ 11 | int main(void) 12 | { 13 | listint_t *head; 14 | listint_t *node; 15 | 16 | head = NULL; 17 | add_nodeint_end(&head, 0); 18 | add_nodeint_end(&head, 1); 19 | add_nodeint_end(&head, 2); 20 | add_nodeint_end(&head, 3); 21 | add_nodeint_end(&head, 4); 22 | add_nodeint_end(&head, 98); 23 | add_nodeint_end(&head, 402); 24 | add_nodeint_end(&head, 1024); 25 | print_listint(head); 26 | node = get_nodeint_at_index(head, 5); 27 | printf("%d\n", node->n); 28 | print_listint(head); 29 | free_listint2(&head); 30 | return (0); 31 | } 32 | -------------------------------------------------------------------------------- /0x17-doubly_linked_lists/0-main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "lists.h" 5 | 6 | /** 7 | * main - check the code 8 | * 9 | * Return: Always EXIT_SUCCESS. 10 | */ 11 | int main(void) 12 | { 13 | dlistint_t *head; 14 | dlistint_t *new; 15 | dlistint_t hello = {8, NULL, NULL}; 16 | size_t n; 17 | 18 | head = &hello; 19 | new = malloc(sizeof(dlistint_t)); 20 | if (new == NULL) 21 | { 22 | dprintf(2, "Error: Can't malloc\n"); 23 | return (EXIT_FAILURE); 24 | } 25 | new->n = 9; 26 | head->prev = new; 27 | new->next = head; 28 | new->prev = NULL; 29 | head = new; 30 | n = print_dlistint(head); 31 | printf("-> %lu elements\n", n); 32 | free(new); 33 | return (EXIT_SUCCESS); 34 | } 35 | -------------------------------------------------------------------------------- /0x07-pointers_arrays_strings/5-strstr.c: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | #include 3 | 4 | 5 | /** 6 | *_strstr - function that locates a substring. 7 | * @haystack: pointer to the null-terminated byte string to examine. 8 | * @needle: pointer to the null-terminated byte string to search for. 9 | * 10 | * Return: a pointer to the beginning of the located substring, 11 | * or NULL if the substring is not found. 12 | */ 13 | 14 | char *_strstr(char *haystack, char *needle) 15 | { 16 | int i, j; 17 | 18 | for (i = 0; haystack[i] != '\0'; i++) 19 | { 20 | for (j = 0; needle[j] != '\0'; j++) 21 | { 22 | if (haystack[i + j] != needle[j]) 23 | break; 24 | } 25 | if (needle[j] == '\0') 26 | return (haystack + i); 27 | } 28 | return (0); 29 | } 30 | -------------------------------------------------------------------------------- /0x04-more_functions_nested_loops/7-print_diagonal.c: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | /** 3 | * print_diagonal - function that draws a diagonal line on the terminal. 4 | * @n: the number of times the character \ should be printed. 5 | * 6 | * You can only use _putchar function to print. 7 | * The diagonal should end with a \n. 8 | * If n is 0 or less, the function should only print a \n. 9 | * 10 | * Return: No return. 11 | */ 12 | 13 | void print_diagonal(int n) 14 | { 15 | int a = 0; 16 | int b = 0; 17 | 18 | if (n > 0) 19 | { 20 | while (a < n) 21 | { 22 | while (b < a) 23 | { 24 | _putchar(' '); 25 | b++; 26 | } 27 | a++; 28 | b = 0; 29 | _putchar('\\'); 30 | _putchar('\n'); 31 | } 32 | } 33 | else 34 | _putchar('\n'); 35 | } 36 | -------------------------------------------------------------------------------- /0x05-pointers_arrays_strings/8-print_array.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "main.h" 3 | 4 | /** 5 | * print_array - Function that prints n elements of an array of integers, 6 | * followed by a new line. 7 | * @n: number of elements of array to be printed. 8 | * @a: Pointer to array of integers. 9 | * 10 | * Numbers must be separated by comma, followed by a space. 11 | * The numbers should be displayed in the same order as they are stored, 12 | * in the array. 13 | * You are allowed to use printf. 14 | * 15 | * Return: No return. 16 | */ 17 | 18 | void print_array(int *a, int n) 19 | { 20 | int len; 21 | 22 | for (len = 0; len < n; len++) 23 | { 24 | printf("%d", a[len]); 25 | if (len != n - 1) 26 | printf(", "); 27 | } 28 | printf("\n"); 29 | } 30 | -------------------------------------------------------------------------------- /0x17-doubly_linked_lists/5-main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "lists.h" 5 | 6 | /** 7 | * main - check the code 8 | * 9 | * Return: Always EXIT_SUCCESS. 10 | */ 11 | int main(void) 12 | { 13 | dlistint_t *head; 14 | dlistint_t *node; 15 | 16 | head = NULL; 17 | add_dnodeint_end(&head, 0); 18 | add_dnodeint_end(&head, 1); 19 | add_dnodeint_end(&head, 2); 20 | add_dnodeint_end(&head, 3); 21 | add_dnodeint_end(&head, 4); 22 | add_dnodeint_end(&head, 98); 23 | add_dnodeint_end(&head, 402); 24 | add_dnodeint_end(&head, 1024); 25 | print_dlistint(head); 26 | node = get_dnodeint_at_index(head, 5); 27 | printf("%d\n", node->n); 28 | free_dlistint(head); 29 | head = NULL; 30 | return (EXIT_SUCCESS); 31 | } 32 | -------------------------------------------------------------------------------- /0x13-more_singly_linked_lists/7-get_nodeint.c: -------------------------------------------------------------------------------- 1 | #include "lists.h" 2 | #include 3 | 4 | /** 5 | * get_nodeint_at_index - function that returns the nth node of a, 6 | * listint_t linked list. 7 | * @head: pointer to the head of linked list. 8 | * @index: index of the node, starting at 0. 9 | * 10 | * Make sure there is no memory leaks. 11 | * 12 | * Return: and returns the nth node or NULL if node is non-existent. 13 | */ 14 | 15 | listint_t *get_nodeint_at_index(listint_t *head, unsigned int index) 16 | { 17 | unsigned int i = 0; 18 | 19 | /* if there is no list return NULL */ 20 | if (head == NULL) 21 | return (NULL); 22 | 23 | while (i < index && head != NULL) 24 | { 25 | head = head->next; 26 | i++; 27 | } 28 | return (head); 29 | } 30 | -------------------------------------------------------------------------------- /0x17-doubly_linked_lists/7-main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "lists.h" 5 | 6 | /** 7 | * main - check the code 8 | * 9 | * Return: Always EXIT_SUCCESS. 10 | */ 11 | int main(void) 12 | { 13 | dlistint_t *head; 14 | 15 | head = NULL; 16 | add_dnodeint_end(&head, 0); 17 | add_dnodeint_end(&head, 1); 18 | add_dnodeint_end(&head, 2); 19 | add_dnodeint_end(&head, 3); 20 | add_dnodeint_end(&head, 4); 21 | add_dnodeint_end(&head, 98); 22 | add_dnodeint_end(&head, 402); 23 | add_dnodeint_end(&head, 1024); 24 | print_dlistint(head); 25 | printf("-----------------\n"); 26 | insert_dnodeint_at_index(&head, 5, 4096); 27 | print_dlistint(head); 28 | free_dlistint(head); 29 | head = NULL; 30 | return (EXIT_SUCCESS); 31 | } 32 | -------------------------------------------------------------------------------- /0x0F-function_pointers/2-int_index.c: -------------------------------------------------------------------------------- 1 | #include "function_pointers.h" 2 | 3 | /** 4 | * int_index - function that searches for an integer. 5 | * @array: pointer to array. 6 | * @size: number of elements in the array. 7 | * @cmp: pointer to the function to be used to compare values. 8 | * 9 | * If size <= 0, return -1. 10 | * If no element matches, return -1. 11 | * 12 | * Return: the index of the first element for which the cmp func, 13 | * does not return 0. 14 | */ 15 | 16 | int int_index(int *array, int size, int (*cmp)(int)) 17 | { 18 | int i; 19 | 20 | if (array && cmp) 21 | { 22 | if (size <= 0) 23 | return (-1); 24 | 25 | for (i = 0; i < size; i++) 26 | { 27 | if (cmp(*(array + i)) != 0) 28 | return (i); 29 | } 30 | } 31 | return (-1); 32 | } 33 | --------------------------------------------------------------------------------