chore(C): add odd or even number (#719)

Co-authored-by: LuigiAltamura <luigi.altamura@mail.polimi.it>
pull/732/head
Luigi Altamura 2022-03-24 15:12:56 +01:00 committed by GitHub
parent f35e35ef5c
commit ec7c098897
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 33 additions and 0 deletions

View File

@ -34,6 +34,7 @@
- [Palindrome Number](maths/palindrome.c) - [Palindrome Number](maths/palindrome.c)
- [Fibonacci Series](maths/fibonacci-series.c) - [Fibonacci Series](maths/fibonacci-series.c)
- [Odd or Even Number](maths/odd-or-even-number.c)
## Queues ## Queues

View File

@ -0,0 +1,32 @@
/**
*This program checks if a number is odd or even.
*
* Odd numbers are whole numbers that cannot be divided exactly by 2. If the number is not divisible by 2 entirely,
* it'll leave a remainder 1.
* Even numbers are whole numbers that can be divided exactly by 2. If we divide the number by 2, it'll leave a remander 0.
*
* Complexity -> O(1)
* _______________________________
* | INPUT | OUTPUT |
* | 2 | It's an even number! |
* | 1 | It's an odd number! |
* | 3 | It's an odd number! |
* _______________________________
* */
#include <stdio.h>
int main()
{
int n;
printf("Enter a number:\n");
scanf("%d", &n);
if(n % 2 == 0 ){
printf("It's an even number!");
}else{
printf("It's an odd number!");
}
return 0;
}