Tuesday, July 14, 2009

Write a program In C++ which contains a user defined function named multiple.?

Write a program In C++ which contains a user defined function named multiple. This function takes two integers values and determines whether the second integer is a multiple of the first. The function should take two integer arguments and return 1 (true) if the second is a multiple of the first and 0 (false) otherwise.





Call this function in a main program after getting two integers from user.





Output:


Enter first number : 4


Enter second number : 16





16 is multiple of 2

Write a program In C++ which contains a user defined function named multiple.?
I don't get it... In your example, you entered 4 and 16. Why did the output say 16 is a multiple of 2.





Oh, there's some trickery going on... The function should then also determine if the second number is a multiple of half of the first number as well as the first number?





Tell your instructor that he has an error in his example and meybe you won't have to write your assignment.
Reply:Resend your question here:


http://answers.yahoo.com/dir/;_ylt=Al7H4...
Reply:The modulo function, %, is perfect for that. 9 modulo 3 is zero (not remainder so a multiple of three). 10 modulo 3 is 1, so 10 is not a multiple.


No comments:

Post a Comment