Write a function int multiple(int a, int b) that determines for a pair of intege
ID: 3532316 • Letter: W
Question
Write a function int multiple(int a, int b) that determines for a pair of integers whether the
second integer is a multiple of the first. The function takes two integer arguments and return 1(true) if the
second is a multiple of the first and 0(false) otherwise. Use this function in a program that inputs a series
of pairs of integers.
? You program should be able to continue processing multiple input series as shown in the example.
? You program should give feedback on invalid input as shown in the example.
? You program should print an ending when user choose to end this program.
Example (characters in shaded background are input from keyboard):
This program will test if the 2nd integer is multiple of 1st integer.
Please input two integers:2 5
2nd integer is NOT a multiple of 1st integer!
Please input two integers:2 4
2nd integer is a multiple of 1st integer!Please input two integers:4 2
Invalid input!!
Please input two integers:-3 4
Invalid input!!
Explanation / Answer
#include int multiple; int main() { int x; int y; int a; int m; printf("Enter first integer here:"); scanf("%d", x); printf("Enter second integer here:"); scanf("%d", y); m = int multiple(a) return 0; } int multiple { int a; a = x % y; if(a==0) printf("The second integer is a multiple of the first"); return 1; if(a==1) printf("The second integer is not a multiple of the first"); return 0;
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.