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
20 changes: 19 additions & 1 deletion TASKS/Task 002.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
*/


#include <stdio.h>

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;
}
25 changes: 24 additions & 1 deletion TASKS/Task 003.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,27 @@ 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("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;
}
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()
{
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;
}
20 changes: 19 additions & 1 deletion TASKS/Task 006.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,22 @@
/*
Write a program in C to check a given number is even
or odd using the function.
*/
*/


#include <stdio.h>


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;
}
14 changes: 14 additions & 0 deletions TASKS/fruit_bowl.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,17 @@ Sample Output
4

* */


#include <stdio.h>

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;
}
22 changes: 22 additions & 0 deletions TASKS/popsicles.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,25 @@ Sample Output
give away

* */



#include <stdio.h>

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;
}
21 changes: 21 additions & 0 deletions TASKS/thats_odd_and_even.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 <stdio.h>

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<n; i++){
scanf("%d", &num);
if (num%2 ==0){
sum_even += num;
}
else {
sum_odd += num;
}
}
printf("Sum of even intgers: %d\n", sum_even);
printf("Sum of odd integers: %d\n", sum_odd);
return 0;
}