Question: Write a program that reads in two integers and determines and prints whether the first is a multiple of the second. [Hint: Use the remainder operator.]
1 2 |
/* <br /> * Author: AGHATISE OSAZUWA<br /> * Website: www.cscprogrammingtutorials.com <br /> *<br /> * Program to check if a number is a multiple of another number.<br /> */<br /><br />#include <stdio.h><br />int main ( ){ <br /> int num1, num2;<br /> printf("Enter two numbers: ");<br /> scanf("%d%d", &num1, &num2);<br /> if (num2 % num1 == 0){<br /> printf("%d is a multiple of %dn", num1, num2);<br /> }<br /> if (num2 % num1 != 0){<br /> printf("%d is not a multiple of %dn", num1, num2);<br /> }<br /> return 0;<br />}<br /> |
Click here to see other solutions to Deitel C How To Program exercises.