DIGIT-ARC read-only archive · snapshot: July 23, 2026

Need guidance and a lil programming puzzle (C)

7 posts · originally from https://geek.digit.in/community/threads/need-guidance-and-a-lil-programming-puzzle-c.135243/

cute.bandar
cute.bandar Original post #1
Dec 20, 2010 at 9:50 PM
These days I am trying to teach myself the C programming language.

So I found some puzzles for the C language that I am attempting to solve. Link!

Try to do puzzle number B06

Here is the question for those to lazy to click:
Write a function int randInt(int min, int max) that returns a random integer in the range min..max (inclusive).
to solve this you can only use the rand() function from the standard library.

My questions to you people are :

1. without looking at the answer or without knowing the answer previously how many of you can do this ? how difficult is this question ?
2. The way I see it , the question is more about maths than programming.(or is programming all about maths ? ) , so how important really is it to get this right ?

cya
A
Dec 20, 2010 at 11:42 PM
its pretty easy yaar!!
yup its all about maths.
try it.
also may include some if statements!!
Liverpool_fan
Dec 21, 2010 at 4:25 AM
1. without looking at the answer or without knowing the answer previously how many of you can do this ? how difficult is this question ?
I couldn't. Using Modulo to get the largest number is kind of weird but makes sense.
2. The way I see it , the question is more about maths than programming.(or is programming all about maths ? ) , so how important really is it to get this right ?
You don't have to get it right all the time. What are experiences for then?
S
Dec 21, 2010 at 7:41 AM
its basically the same as puzzle b03 with non-zero lower limit and a variable range...

Arun
A
Dec 21, 2010 at 3:24 PM
then it seems I am an idiot for not being able to do this :(

Nope it doesn't means that!!
Be +ve and just think how to do that, u will get the answer!!:p
cute.bandar
Dec 21, 2010 at 7:33 PM
thanks for the support guys. I got so upset about not being able to do a (supposedly?) simple question that the solution is burned inside my head now ..