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: 12 additions & 4 deletions TASKS/Task 001.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
/* Write your program after the comment
/* 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 <stdio.h>

int main() {
char i;
for (i = 'a'; i <='z'; ++i)
if (i != 'e' && i != 'q')
printf("%c", i);

return 0;
}
15 changes: 14 additions & 1 deletion TASKS/Task 002.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
*/
#include <stdio.h>

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;
}
18 changes: 17 additions & 1 deletion TASKS/Task 003.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,20 @@ 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 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;
}
16 changes: 15 additions & 1 deletion TASKS/Task 004.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,18 @@ How old are you?: 65
Output:
Your name is David and you are 65 years old.

*/
*/
#include <stdio.h>

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;
}
12 changes: 11 additions & 1 deletion TASKS/Task 005.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
/*
Write a program in C to find the square of any number
using the function.
*/
*/
#include <stdio.h>

int main() {
int num = 6;

int square = num * num;
printf("The square of your number is: %d", square);

return 0;
}
21 changes: 20 additions & 1 deletion TASKS/Task 006.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,23 @@
/*
Write a program in C to check a given number is even
or odd using the function.
*/
*/
// Online C compiler to run C program online
#include <stdio.h>
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);
}
13 changes: 12 additions & 1 deletion TASKS/Task 007.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,15 @@
write your solution after the comment
Write a function that prints the alphabet, in uppercase,
followed by a new line.
*/
*/
#include <stdio.h>
void capital_letters()
{
for (char i = 'A'; i <= 'Z'; ++i)
printf("%c\n", i);
}
int main()
{
capital_letters();
return (0);
}
13 changes: 12 additions & 1 deletion TASKS/Task 008.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
/*write your solution after the comment
Write a function that prints the alphabet, in lowercase
followed by a new line.
*/
*/
#include <stdio.h>
void capital_letters()
{
for (char i = 'a'; i <= 'z'; ++i)
printf("%c\n", i);
}
int main()
{
capital_letters();
return (0);
}
19 changes: 18 additions & 1 deletion TASKS/Task 009.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
*/
// Online C compiler to run C program online
#include <stdio.h>
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;
}
13 changes: 12 additions & 1 deletion TASKS/Task 010.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,15 @@
Write a function that computes the absolute
value of an integer.
Understand what an absolute value is, before attempting it.
*/
*/
#include <stdio.h>

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;
}
16 changes: 15 additions & 1 deletion TASKS/Task 011.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,18 @@ Output should look like this;
9 x 1 = 9
9 x 2 = 18
... and so on till 12
*/
*/
#include <stdio.h>
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;
}
34 changes: 33 additions & 1 deletion TASKS/Task 012.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,36 @@
/*Write your solution after the comment
Write a function that adds two integers and prints
the result.
*/
*/
#include <stdio.h>
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 <stdio.h>
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;
}
16 changes: 15 additions & 1 deletion TASKS/Task 013.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
*/
#include <stdio.h>
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;
}