diff --git a/TASKS/Task 002.c b/TASKS/Task 002.c index 5cdd390..6c0b846 100644 --- a/TASKS/Task 002.c +++ b/TASKS/Task 002.c @@ -3,4 +3,22 @@ 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 your score: "); + if (scanf("%d", &score) != 1) { + printf("Invalid input. Please enter a number.\n"); + return; + } + if (score < 80) { + printf("You are not eligible to be enrolled.\n"); + } else { + printf("You can be enrolled.\n"); + } + return 0; +} diff --git a/TASKS/Task 003.c b/TASKS/Task 003.c index 7fca79c..e21d474 100644 --- a/TASKS/Task 003.c +++ b/TASKS/Task 003.c @@ -6,4 +6,27 @@ 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 Number; + +printf("Enter your number: "); +scanf("%d", &Number); + +if (Number==0){ +printf("%d is zero"); +} +else if (Number%2==0){ +printf("%d is even"); +} +else { +printf("%d is odd"); +} + + return 0; +} diff --git a/TASKS/Task 004.c b/TASKS/Task 004.c index 17ee38c..87002ed 100644 --- a/TASKS/Task 004.c +++ b/TASKS/Task 004.c @@ -11,4 +11,21 @@ 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 name[10]; +int age; + +printf("What is your name: "); +scanf("%s", name); +printf("How old are you? "); +scanf("%d", &age); +printf("Your name is %s, and your are %d years old",name,age); + +return 0; +} diff --git a/TASKS/Task 006.c b/TASKS/Task 006.c index dc0b9af..5719b08 100644 --- a/TASKS/Task 006.c +++ b/TASKS/Task 006.c @@ -1,4 +1,22 @@ /* Write a program in C to check a given number is even or odd using the function. -*/ \ No newline at end of file +*/ + + +#include + + +int main() +{ +int number; +printf("Enter your number: "); +scanf("%d", &number); + +if (number%2==0){ +printf("%d is even");} +else { +printf("%d is odd");} + +return 0; +} diff --git a/TASKS/fruit_bowl.c b/TASKS/fruit_bowl.c index 5d7731e..c333f2f 100644 --- a/TASKS/fruit_bowl.c +++ b/TASKS/fruit_bowl.c @@ -12,3 +12,17 @@ Sample Output 4 * */ + + +#include + +int main() { + int n, num_apples, num_pies; + printf("Enter the number of fruits: "); + scanf("%d", &n); + + num_apples = n/2; + num_pies = num_apples/3; + printf("You can make %d pies",num_pies); + return 0; +} diff --git a/TASKS/popsicles.c b/TASKS/popsicles.c index 905bf8e..f0fc980 100644 --- a/TASKS/popsicles.c +++ b/TASKS/popsicles.c @@ -12,3 +12,25 @@ Sample Output give away * */ + + + +#include + +int main() { + int siblings, popsicles; + printf("How many siblings are there? "); + scanf("%d", &siblings); + + printf("How many popsicles do you have? "); + scanf("%d", &popsicles); + + if (siblings> popsicles) { + printf("Eat them yourself"); + } + else { + printf("Give away"); + } + + return 0; +} diff --git a/TASKS/thats_odd_and_even.c b/TASKS/thats_odd_and_even.c index 8e02e75..8402c5a 100644 --- a/TASKS/thats_odd_and_even.c +++ b/TASKS/thats_odd_and_even.c @@ -6,3 +6,24 @@ Input Format: The first input denotes the length of the list (N). The next N lines contain the list elements as integers. * */ + +#include + +int main() { + int n, num, sum_even=0, sum_odd=0; + printf("Enter the number of integers: "); + scanf("%d", &n); + printf("Enter the integers: "); + for (int i=0; i