An even number is an integer which is "evenly divisible" by two. This means that if the integer is divided by 2, it yields no remainder.
For example, 2,22,68.etc.
An odd number is an integer which is not a multiple of two. If it is divided by two the result is a fraction.
For example, 3,23,69,etc.
SOURCE CODE:
For example, 2,22,68.etc.
An odd number is an integer which is not a multiple of two. If it is divided by two the result is a fraction.
For example, 3,23,69,etc.
PROBLEM STATEMENT
Write a program in C to identify a number as even or odd
SOURCE CODE:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | #include |
OUTPUT
Explanation
First within the main() function we declared two integer variable num and rem.Then we display a message for the user to take input and we store it in n.Next divide the num by 2 and store it into rem.Then we are using a if-else loop to check whether the rem is equals to zero or not.If rem is equals to zero then it is a even number and we will display it as a even number, else we will print it as odd number.
Related Topics
- C program to display Fibonacci series up to n terms
- C program to check whether a number is Palindrome or not
- C Program to display Fibonacci series up to a certain number
- C Program to display the Factorial of a number
- C Program to find prime numbers between intervals using function.
- C Program to check whether a number is perfect or not
- C program to identify a number as Even or Odd
- C program to print "Hello World"
No comments:
Post a Comment