Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialMarguerite Holden
6,075 PointsPlease can someone help me?
def mod(a, b) puts "The remainder of #{a} divided by #{b} is #{c}:" return a % b end
Use string interpolation to return the remainder inside the sentence "The remainder of a divided by b is c." where a is your "a" variable and b is your "b" variable and "c" is the value of a % b.
def mod(a, b)
puts "The remainder of #{a} divided by #{b} is #{c}:"
return a % b
end
2 Answers
jacobproffer
24,604 PointsHey Marguerite,
At the moment, your variable 'c' doesn't exist. In this case, you'd want to declare the 'c' variable and assign it the remainder of a divided by b (Using the modulus operator), like so:
c = a % b
Then, you can simply return the required sentence instead of printing it:
c = a % b
return "The remainder of #{a} divided by #{b} is #{c}."
Marguerite Holden
6,075 PointsThanks so much. for your help!