Question: Write a program that reads an integer and determines and prints whether it’s odd or even. [Hint: Use the remainder operator. An even number is a multiple of two. Any multiple of two leaves a remainder of zero when divided by 2.]
1 2 |
/* <br /> * Author: AGHATISE OSAZUWA<br /> * Website: www.cscprogrammingtutorials.com <br /> *<br /> * Program to determine if number is odd or even.<br /> */<br /><br />#include <stdio.h><br />int main ( ){ <br /> int num;<br /> printf("Enter an integer number: ");<br /> scanf("%d", &num);<br /> if (num%2==0){<br /> printf("%d is an even number.n", num);<br /> }<br /> if (num%2==1){<br /> printf("%d is an odd number.n", num);<br /> }<br /> return 0;<br />}<br /> |
Click here to see other solutions to Deitel C How To Program exercises.