Current location - Training Enrollment Network - Mathematics courses - How to write a program in C language to judge whether an input number is even or odd?
How to write a program in C language to judge whether an input number is even or odd?
1. Open the virtual machine, open the terminal (ctrl+alt+t), then create a new file with vi, and press enter to edit a C file (vi a.c).

2. Press "I" to enter the input mode and start writing the program. Because inputting Chinese under linux requires other settings, it is edited under notepad++.

3. first, define an integer a.

4. Judge whether A is divisible by 2, that is, whether the remainder of A to 2 is 0, if it is 0, the number is even, otherwise it is odd.

5. After writing the C program, save the C file and compile it with gcc.

6. After the compilation is passed, run the program (". /+file ") to verify whether the running result is wrong.