answersLogoWhite

0


Best Answer

There are several ways to determine if an integer is even or odd. The most efficient method is to simply check if the low-order bit is set or not. If it is, the number is odd, otherwise it is even.

bool is_odd (int num) {

return (num & 1);

}

However, if the system uses ones-complement notation to represent negative values this won't work because ones-complement has two representations of the value zero (one positive and one negative), even though zero is neither positive nor negative but is an even number. Most systems these days use twos-complement notation so this is rarely an issue but it's worth keeping in mind.

The most generic solution is to divide the value by 2 and check the remainder using the modulus operator (%). If there is a remainder, the value is odd, otherwise it is even.

User Avatar

Wiki User

7y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How do you write a c program for taking decision whether a number of a series is even or odd?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

Would it be a copyright infringement if a new TV series opened up their TV program in a similar manner as another program form the 70's?

It depends on how similar they are, whether the similarity is intentional, whether it is a parody of or commentary on the original, and whether it damages the ability of the rightsholder to monetize or license the original.


Will there be a Beast Quest series 10?

yes the series is called the final decision


Internal Conflict examples?

In the twilight series, Bella must choose whether or not she wants to become a vampire. This is an internal conflict. She must make a decision for herself and it has nothing to do with anyone else.


Is Vampire Diaries apporarite?

It is appropriate for teenagers and adult but i wouldn't recommend it for anyone younger than 13. Also it is the parents decision whether they let their child read or watch the series.


What is the difference between a Program decision memo and a program objective memo?

Program is a planned series of future events, items, or performances. It can also mean a sheet or booklet giving details of items or performers at an event or performance. Having the aforementioned definition in mind, it then become easy to state the difference between a Program decision memo and a Program objective memo. A memo served on the Board of Directors or higher constituted body by a Committee highlighting the verdict or the outcome or the derivation from the objectives memo is a program decision memo. A document stating what a Committee arrived at, or the concluded result of a particular committee. While a Program objective memo reflect the issues that needed be resolved, served by a higher authority to a set up committee.


Program for sin series in c language?

find the program in c-pgms.blogspot.com


What is a series finale?

A series finale is the last or final episode of a television program.


The series of instructions that tells the computer what to do and how to do it?

A program.


What is friend?

A TV program/Series!


What is the assembly program to generate a geometric series and compute its sum The inputs are the base root and the length of the series The outputs are the series elements and their sum?

What is the assembly program to generate a geometric series and compute its sum The inputs are the base root and the length of the series The outputs are the series elements and their sum?


An instruction book or program that takes users through a prescribed series of steps to learn a complex program is called a?

An instruction book or program that takes users through a prescribed series of steps to learn a complex program is called a tutorial.


How can you know whether the circuit is in voltage series or current series?

Jam your finger in it. Or RTFM.