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 LowerAlpha;

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

printf("Enter you score:");
scanf("%lf", &score);

if (score >= 80)
{
printf("You are eligible to be enrolled\n");
}
else if (score < 80)
{
printf("You are not eligible to be enrolled\n");
}
}
26 changes: 25 additions & 1 deletion TASKS/Task 003.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,28 @@ 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 num;

printf("Enter and integer: ");
scanf("%d", &num);

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

*/
*/

#include <stdio.h>

int main(void)
{
char StrName[20];
int age;

printf("Enter your name: ");
scanf("%s", &StrName);

printf("Enter your age: ");
scanf("%d", &age);

printf("Your name is %s and you are %d years old\n", StrName, age);
return;
}
20 changes: 19 additions & 1 deletion TASKS/Task 005.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,22 @@
/*
Write a program in C to find the square of any number
using the function.
*/
*/
#include <stdio.h>

int sqr(int num)
{
return num * num;
}
int main()
{
int num, result;

printf("Enter a number: ");
scanf("%d", &num);

result = sqr(num);
printf("Square of %d is %d", num, result);

return 0;
}
26 changes: 25 additions & 1 deletion TASKS/Task 006.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,28 @@
/*
Write a program in C to check a given number is even
or odd using the function.
*/
*/

#include <stdio.h>

void odd_even(int num)
{
if (num % 2 == 0)
{
printf("It's even\n");
}
else if (num % 2 != 0)
{
printf("It's odd\n");
}
return;
}

int main()
{
int num;
printf("Enter an integer: ");
scanf("%d", &num);

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

#include <stdio.h>

void UpperAlph()
{
char Caps;

for (Caps = 'A'; Caps <= 'Z'; Caps++)
{
printf("%c ", Caps);
}
}

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

#include <stdio.h>

void LowerAlph()
{
char letters;

for (letters = 'a'; letters <= 'z'; letters++)
{
printf("%c ", letters);
}
}

int main()
{
LowerAlph();
}
25 changes: 24 additions & 1 deletion TASKS/Task 009.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,27 @@
Write a function that checks for lowercase character.
That is, when passed in an arguments, it checks if the
argument is lowercase or uppercase.
*/
*/

void Lower(char letter)
{

if (letter >= 'a' && letter <= 'z')
{
printf("It's lowercase ");
}
else if (letter >= 'A' && letter <= 'Z')
{
printf("It's not lowercase ");
}
}

int main()
{
char letter;

printf("Enter a letter: ");
scanf("%c", &letter);

Lower(letter);
}
27 changes: 26 additions & 1 deletion TASKS/Task 010.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,29 @@
Write a function that computes the absolute
value of an integer.
Understand what an absolute value is, before attempting it.
*/
*/

#include <stdio.h>

int AbsVal(int num)
{
if(num < 0)
{
return (-num);
}
if (num >= 0)
{
return (num);
}
}

int main()
{
int num;
printf("Enter a number: ");
scanf("%d", &num);

int Absolute = AbsVal(num);

printf("The absolute value if %d is %d\n", num, Absolute);
}
19 changes: 18 additions & 1 deletion TASKS/Task 011.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,21 @@ Output should look like this;
9 x 1 = 9
9 x 2 = 18
... and so on till 12
*/
*/

#include <stdio.h>

void NTab()
{
int i;

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

int main()
{
NTab();
}
22 changes: 21 additions & 1 deletion TASKS/Task 012.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 adds two integers and prints
the result.
*/
*/

#include <stdio.h>

void AddInt(int num, int num1)
{
int sum = num + num1;

printf("The sum of %d and %d = %d\n", num, num1, sum);
}

int main()
{
int num1, num2;

printf("Enter an integer: ");
scanf("%d", &num1);
printf("Enter another integer: ");
scanf("%d", &num2);
AddInt(num1, num2);
}
34 changes: 33 additions & 1 deletion TASKS/Task 013.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,36 @@ 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>

void NatNum(int n)
{
int i;
if (n >= 0 && n <= 100)
{
for (i = n; i <= 100; i++)
{
printf("%d ", i);
}
}
else if (n < 0)
{
printf("This is not a natural number\n");
}
else
{
printf("This number exceeds 100\n");
}
}


int main()
{
int num;

printf("Enter a number from 0 - 100: ");
scanf("%d", &num);
NatNum(num);
}
26 changes: 25 additions & 1 deletion TASKS/Task 014.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,28 @@ Your output should look like this;
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14
...up to 10 times
*/
*/

#include <stdio.h>

void PrintNum()
{
int i = 1, j = 0;

while (i <= 10)
{
while (j <= 14)
{
printf("%d ", j);
j++;
}
printf("\n");
i++;
j = 0;
}
}

int main()
{
PrintNum();
}
Loading