Q:
C++ Program to find odd or even number without using modulus operator
belongs to collection: Most popular and Searched C++ solved programs with Explanation and Output
Most popular and Searched C++ solved programs with Explanation and Output
- C++ program to add two integer numbers
- C++ program to add two integer numbers using function
- C++ program to add two integer numbers using pointers
- C++ program to add two integer numbers using class
- C++ program to read a string
- C++ program to display name and age
- C++ program to find factorial of a number
- C++ program to check prime number
- C++ program to display prime numbers
- C++ program to add two times
- C++ program to check EVEN or ODD
- C++ Program to find odd or even number without using modulus operator
- C++ Program to check if a number is even using Recursion
- C++ program to check leap year
- C++ program to convert lowercase character to uppercase and vice versa
- C++ program to sort an array in Ascending Order
- C++ program to sort an array in Descending Order
- C++ program to reverse a number
- C++ Program to print a Pascal Triangle upto N depth
- C++ Program to print a chessboard pattern
- C++ program to print pattern of stars till N number of rows
- C++ program to generate random alphabets and store them into a character array
- C++ program to find factorial of large numbers using array
- C++ program to find the frequency of a character in a string using Count Array
- C++ program to print a spiral matrix
- C++ program to check whether a string2 can be formed from string1
- C++ program to convert number to word (up to four digits only)
- C++ program to find the next greatest number from the same set of digits
- C++ program to find Fibonacci number using different methods
- C++ program to add seconds to the time
- C++ program to check given date is in valid format or not
- C++ program to check given string is numeric or not
- C++ program to set IP address, subnet mask, network gateway in Linux System
- C++ program to get MAC address of Linux based network device
- C++ program to set MAC address in Linux Devices
- C++ program to pad octets of IP Address with Zeros
- C++ program to set network settings for IPv6 Network in Linux Devices
- C++ program to find total number of days in given month of year
- C++ program to get previous date of given date
- Reading date and time from Linux operating system using C++ program
- Set date and time in Linux Operating System using C++ program
- C++ program to get week day from given date
- Find last index of a character in a string using C++ program
- C++ program to print the maximum possible time using six of nine given single digits
- Sieve of Eratosthenes to find prime numbers using c++
- C++ program to print your name randomly on the screen with colored text
- C++ program to demonstrate example of delay() function
- Example of declaring and printing different constants in C++
- How to skip some of the array elements in C++?
- C++ program to keep calculate the sum of the digits of a number until the number is a single digit
- C++ Program to print right angled pyramid of numbers
- C++ program to print right angled (Right oriented) pyramid of numbers
- C++ program to print Hello World/First Program in C++
- Read character array as string using cin in C++
- C++ program to demonstrate example of cascading cout and cin
- C++ program to demonstrate use of Scope Resolution Operator
- C++ program to demonstrate use of reference variable
- C++ program to use function as a LVALUE using reference variable
- C++ program to demonstrate example of Inline Function
- C++ program to demonstrate example of Default Argument
- C++ program to demonstrate methods of passing arguments in function:
- C++ program to demonstrate example of function overloading
- C++ program to read string using cin.getline()
- C++ program to generate random numbers
- Print Reverse Triangle Bridge Pattern for Characters in C++
Program to find EVEN or ODD without using Modulus (%) Operator in C++
Output
In this program, we are simply reducing the given number by 2 until it is either 0 or 1. If it is even, the end result will be 0 and if it is odd, the loop will not go to negative number, therefore the result for odd will be 1.
Then we are simply checking if number (n) is 0, it is even and if it is 1, the number is odd.
need an explanation for this answer? contact us directly to get an explanation for this answer