bool is_even(long int num)
{
return !(num & 1); //when the number is even(divisible by two),
//its least significant bit is 0
}
Chat with our AI personalities
find even number in array
To write a C program to determine if something is odd or even you need to be a programmer. To write a program in C is complicate and only done by programmers.
#include <stdio.h> int main() { printf("Program to find ODD or Even Number\n"); while(1) { int n = 0; printf("\nEnter a number(-1 for Exit): "); scanf("%d",&n); if( n 0) { printf("%d is a EVEN number.\n", n); } else { printf("%d is a ODD number.\n", n); } } return 0; }
swap(&grades[num],&grades[num+1]); what it make in a program?
echo "Program to check even or odd number"echo "Enter a number"read na=`expr $n % 2`if [ $a -eq 0 ] ; then #Semicolon is most important for Executing ifelse statementsecho "It is an even number"elseecho "It is an odd number"fi