-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cc7f54c
commit 01d5d8a
Showing
49 changed files
with
990 additions
and
119 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#include "main.h" | ||
/** | ||
* _isupper - checks for uppercase. | ||
* @c: character to check. | ||
* Return: 1 if c is uppercase, otherwise return 0. | ||
*/ | ||
|
||
int _isupper(int c) | ||
{ | ||
if (c >= 65 && c <= 90) | ||
{ | ||
return (1); | ||
} | ||
return (0); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#include <stdio.h> | ||
#include "main.h" | ||
/** | ||
* _isdigit - Checks for a digit (0-9). | ||
* @c: The number to be checked. | ||
* | ||
* Return: 1 if the number is a digit, 0 otherwise. | ||
*/ | ||
int _isdigit(int c) | ||
{ | ||
if (c >= 48 && c <= 57) | ||
{ | ||
return (1); | ||
} | ||
else | ||
{ | ||
return (0); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#include <stdio.h> | ||
|
||
/** | ||
* print_triangle - draws a triangle using multiple terminal lines and #'s. | ||
* @size: the height of the triangle. | ||
*/ | ||
void print_triangle(int size) | ||
{ | ||
int i, j, c; | ||
if (size <= 0) | ||
{ | ||
putchar('\n'); | ||
} | ||
else | ||
{ | ||
for (i = 0; i < size; i++) | ||
{ | ||
for (j = i + 1; j < size; j++) | ||
{ | ||
putchar(' '); | ||
} | ||
for (c = 0; c <= i; c++) | ||
{ | ||
putchar('#'); | ||
} | ||
putchar('\n'); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#include <stdio.h> | ||
/** | ||
* mul - multiplies two integers. | ||
* @a: the first number. | ||
* @b: the second number. | ||
* Return: the multiplication of a and b | ||
*/ | ||
int mul(int a, int b) | ||
{ | ||
return (a * b); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#include <stdio.h> | ||
/** | ||
* print_numbers - Prints the numbers from 0-9. | ||
*/ | ||
void print_numbers(void) | ||
{ | ||
int i; | ||
for (i = 0; i <= 9; i++) | ||
{ | ||
putchar(i + '0'); | ||
} | ||
putchar('\n'); | ||
return; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#include <stdio.h> | ||
|
||
/** | ||
* print_most_numbers - print all numbers except 2 and 4 | ||
* Return: 0 on success. | ||
*/ | ||
|
||
void print_most_numbers(void) | ||
{ | ||
int i; | ||
for (i = 0; i <= 9; i++) | ||
{ | ||
if (i == 2 || i == 4) | ||
{ | ||
continue; | ||
} | ||
putchar(i + '0'); | ||
} | ||
putchar('\n'); | ||
return; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#include "main.h" | ||
|
||
/** | ||
* more_numbers - Prints the numbers 0-14 ten times. | ||
*/ | ||
void more_numbers(void) | ||
{ | ||
int num, count; | ||
for (count = 0; count <= 9; count++) | ||
{ | ||
for (num = 0; num <= 14; num++) | ||
{ | ||
if (num > 9) | ||
_putchar((num / 10) + '0'); | ||
_putchar((num % 10) + '0'); | ||
} | ||
_putchar('\n'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#include <stdio.h> | ||
|
||
/** | ||
* print_line - Draws a straight line using the character _. | ||
* @n: The number of _ characters to be printed. | ||
*/ | ||
|
||
void print_line(int n) | ||
{ | ||
if (n <= 0) | ||
{ | ||
putchar('\n'); | ||
return; | ||
} | ||
while (n--) | ||
{ | ||
putchar('_'); | ||
} | ||
putchar('\n'); | ||
return; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#include <stdio.h> | ||
|
||
/** | ||
* print_diagonal - Draws a diagonal line using the \ character. | ||
* @n: The number of \ characters to be printed. | ||
*/ | ||
|
||
void print_diagonal(int n) | ||
{ | ||
int i, j; | ||
if (n <= 0) | ||
{ | ||
putchar('\n'); | ||
} | ||
else | ||
{ | ||
for (i = 0; i < n; i++) | ||
{ | ||
for (j = 0; j < i; j++) | ||
{ | ||
putchar(' '); | ||
} | ||
putchar('\\'); | ||
putchar('\n'); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#include <stdio.h> | ||
#include "main.h" | ||
/** | ||
* print_square - Prints a squareusing the character #. | ||
* @size: The size of the square. | ||
*/ | ||
|
||
void print_square(int size) | ||
{ | ||
int i, j; | ||
if (size > 0) | ||
{ | ||
for (i = 0; i < size; i++) | ||
{ | ||
for (j = 0; j < size; j++) | ||
{ | ||
_putchar('#'); | ||
} | ||
_putchar('\n'); | ||
} | ||
} | ||
else | ||
{ | ||
putchar('\n'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#include <stdio.h> | ||
/** | ||
* main - Prints the numbers 1 - 100, | ||
* instead of multiples of 3, print Fizz | ||
* instead of multiples of 5, print Buzz | ||
* for multiples of 3 and 5, print FizzBuzz. | ||
(* | ||
* Return: 0 on success. | ||
*/ | ||
int main(void) | ||
{ | ||
int i; | ||
for (i = 1; i <= 100; i++) | ||
{ | ||
if (i % 3 == 0 && i % 5 == 0) | ||
{ | ||
printf("FizzBuzz"); | ||
} | ||
else if (i % 3 == 0) | ||
{ | ||
printf("Fizz"); | ||
} | ||
else if (i % 5 == 0) | ||
{ | ||
printf("Buzz"); | ||
} | ||
else | ||
{ | ||
printf("%d", i); | ||
} | ||
if (i != 100) | ||
{ | ||
putchar(' '); | ||
} | ||
} | ||
putchar('\n'); | ||
return (0); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
more_functions_nested_loops |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
int _putchar(char c); | ||
int _isupper(int c); | ||
int _isdigit(int c); | ||
int mul(int a, int b); | ||
void print_numbers(void); | ||
void print_most_numbers(void); | ||
void more_numbers(void); | ||
void print_line(int n); | ||
void print_diagonal(int n); | ||
void print_square(int size); | ||
void print_triangle(int size); | ||
void print_number(int n); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#include <string.h> | ||
#include "main.h" | ||
/** | ||
* _memset - Fill memory with a constant byte | ||
* @s: memory area to fill | ||
* @b: constant byte to fill | ||
* @n: bytes of memory area to fill | ||
* | ||
* Return: the memory area filled | ||
*/ | ||
char *_memset(char *s, char b, unsigned int n) | ||
{ | ||
unsigned int i; | ||
for (i = 0; i < n; i++) | ||
{ | ||
s[i] = b; | ||
} | ||
return (s); | ||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#include "main.h" | ||
#include <stdio.h> | ||
/** | ||
* _memcpy - function that copies memory area. | ||
* @dest: pointer to desitnation array | ||
* @src: pointer to the sorce array | ||
* @n: number of bytes to be copied from source to destination | ||
* Return: destenation | ||
*/ | ||
char *_memcpy(char *dest, char *src, unsigned int n) | ||
{ | ||
unsigned int i; | ||
for (i = 0; i < n; i++) | ||
{ | ||
dest[i] = src[i]; | ||
} | ||
return (dest); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#include "main.h" | ||
#include <stdio.h> | ||
/** | ||
* set_string - function that sets the value of a pointer to a char. | ||
* @s: the destination | ||
* @to: the source | ||
* Retrun: nothing | ||
*/ | ||
void set_string(char **s, char *to) | ||
{ | ||
*s = to; | ||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#include "main.h" | ||
#include <stdio.h> | ||
/** | ||
* _strchr - Locates a character in a string. | ||
* @s: The string to be searched. | ||
* @c: The character to be located. | ||
* | ||
* Return: If c is found - a pointer to the first occurence. | ||
* If c is not found - NULL. | ||
*/ | ||
char *_strchr(char *s, char c) | ||
{ | ||
int i; | ||
for (i = 0; s[i] >= '\0'; i++) | ||
{ | ||
if (s[i] == c) | ||
{ | ||
return (s + i); | ||
} | ||
} | ||
return ('\0'); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#include "main.h" | ||
#include <stdio.h> | ||
/** | ||
* _strspn - function that gets the length of a prefix substring. | ||
* @s: The string in which the characters of string s are searched | ||
* @accept: Another string, the characters of this string are searched in s | ||
* Return: number of bytes was matched | ||
*/ | ||
unsigned int _strspn(char *s, char *accept) | ||
{ | ||
int len = 0, i, j; | ||
for (i = 0; s[i] != '\0'; i++) | ||
{ | ||
if (s[i] != ' ') | ||
{ | ||
for (j = 0; accept[j] != '\0'; j++) | ||
{ | ||
if (s[i] == accept[j]) | ||
{ | ||
len++; | ||
} | ||
} | ||
} | ||
else | ||
{ | ||
return (len); | ||
} | ||
} | ||
return (len); | ||
} |
Oops, something went wrong.