From a4c24dc4075a7e3651c210ab56bafb8965532a80 Mon Sep 17 00:00:00 2001 From: Abdullah Al Fuwad <138917560+abdullah09c@users.noreply.github.com> Date: Sat, 8 Jul 2023 00:42:08 +0600 Subject: [PATCH 1/2] Create 1_even_odd_1.c --- 1_even_odd_1.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 1_even_odd_1.c diff --git a/1_even_odd_1.c b/1_even_odd_1.c new file mode 100644 index 0000000..953c3cf --- /dev/null +++ b/1_even_odd_1.c @@ -0,0 +1,14 @@ +#include +int main() +{ + int T, N; + scanf("%d", &T); + while (T--) { + scanf("%d", &N); + if(N % 2 == 0) + printf("even\n"); + else + printf("odd\n"); + } +return 0; + } From 957249f7967056604e6e2dea28a9ec4eafdf4548 Mon Sep 17 00:00:00 2001 From: Abdullah Al Fuwad <138917560+abdullah09c@users.noreply.github.com> Date: Sat, 8 Jul 2023 00:51:06 +0600 Subject: [PATCH 2/2] Create 2_even_odd_2.c Input are strings. So last digit(which is string) need converted to int. So minus 48 as '0' ascii value 48. Or minus -'0' --- 2_even_odd_2.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 2_even_odd_2.c diff --git a/2_even_odd_2.c b/2_even_odd_2.c new file mode 100644 index 0000000..317642b --- /dev/null +++ b/2_even_odd_2.c @@ -0,0 +1,19 @@ +#include +int main() +{ + int T, N; + char ara[100]; + scanf("%d", &T); + while(T--) { + int i, c = 0, num = 0; + scanf("%s", &ara); + for(i = 0;ara[i] != '\0';i++) + c++; + // num = ara[c-1] - 48; + if((ara[c-1] - '0') % 2 == 0) + printf("even\n"); + else + printf("odd\n"); + } +return 0; +}