CPPForSchool.com: Flow of Control Set 1: Assignment 1

1. Any integer is input by the user. Write a program to find out whether it is an odd number or even number.

This assignment was not too difficult.  The best way to determine if a number is even is to check if it can be divided by 2 evenly.  With that said, I used the modulo operator so if there is a remainder, it will be classified as an odd number.  Below is my source code.




Both even and odd numbers are detected successfully!






Comments

Popular posts from this blog

CPPForSchool.com: Variable, Operator & Expression Set 1: Assignment 9

CPPForSchool.com: Array - Single Dimension Set 1 Assignment 6

CPPForSchool.com: Variable, Operator & Expression Set 1: Assignment 8