7 Replies - 11157 Views - Last Post: 08 October 2010 - 01:59 PM Rate Topic: -----

#1 JCS33   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 08-October 10

Help with this code please been stuck for a few hours..

Posted 08 October 2010 - 11:13 AM

Need help with this C code.. please..

--------------------------------------------------------------------------------

Hey guys,Im really new to C programming orany programming in general and im trying to make this lottery game work.. I know that the line that says 10+rand()%90 is incorrect. What can i do to make it better. You dont have to give me the answer if you dont want to. just point me in the right direction please. ive been working on it for a few hours and its frustrating me..

am i even using the rand number correectly?

please and thank you.


please help.. thank you..

#include <stdio.h>
#include <stdlib.h>
10+rand()%90
int main()
{
input-input%10)/10

if(input==random number)
{
printf("You have won $10000\n"); 
break;
}
else
{
if (input%10==random number || ((input-input%10)/10)==random number)
{
printf("You have won $1000\n");
break;
}
printf("You have won nothing\n");
}
return 0;
}



Is This A Good Question/Topic? 0
  • +

Replies To: Help with this code please been stuck for a few hours..

#2 jimblumberg   User is online

  • member icon

Reputation: 5487
  • View blog
  • Posts: 17,064
  • Joined: 25-December 09

Re: Help with this code please been stuck for a few hours..

Posted 08 October 2010 - 11:24 AM

Does the code compile? Have you "Googled" rand()? See rand()

Jim
Was This Post Helpful? 0
  • +
  • -

#3 JCS33   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 08-October 10

Re: Help with this code please been stuck for a few hours..

Posted 08 October 2010 - 11:29 AM

when i try to compile it says decleration terminated incorrectly.. which it point to like 4 where 10+rand()%90 is at...
Was This Post Helpful? 0
  • +
  • -

#4 JackOfAllTrades   User is offline

  • Saucy!
  • member icon

Reputation: 6246
  • View blog
  • Posts: 24,014
  • Joined: 23-August 08

Re: Help with this code please been stuck for a few hours..

Posted 08 October 2010 - 11:34 AM

Gee, looks to me like you haven't done anything in the past nearly 24 hours, judging by your post here.
Was This Post Helpful? 0
  • +
  • -

#5 Mohanddo   User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 50
  • Joined: 07-July 09

Re: Help with this code please been stuck for a few hours..

Posted 08 October 2010 - 11:34 AM

I think you have forgotten to seed your random number. Your program cant just create a random number by its own. It has to use some unique value to generate it.

I also dont know what your trying to do above and in the first line of the main function... if you dont understand programming dont try to push something together and hand it in... go and learn properly.

This post has been edited by Mohanddo: 08 October 2010 - 11:37 AM

Was This Post Helpful? 0
  • +
  • -

#6 jimblumberg   User is online

  • member icon

Reputation: 5487
  • View blog
  • Posts: 17,064
  • Joined: 25-December 09

Re: Help with this code please been stuck for a few hours..

Posted 08 October 2010 - 11:37 AM

Have you read the information from the link or tried Google???

Jim
Was This Post Helpful? 0
  • +
  • -

#7 snoopy11   User is offline

  • Engineering ● Software
  • member icon

Reputation: 1467
  • View blog
  • Posts: 4,726
  • Joined: 20-March 10

Re: Help with this code please been stuck for a few hours..

Posted 08 October 2010 - 01:25 PM

There is a Tutorial in </dream in code> on random numbers

Random Numbers
Was This Post Helpful? 0
  • +
  • -

#8 JackOfAllTrades   User is offline

  • Saucy!
  • member icon

Reputation: 6246
  • View blog
  • Posts: 24,014
  • Joined: 23-August 08

Re: Help with this code please been stuck for a few hours..

Posted 08 October 2010 - 01:59 PM

This goes way beyond random number issues. As mentioned in the other link, this is a fundamental lack of knowledge in C. There's just code all over the place with no rhyme or reason. It seems like an attempt to just throw something up (pun intended) and hope someone will fix it so they can hand it in and get credit.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1