From d2d3f5e51edb00f4a29d121ded7d75d72e6a3c65 Mon Sep 17 00:00:00 2001 From: Gracie1st <112003488+Gracie1st@users.noreply.github.com> Date: Wed, 18 Jan 2023 15:31:35 +0100 Subject: [PATCH 01/15] Update Task 001.c --- TASKS/Task 001.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/TASKS/Task 001.c b/TASKS/Task 001.c index 24be041..a1b8640 100644 --- a/TASKS/Task 001.c +++ b/TASKS/Task 001.c @@ -1,7 +1,10 @@ -/* Write your program after the comment -Write a program that prints the alphabet in lowercase, followed by a new line. +#include -Print all the letters except q and e +int main() { + char i; + for (i = 'a'; i <='z'; ++i) + if (i != 'e' && i != 'q') + printf("%c", i); -use printf -*/ \ No newline at end of file + return 0; +} From df19d52b04ca829865c4e0b34f7770b18b73597b Mon Sep 17 00:00:00 2001 From: Gracie1st <112003488+Gracie1st@users.noreply.github.com> Date: Fri, 20 Jan 2023 04:28:43 +0100 Subject: [PATCH 02/15] Update Task 001.c --- TASKS/Task 001.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/TASKS/Task 001.c b/TASKS/Task 001.c index a1b8640..c394f75 100644 --- a/TASKS/Task 001.c +++ b/TASKS/Task 001.c @@ -1,3 +1,8 @@ + /* Write your program after the comment +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 int main() { From fb5ded4d42bf18c9ec229d9cbd099e35286aead6 Mon Sep 17 00:00:00 2001 From: Gracie1st <112003488+Gracie1st@users.noreply.github.com> Date: Fri, 20 Jan 2023 04:30:01 +0100 Subject: [PATCH 03/15] Update Task 002.c --- TASKS/Task 002.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/TASKS/Task 002.c b/TASKS/Task 002.c index 5cdd390..7c2e3f1 100644 --- a/TASKS/Task 002.c +++ b/TASKS/Task 002.c @@ -3,4 +3,17 @@ 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. -*/ \ No newline at end of file +*/ +#include + +int main() { + int score; + printf("Enter an integer: "); + scanf("%d", &score); + if (score < 80) { + printf("You are not eligible to enrolled"); + } else { + printf("You are enrolled"); + } + return 0; +} From 173b8f160a1deaa8ffe329771e4a7955af0b5616 Mon Sep 17 00:00:00 2001 From: Gracie1st <112003488+Gracie1st@users.noreply.github.com> Date: Fri, 20 Jan 2023 05:02:51 +0100 Subject: [PATCH 04/15] Update Task 003.c --- TASKS/Task 003.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/TASKS/Task 003.c b/TASKS/Task 003.c index 7fca79c..17c76c6 100644 --- a/TASKS/Task 003.c +++ b/TASKS/Task 003.c @@ -6,4 +6,20 @@ If the number is zero, display 'This is zero' NOTE: 'userInput' should be the number entered by the user. -*/ \ No newline at end of file +*/ +#include + +int main() { + int n; + printf("Enter an integer: "); + scanf("%d", &n); + if (n == 0) { + printf("You entered zero\n"); + } + else if (n %2==0) { + printf("You entered an even number\n"); + } else { + printf("You entered an odd number\n"); + } + return 0; +} From f93ba2a6415a02a9790966671daa12b9d22705fe Mon Sep 17 00:00:00 2001 From: Gracie1st <112003488+Gracie1st@users.noreply.github.com> Date: Thu, 23 Feb 2023 00:20:53 +0100 Subject: [PATCH 05/15] Update Task 004.c --- TASKS/Task 004.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/TASKS/Task 004.c b/TASKS/Task 004.c index 17ee38c..666e97a 100644 --- a/TASKS/Task 004.c +++ b/TASKS/Task 004.c @@ -11,4 +11,18 @@ How old are you?: 65 Output: Your name is David and you are 65 years old. -*/ \ No newline at end of file +*/ +#include + +int main() { + char n[50]; + int a; +//where n represents the name of user, while a represents the user's age + printf("Enter Your name: \n"); + scanf("%s", n); + printf("Enter your Age: \n"); + scanf("%d", &a); + printf("Your name is %s and you are %d years old.\n", n, a); + + return 0; +} From e504fd1ed3fb7d9db1f2fb895b579316800e9be3 Mon Sep 17 00:00:00 2001 From: Gracie1st <112003488+Gracie1st@users.noreply.github.com> Date: Thu, 23 Feb 2023 01:10:27 +0100 Subject: [PATCH 06/15] Update Task 005.c --- TASKS/Task 005.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/TASKS/Task 005.c b/TASKS/Task 005.c index db32ab3..933e3cd 100644 --- a/TASKS/Task 005.c +++ b/TASKS/Task 005.c @@ -1,4 +1,14 @@ /* Write a program in C to find the square of any number using the function. -*/ \ No newline at end of file +*/ +#include + +int main() { + int num = 6; + + int square = num * num; + printf("The square of your number is: %d", square); + + return 0; +} From a2915ea97c690c9d114c63a212f710ed8738a9d4 Mon Sep 17 00:00:00 2001 From: Gracie1st <112003488+Gracie1st@users.noreply.github.com> Date: Tue, 28 Feb 2023 10:31:57 +0100 Subject: [PATCH 07/15] Update Task 006.c --- TASKS/Task 006.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/TASKS/Task 006.c b/TASKS/Task 006.c index dc0b9af..91535a8 100644 --- a/TASKS/Task 006.c +++ b/TASKS/Task 006.c @@ -1,4 +1,23 @@ /* Write a program in C to check a given number is even or odd using the function. -*/ \ No newline at end of file +*/ +// Online C compiler to run C program online +#include +void even_or_odd() +{ + int num; + printf("Enter a number: "); + if (scanf("%d", &num)) + { + if (num%2 == 0) + printf("%d is an even number\n",num); + else + printf("%d is an odd number\n", num); + } +} +int main (void) +{ + even_or_odd(); + return (0); +} From 7556ea1bc8052fefa44b643a077a60a06b6f485e Mon Sep 17 00:00:00 2001 From: Gracie1st <112003488+Gracie1st@users.noreply.github.com> Date: Tue, 28 Feb 2023 11:06:21 +0100 Subject: [PATCH 08/15] Thanks david --- TASKS/Task 007.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/TASKS/Task 007.c b/TASKS/Task 007.c index 07ea0fb..d5054bf 100644 --- a/TASKS/Task 007.c +++ b/TASKS/Task 007.c @@ -2,4 +2,15 @@ write your solution after the comment Write a function that prints the alphabet, in uppercase, followed by a new line. -*/ \ No newline at end of file +*/ +#include +void capital_letters() +{ + for (char i = 'A'; i <= 'Z'; ++i) + printf("%c\n", i); +} +int main() +{ + capital_letters(); + return (0); +} From c408d2e637a82aa06401e5dac5c67a9c64872f28 Mon Sep 17 00:00:00 2001 From: Gracie1st <112003488+Gracie1st@users.noreply.github.com> Date: Tue, 28 Feb 2023 11:19:41 +0100 Subject: [PATCH 09/15] Thanks David --- TASKS/Task 008.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/TASKS/Task 008.c b/TASKS/Task 008.c index 0a815b2..a640a32 100644 --- a/TASKS/Task 008.c +++ b/TASKS/Task 008.c @@ -1,4 +1,15 @@ /*write your solution after the comment Write a function that prints the alphabet, in lowercase followed by a new line. -*/ \ No newline at end of file +*/ +#include +void capital_letters() +{ + for (char i = 'a'; i <= 'z'; ++i) + printf("%c\n", i); +} +int main() +{ + capital_letters(); + return (0); +} From 9b7662270be7315ffbdf2cb1b4f91cd70836c441 Mon Sep 17 00:00:00 2001 From: Gracie1st <112003488+Gracie1st@users.noreply.github.com> Date: Wed, 1 Mar 2023 22:37:58 +0100 Subject: [PATCH 10/15] Update Task 009.c --- TASKS/Task 009.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/TASKS/Task 009.c b/TASKS/Task 009.c index d481f90..0dfd032 100644 --- a/TASKS/Task 009.c +++ b/TASKS/Task 009.c @@ -2,4 +2,21 @@ Write a function that checks for lowercase character. That is, when passed in an arguments, it checks if the argument is lowercase or uppercase. -*/ \ No newline at end of file +*/ +// Online C compiler to run C program online +#include +void zero_to_14_10x() +{ + int x,y; + for(x >= 0; x <= 14; ++x) + { + for(y=0; y<15; y++) + printf("%d\n", x); + } +} +int main() +{ + zero_to_14_10x(); + + return 0; +} From 5339f421ca75202bf6f6e6000372321eafea9d85 Mon Sep 17 00:00:00 2001 From: Gracie1st <112003488+Gracie1st@users.noreply.github.com> Date: Thu, 2 Mar 2023 06:33:37 +0100 Subject: [PATCH 11/15] going --- TASKS/Task 010.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/TASKS/Task 010.c b/TASKS/Task 010.c index 62c07e9..49eedfa 100644 --- a/TASKS/Task 010.c +++ b/TASKS/Task 010.c @@ -2,4 +2,15 @@ Write a function that computes the absolute value of an integer. Understand what an absolute value is, before attempting it. -*/ \ No newline at end of file +*/ +#include + +int abs(int x) { + return x < 0 ? -x : x; +} + +int main() { + int x = -5; + printf("The absolute value of %d is %d.\n", x, abs(x)); + return 0; +} From e7dcd38d6602b221a678bf36b2c476b6612f93e5 Mon Sep 17 00:00:00 2001 From: Gracie1st <112003488+Gracie1st@users.noreply.github.com> Date: Thu, 2 Mar 2023 07:00:39 +0100 Subject: [PATCH 12/15] Going --- TASKS/Task 011.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/TASKS/Task 011.c b/TASKS/Task 011.c index 96c4add..41a6c52 100644 --- a/TASKS/Task 011.c +++ b/TASKS/Task 011.c @@ -6,4 +6,18 @@ Output should look like this; 9 x 1 = 9 9 x 2 = 18 ... and so on till 12 -*/ \ No newline at end of file +*/ +#include +void table_9() +{ + int x; + int y; + if (x = 9) + for (y>=0; y<=12; y++) + printf("%d X %d = %d\n", x, y,x*y); +} +int main() +{ + table_9(); + return 0; +} From de242d67c2597c364f32a24679b4a2b315f42005 Mon Sep 17 00:00:00 2001 From: Gracie1st <112003488+Gracie1st@users.noreply.github.com> Date: Thu, 2 Mar 2023 07:04:21 +0100 Subject: [PATCH 13/15] Update Task 012.c --- TASKS/Task 012.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/TASKS/Task 012.c b/TASKS/Task 012.c index 735a015..e3d0fa2 100644 --- a/TASKS/Task 012.c +++ b/TASKS/Task 012.c @@ -1,4 +1,17 @@ /*Write your solution after the comment Write a function that adds two integers and prints the result. -*/ \ No newline at end of file +*/ +#include +void sum() +{ + int x; + int y; + if (x = 9, y=8) + printf("%d + %d = %d\n", x, y,x+y); +} +int main() +{ + sum(); + return 0; +} From 90d8c5290e46f7d7e956a27235fa8a631a3d1a12 Mon Sep 17 00:00:00 2001 From: Gracie1st <112003488+Gracie1st@users.noreply.github.com> Date: Thu, 2 Mar 2023 07:10:45 +0100 Subject: [PATCH 14/15] GOing --- TASKS/Task 012.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/TASKS/Task 012.c b/TASKS/Task 012.c index e3d0fa2..215414d 100644 --- a/TASKS/Task 012.c +++ b/TASKS/Task 012.c @@ -2,6 +2,25 @@ Write a function that adds two integers and prints the result. */ +#include +void sum() +{ + int x; + int y; + printf("Enter an integer: "); + scanf("%d", &x); + printf("Enter another integer you want to add: "); + scanf("%d", &y); + printf("%d + %d = %d\n", x, y,x+y); +} +int main() +{ + sum(); + return 0; +} + +OR + #include void sum() { From 9e892f8590d91eeb39f2de69a3a1a4b859d7c67a Mon Sep 17 00:00:00 2001 From: Gracie1st <112003488+Gracie1st@users.noreply.github.com> Date: Thu, 2 Mar 2023 07:18:03 +0100 Subject: [PATCH 15/15] GOing --- TASKS/Task 013.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/TASKS/Task 013.c b/TASKS/Task 013.c index 068a6cc..0e1841e 100644 --- a/TASKS/Task 013.c +++ b/TASKS/Task 013.c @@ -3,4 +3,18 @@ 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. -*/ \ No newline at end of file +*/ +#include +void nat() +{ + int n; + printf("Enter an integer: "); + scanf("%d", &n); + for (n >=n; n<=100; n++) + printf("%d\n", n); +} +int main() +{ + nat(); + return 0; +}