need to write a program to test to see is a number is a multiple of another. sim
ID: 3637691 • Letter: N
Question
need to write a program to test to see is a number is a multiple of another. simple program-just don't know the code to process if a multiple or not.example of the GUI
enter first number
enter second number
multiple (?)
answer
any help would be appreciated
Explanation / Answer
I am not going to put the whole code here but I can give you an idea on the logic to do it. (Use mod operator for %) If first_num>second_num { if (first_num % second_num) == 0 { first_num is the multiple of second_num} else { They are not multiples) } else { if (second_num % first_num) == 0 { second_num is the multiple of first_num} else { They are not multiples) } Make sure you check for input values being zeroes also before using this logic.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.