The output of the program is:

 

 

Suppose if we don’t have modulus operator in the C language. Is there any other way to find out the even numbers? We know that in C integer division gives the integer result and the decimal portion is truncated. So the expression (2 * (number / 2)) gives the number as a result, if the number is even only. So we can change our condition in if statement as:

                     if ( ( 2 * ( number /2 ) ) == number )

 

 

 

Previous

 

TOC

 

Next