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
17 changes: 16 additions & 1 deletion TASKS/Task 001.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,19 @@ 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 small;

for (small = 'a'; small <= 'z'; small++)
{
if (small != 'e' && small != 'q')
printf("%c, \n", small);
}
printf('\n');
return 0;
}
24 changes: 23 additions & 1 deletion TASKS/Task 002.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,26 @@ 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;

printf("Please enter your score:");
scanf("%d", &score);

if (score < 80)
{
printf("Sorry, you are not eligible to be enrolled,try again");
}
else if (score >= 80)
{
printf("Congratulations, you have been enrolled);
}
printf('\n');
return 0;
}
27 changes: 26 additions & 1 deletion TASKS/Task 003.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,29 @@ If the number is zero, display 'This is zero'

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

*/
*/

#include <stdio.h>

int main()
{
int Number;

printf("Please input your number: ");
scanf("%d", &Number);

if (Number == 0)
{
printf("This is zero");
}
else if (Number % 2 == 0)
{
printf("userInput is even");
}
else if (Number % 2 != 0)
{
printf("userInput is odd");
}
printf('\n');
return 0;
}
20 changes: 19 additions & 1 deletion TASKS/Task 004.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,22 @@ How old are you?: 65
Output:
Your name is David and you are 65 years old.

*/
*/

#include <stdio.h>

int main()
{
char name[30];
int age;

printf("What is your Name: \n");
scanf("%s", &name);
printf("How old are you?: \n");
scanf("%d", &age);

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

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

#include <stdio.h>

int squareNum(int num)
{
return (num * num);
}

int main()
{
int num;
int n;

printf("Input a whole number: "\n);
scanf("%d", &num);

n = squareNum(num);
printf("The square of %d is: %d", num, n);

printf('\n');
return 0;
}
30 changes: 29 additions & 1 deletion TASKS/Task 006.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,32 @@
/*
Write a program in C to check a given number is even
or odd using the function.
*/
*/

#include <stdio.h>

int EvenOrOdd(int num)
{
if(num % 2 == 0)
{
printf("The number s an even number");
}
else
{
printf("The number is an odd number");
}
}

int main()
{
int num;
int n;

printf("Please input a whole number: ");
scanf("%d", &num);

n = EvenOrOdd(num);

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

#include <stdio.h>

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

int main()
{
char alpha;
char big;

big = upper(alpha);

printf('\n');
return 0;
}
26 changes: 23 additions & 3 deletions TASKS/Task 008.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,24 @@
/*write your solution after the comment
Write a function that prints the alphabet, in lowercase
/*
write your solution after the comment
Write a function that prints the alphabet, in lowercase,
followed by a new line.
*/
*/

#include <stdio.h>

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

int main()
{
char alpha;
char small;

small = lower(alpha);

printf('\n');
return 0;
}
34 changes: 33 additions & 1 deletion TASKS/Task 009.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,36 @@
Write a function that checks for lowercase character.
That is, when passed in an arguments, it checks if the
argument is lowercase or uppercase.
*/
*/

#include <stdio.h>

char lowerOrUpper(char alpha)
{
if(alpha >= 'A' && alpha <= 'Z')
{
printf("This is an uppercase character");
}
else if(alpha >= 'a' && alpha <= 'z');
{
printf("This is a lowercase character");
}
else
{
printf("This is not a character");
}
}

int main()
{
char alpha;
char x;

printf("Please input a character: ");
scanf("%c", &alpha);

x = lowerOrUpper(alpha);

printf('\n');
return 0;
}
31 changes: 30 additions & 1 deletion TASKS/Task 010.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,33 @@
Write a function that computes the absolute
value of an integer.
Understand what an absolute value is, before attempting it.
*/
*/

#include <stdio.h>

int absValue(int val)
{
if(val < 0)
{
val = (-1) * val;
printf("The absolute value is: %d ", val);
}
else
{
printf("the absolute value is %d", val);
}
}

int main()
{
int val;
int x;

printf("please enter a number: ");
scanf("%d", &val);

x = absval(val);

printf('\n');
return 0;
}
24 changes: 23 additions & 1 deletion TASKS/Task 011.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,26 @@ Output should look like this;
9 x 1 = 9
9 x 2 = 18
... and so on till 12
*/
*/

#include <stdio.h>

int timesTable(int num)
{
int x;
for(x = 0; x <= 12; x++)
{
printf("%d * %d = %d \n", num, x, (num * x));
}
}

int main()
{
int num = 9;
int n;

n = timesTable(num);
printf("Times Table of 9);

printf('\n');
return 0;
25 changes: 24 additions & 1 deletion TASKS/Task 012.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,27 @@
/*Write your solution after the comment
Write a function that adds two integers and prints
the result.
*/
*/

int add(int num, int num2)
{
int sum = num + num2;
printf("Therefore, %d + %d = %d \n", num, num2, sum);
}

int main()
{
int first;
int second;
int n;

printf("Please enter the first Integer: ");
scanf("%d", &first);
printf("Please enter the second Integer: ");
scanf("%d", &second);

n = add(first, second);

printf('\n');
return 0;
}
26 changes: 25 additions & 1 deletion TASKS/Task 013.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,28 @@ Write a function that prints all natural numbers from n to 100,
followed by a new line.
That is n is your argument, it should print from any number
passed as argument till 100.
*/
*/

#include <stdio.h>

int printNaturalNum(int num, int N)
{
for(num = N; num <= 100; num++)
printf("%d\n", num);
}

int main()
{
int i = 100;
int n;
int x;

printf("Enter your N Number: ");
scanf("%d", &n);

printf("Your Natural numbers from %d to %d: \n", n, i);
x = printNaturalNum(i, n);

printf("\n");
return 0;
}
Loading