I think it is a problem with your printf statement. I'm not sure what though since you have edited your output to be different then what I expect the code to output. Also, why did you decide to make some of your variables double precision and others float?
Well, to tell you the truth I wasn't sure why it was working so I just played around with the lf, d, c, and even some other things. Here is the exact question the book asks me to do and maybe you can give me a small code so I can get idea how it works.
1. prompt the user to enter a number (type double).
2. read number (using %lf).
3. Generate a random number and scale it to range 2...8.
4. Set result to number divided by the random number.
Ex.One output could be
number: 127.50 <<-- user input
the random number 2
result 63.75 <<-- 127.50 / 2 = 63.75