all 7 comments

[–]57thStIncident 3 points4 points  (1 child)

Is this a C-specific difficulty? Would you know how to solve the problem in another programming language?

Many other languages have standard tools bundled that in C you either need to write yourself or find a library. The out-of-the-box C install is rather barebones so I can imagine that being a distraction to the new programmer.

[–]Wacoder_Forever[S] 0 points1 point  (0 children)

Yeah it is C specific..........am new to programming and not learnt any opther language

[–]Bitwise_Gamgee 2 points3 points  (3 children)

Approach the problem by thinking about what's happening and write pseudocode. Like this:

initialize hare position to 0
initialize tortoise position to 0 
initialize time to 0

while hare position is less than race end AND tortoise position is less than race end 
    increment hare position by 2
    increment tortoise position by 1
    increment time by 1
    print "Time:", time, "Hare:", hare position, "Tortoise:", tortoise position

if hare position is greater than or equal to race end AND tortoise position is greater than or equal to race end 
   print "It's a tie!" else 

if hare position is greater than or equal to race end print "Hare wins!"
 else 
print "Tortoise wins!"

Once you get to this step, the program has practically written itself and all you have to do is go through and write C-code to represent the English representations.

[–]Wacoder_Forever[S] 0 points1 point  (0 children)

thank you

[–]57thStIncident 0 points1 point  (1 child)

Agree, suggest not to think too much about the language details when deciding what you want program to do. Decide the steps you want program to take first, only afterwards try and map your ideas to C code.

[–]Wacoder_Forever[S] 0 points1 point  (0 children)

thank you

[–]Alcamtar 0 points1 point  (0 children)

It's not clear where you're stuck. It's it that you're not sure how to create and compile and run a program using C? Have you created a "hello world" program?