answersLogoWhite

0


Best Answer

Oh good old-fashioned C.

void main()

{

int variable_name = [Any number goes here];

if (variable_name % 2 == 0)

{

printf("%d is even.", variable_name);

} else

{

printf("%d is odd.", variable_name);

}

}

I think I've helped enough, so it's up to you to learn how to get input from the user, if that's what you're working on.

User Avatar

Wiki User

14y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

15y ago

/*
Title: even.c

A simple C program to find if the given number is even or not.
*/

#include

int main()
{
int number;

/* prompt the user for a number */
printf("\nNumber: ");
scanf("%d" , &number);

/*
Check if the number is even or not. A number is even if it is divisible by 2.
The remainder is zero.
*/
if(number % 2 == 0)
printf("The number %d is even\n" , number);
else
printf("The number %d is odd\n" , number);

return 0;
}

This answer is:
User Avatar

User Avatar

Wiki User

12y ago

if (number & 1) printf("Number is odd\n");

else printf("Number is even\n");

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: C program to find weather given number is even or not?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

Need a'c' program to find given number is even or odd?

No, thanks.


How do you find whether a given number is even or odd in Unix shell programming?

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


Does a prime number always go an equal number of times?

No. A given number need not even be divisible by a given prime.


Write a shell program to find given no is even or odd?

The pseudo code would be as follows (you figure out the syntax) 1) Prompt the user to enter a number 2) If entered number is alpha, quit program after displaying message that the user ended the program. 3) Otherwise, find Modulo 2 of the entered number. This is a fancy way of saying "find the remainder when the number is divided by 2) 4) If Modulo 2 is zero, the number is even, otherwise odd 5) Display message showing if the entered number was Even or Odd 6) Branch back to step 1


Program to check whether the entered number is even or odd?

#include<stdio.h> #include<conio.h> void main() { int n; printf("ENTER NO FOR CHECK........ "); scanf("%d", &n); if(n%2==0) printf("Given No is EVEN"); else printf("Given No is ODD"); getch(); }


Write c program to find the given no is even or odd?

int main () { int x; printf ("Enter the value of x\n"); scanf ("%d",&x); if (0 == x%2) printf ("Number is even\n") else printf ("Number is odd\n"); }


What is the only given prime number?

The only even prime number is 2.


Dicide given number is odd or even?

An even number can be divided by 2 evenly. An odd number will have a remainder of 1 when divided by 2.


How will you know that the root of a given number is even or odd?

Assuming you know that your number is a perfect square, the square root of an even number is even, and the square root of an odd number is odd.


How can you tell whether a given number is a multiple of 2?

If it is even


Program to print all the even numbers of an array in visual basic?

find even number in array


What is the rule for checking weather a number is divisible by two?

If it is even, it is divisible by two evenly.