Get the App
SLTechnology News&Howtos  ›  Development  › 

How to judge odd and even numbers in C language

Shulou Source: shulou.com Published: 2022-06-01 01:50:52 09月30日 Update

In this article, the editor introduces in detail "how to judge odd and even numbers in C language". The content is detailed, the steps are clear, and the details are handled properly. I hope this article "how to judge odd and even numbers in C language" can help you solve your doubts. Let's follow the editor's ideas to learn new knowledge.

In fact, there is a simpler and more efficient way to judge odd and even numbers. our integers are all stored in binary in the computer, and the last bit of the odd number must be 1, so we can write like this:

# include int main () {int number; printf ("Please enter an integer:"); scanf ("% d", & number); / / determine that the last digit of this number is 1 which is odd if (number&1) printf ("% d is odd." , number); else printf ("d is an even number." , number); return 0;} read here, this article "how to judge odd and even numbers in C language" has been introduced. If you want to master the knowledge points of this article, you still need to practice and use it before you can understand it. If you want to know more related articles, you are welcome to follow the industry information channel.

Tags: Parity parity language odd articles content integers proper binary even methods ideas new knowledge more steps knowledge knowledge points articles details industry Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MySQL macOS vpn Shulou Information Linux