Skip to content

Commit

Permalink
upload missing files
Browse files Browse the repository at this point in the history
  • Loading branch information
alyalsayed committed Apr 5, 2023
1 parent cc7f54c commit 01d5d8a
Show file tree
Hide file tree
Showing 49 changed files with 990 additions and 119 deletions.
15 changes: 15 additions & 0 deletions 0x04-more_functions_nested_loops/0-isupper.c
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);
}
19 changes: 19 additions & 0 deletions 0x04-more_functions_nested_loops/1-isdigit.c
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);
}
}
29 changes: 29 additions & 0 deletions 0x04-more_functions_nested_loops/10-print_triangle.c
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');
}
}
}
11 changes: 11 additions & 0 deletions 0x04-more_functions_nested_loops/2-mul.c
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);
}
14 changes: 14 additions & 0 deletions 0x04-more_functions_nested_loops/3-print_numbers.c
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;
}
21 changes: 21 additions & 0 deletions 0x04-more_functions_nested_loops/4-print_most_numbers.c
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;
}
19 changes: 19 additions & 0 deletions 0x04-more_functions_nested_loops/5-more_numbers.c
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');
}
}
21 changes: 21 additions & 0 deletions 0x04-more_functions_nested_loops/6-print_line.c
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;
}
27 changes: 27 additions & 0 deletions 0x04-more_functions_nested_loops/7-print_diagonal.c
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');
}
}
}
26 changes: 26 additions & 0 deletions 0x04-more_functions_nested_loops/8-print_square.c
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');
}
}
38 changes: 38 additions & 0 deletions 0x04-more_functions_nested_loops/9-fizz_buzz.c
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);
}
1 change: 1 addition & 0 deletions 0x04-more_functions_nested_loops/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
more_functions_nested_loops
12 changes: 12 additions & 0 deletions 0x04-more_functions_nested_loops/main.h
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);
19 changes: 19 additions & 0 deletions 0x07-pointers_arrays_strings/0-memset.c
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.
18 changes: 18 additions & 0 deletions 0x07-pointers_arrays_strings/1-memcpy.c
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);
}
12 changes: 12 additions & 0 deletions 0x07-pointers_arrays_strings/100-set_string.c
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.
22 changes: 22 additions & 0 deletions 0x07-pointers_arrays_strings/2-strchr.c
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');
}
30 changes: 30 additions & 0 deletions 0x07-pointers_arrays_strings/3-strspn.c
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);
}
Loading

0 comments on commit 01d5d8a

Please sign in to comment.