# questions

• 11-19-2002
kuwait
questions
i want someone to help me with these questions please.

1- Write statement that assgn random integers to the variable n in the following range :
-3<=n<=11 .

2- Write a function multiple that determines for a pair of integers 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 multiple of the first, and 0 (false) otherwisw. Use this function in a program that inputs series of pairs of integers.

3- Write a program that will help an elementary school student learn multiplication. Use rand to produce two positive one-digit integers. It should then type a question such as :

How much is 6 times 7?

The student then types the answer. Your program checks the student's answer. If it is correct, print "Very good!" and then ask another multiplication question. If the answer is wrong, print "No. Please try again." and then let the student try the same question again repeatedly until the student finally gets it right.
• 11-19-2002
Magos
Re: questions
Quote:

Originally posted by kuwait
1- Write statement that assgn random integers to the variable n in the following range :
-3<=n<=11 .

(rand() % a) + b

Quote:

2- Write a function multiple that determines for a pair of integers 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 multiple of the first, and 0 (false) otherwisw. Use this function in a program that inputs series of pairs of integers.
Modulus ( % ) returns the remainder of a division, helping you to know if a is a divider of b.
12 % 3 = 0, since 12 = 4 * 3 + 0
17 % 5 = 2, since 17 = 3 * 5 + 2

Quote:

3- Write a program that will help an elementary school student learn multiplication. Use rand to produce two positive one-digit integers. It should then type a question such as :

How much is 6 times 7?

The student then types the answer. Your program checks the student's answer. If it is correct, print "Very good!" and then ask another multiplication question. If the answer is wrong, print "No. Please try again." and then let the student try the same question again repeatedly until the student finally gets it right.

Generate two random numbers, print them out formated as you showed, check if the user input equals the product of the numbers, then print answers according to that.
• 11-19-2002
Hunter2
First of all, we aren't automated homework-machines. Show us that you've done some work yourself, or at least thought it through, and if you're stuck, we'll help you. But we aren't going to your homework for you.

And when you're stuck and ask for help, post the relevant code that you're stuck on.

**EDIT**
About us not being automated homework machines, Magos is an exception.
• 11-19-2002
Magos
Quote:

Originally posted by Hunter2
**EDIT**
About us not being automated homework machines, Magos is an exception.

Naahh... didn't actually do the homework for him :D. Just explained how to do it. I left the coding for him.
• 11-19-2002
Hunter2