Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion TASKS/Task 001.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,18 @@ Write a program that prints the alphabet in lowercase, followed by a new line.
Print all the letters except q and e

use printf
*/
*/
#include <stdio.h>

int main(void)
{
char i;

for (i = 'a'; i <= 'z'; i++)
{
if (i == 'q' || i == 'e')
continue;
printf("%c\n", i);
}
return (0);
}
26 changes: 25 additions & 1 deletion TASKS/Task 002.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,28 @@ Write a program that asks and reads the score of a user
If the score is less than 80, display to the user that they
are not elgible to be enrolled.
If the score is greater than or equal 80, they can be enrolled.
*/
*/
#include <stdio.h>

int main(void)
{
int score;
int valid_input = 0;
while (valid_input == 0)
{
printf("input your score: \n");
valid_input = scanf("%d", &score);
if (valid_input == 0)
{
printf("Invalid input. Please enter a number.\n");
scanf("%*s");
}
}
if (score < 80)
printf("you are not eligible for this course\n");

if (score >= 80)
printf("congratulations, you can enrol for this course\n");

return (0);
}
20 changes: 19 additions & 1 deletion TASKS/Task 003.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,22 @@ If the number is zero, display 'This is zero'

NOTE: 'userInput' should be the number entered by the user.

*/
*/
#include <stdio.h>

int main(void)
{
int userInput;

printf("input a number\n");
scanf("%d\n", &userInput);

if (userInput == 0)
printf("You entered zero\n");
else if (userInput % 2 == 0)
printf("%d is even\n", userInput);
else
printf("%d is odd\n", userInput);

return (0);
}
25 changes: 24 additions & 1 deletion TASKS/Task 004.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,27 @@ How old are you?: 65
Output:
Your name is David and you are 65 years old.

*/
*/

/**
* main - checks code
* Return: zero
*/
#include <stdio.h>
#include <string.h>

int main(void)
{
char name[50];
int age;

printf("Please enter your name: \n");
scanf("%s \n", name);

printf("input your age: \n");
scanf("%d \n", &age);

printf("Your name is %s and you are %d years old\n", name, age);

return (0);
}
28 changes: 27 additions & 1 deletion TASKS/Task 005.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,30 @@
/*
Write a program in C to find the square of any number
using the function.
*/
*/

/**
* square - prints square of a number
* @num: number to square
* Return: square
*/
#include <stdio.h>
int square(int num)
{
return (num * num);
}
/**
* main - checks code
* @num: number
* Return: zero
*/
int main()
{
int num;

num = 2;
printf("square of %d is %d\n", num, square(num));

return (0);
}

36 changes: 35 additions & 1 deletion TASKS/Task 006.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,38 @@
/*
Write a program in C to check a given number is even
or odd using the function.
*/
*/
#include <stdio.h>

/**
* checker - checks for even or odd number
* @num: number to check
* Return: 1 for odd number, 0 for even number
*/

int checker(int num)
{
if (num % 2 == 0)
return (0);
else if (num % 2 == 1)
return (1);
}

/**
* main - checks code
* Return: 0
*/
int main(void)
{
int num;
printf("Enter a number: \n");
scanf("%d", &num);

int result = checker(num);
if (result == 0)
printf("%d is even\n", num);
else
printf("%d is odd\n", num);

return (0);
}
28 changes: 27 additions & 1 deletion TASKS/Task 007.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,30 @@
write your solution after the comment
Write a function that prints the alphabet, in uppercase,
followed by a new line.
*/
*/

/**
* uppercase - prints alphabets in uppercase
* @c: characters
*
*/
#include <stdio.h>

void uppercase()
{
char c;

for (char c ='A'; c <= 'Z'; c++)
printf("%c\n", c);
}

/**
* main - checks code
* Return: 0
*/

int main(void)
{
uppercase();
return (0);
}
28 changes: 27 additions & 1 deletion TASKS/Task 008.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,30 @@
/*write your solution after the comment
Write a function that prints the alphabet, in lowercase
followed by a new line.
*/
*/

/**
* lowercase - prints alphabets in lowercase
* @c: characters
*
*/
#include <stdio.h>

void lowercase()
{
char c;

for (char c ='a'; c <= 'z'; c++)
printf("%c\n", c);
}

/**
* main - checks code
* Return: 0
*/

int main(void)
{
lowercase();
return (0);
}
2 changes: 1 addition & 1 deletion TASKS/Task 009.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
Write a function that checks for lowercase character.
That is, when passed in an arguments, it checks if the
argument is lowercase or uppercase.
*/
*/
Binary file added TASKS/task001
Binary file not shown.
Binary file added TASKS/task002
Binary file not shown.
Binary file added TASKS/task003
Binary file not shown.
Binary file added TASKS/task004
Binary file not shown.
Binary file added TASKS/task005
Binary file not shown.
Binary file added TASKS/task006
Binary file not shown.
Binary file added TASKS/task007
Binary file not shown.
Binary file added TASKS/task008
Binary file not shown.