c program

This is a discussion on c program within the C Programming forums, part of the General Programming Boards category; whats wrong with this program, i get 2 errors check the attachments...

  1. #1
    Registered User
    Join Date
    Dec 2005
    Posts
    14

    c program

    whats wrong with this program, i get 2 errors

    check the attachments
    Attached Files Attached Files

  2. #2
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,246
    You might want to rephrase your question before this thread turns into this.

    There is a lot more information you need to give us before we can help you.

  3. #3
    Devil's Advocate SlyMaelstrom's Avatar
    Join Date
    May 2004
    Location
    Out of scope
    Posts
    4,062
    Code:
    #include <stdio.h>   /* This is how you include standard headers */
    #include "myheader.h"  /* This is how you include headers in the current directory */
    NULL in your srand() should be capiltalized.
    Sent from my iPadŽ

  4. #4
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Posts
    5,006
    C is case sensitive: NULL is what you want instead of null.

    Work on indentation and post code within code tags: [code][/code].
    7. It is easier to write an incorrect program than understand a correct one.
    40. There are two ways to write error-free programs; only the third one works.*

  5. #5
    cwr
    cwr is offline
    Registered Luser cwr's Avatar
    Join Date
    Jul 2005
    Location
    Sydney, Australia
    Posts
    868
    Standard system headers have angle brackets, not quotes:
    Code:
    #include <stdio.h>
    #include <stdlib.h>
    #include <time.h>
    conio.h is not part of standard C.

    null should be uppercase. Edit: redundant

    totalwinnings is a long, but you use %d instead of %ld.

  6. #6
    Registered User
    Join Date
    Dec 2005
    Posts
    14
    i don't know how to do it, can somebody run the program and tell me if it is working

  7. #7
    Devil's Advocate SlyMaelstrom's Avatar
    Join Date
    May 2004
    Location
    Out of scope
    Posts
    4,062
    Do what? Change a few quotes to angle brackets and capitalize a word?

    It's syntax errors... what's the problem here? Yes, when I made the changes, the program worked fine.
    Sent from my iPadŽ

  8. #8
    Registered User
    Join Date
    Dec 2005
    Posts
    14
    ok this what the program was asking


    write a program that simulates playing the 6/49 lottery (almost). a 6/49 ticket has six unique
    numbers on it between 1 and 49 (inclusive) a ticket cost $1 for each draw. simulate this for
    10 years (520 draws)

    the program will buy one ticket for each draw(the ticket should have the same numbers in each draw),
    for each draw it will generate the winning ticket and compare the numbers
    in your ticket against the winning ticket. you win if u match

    match winnings
    3 numbers out of 6 $10
    4 numbers out of 6 $100
    5 numbers out of 6 $2000
    6 numbers out of 6 $2000000



    for each draw, print the week number, the ticket you have bought and the winning ticket,
    do the comparison and print "you lost this week" if you lost. if you won, print the winning
    in the form "you won %d this week". where %d is replaced by the winnings, at the end of the program
    print your total expenses and total winnings.

    two functions to use
    generateticket() generate a ticket when passed a six element array of ints.
    printticket() prints a ticket when passed a six element array of ints

    your main should have a line in it that states
    srand ((unsigned) time (NULL));
    after your variable declaration. this will randomize the result



    sample output of the program

    week 517
    i bought ticket: ticket: 34 35 19 16 41 9
    generating winner: ticket: 11 12 28 39 33 32
    you lost this week

    week 518
    i bought ticket: ticket: 34 35 19 16 41 9
    generating winner: ticket: 7 20 27 24 5 10
    you lost this week

    week 519
    i bought ticket: ticket: 34 35 19 16 41 9
    generating winner: ticket: 42 39 32 23 15 40
    you lost this week

    week 520
    i bought ticket: ticket: 34 35 19 16 41 9
    generating winner: ticket: 6 15 12 20 47 16
    you lost this week


    total expenses are 520
    total winnings are 300

    is that what the program is given me

  9. #9
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,341
    Replies to the new code here - program

    Next time shawn33, paste your code into the forum directly, between [code][/code] tags, and keep to 1 thread if you're still stuck on basically the same problem.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Issue with program that's calling a function and has a loop
    By tigerfansince84 in forum C++ Programming
    Replies: 9
    Last Post: 11-12-2008, 12:38 PM
  2. Need help with a program, theres something in it for you
    By engstudent363 in forum C Programming
    Replies: 1
    Last Post: 02-29-2008, 12:41 PM
  3. Replies: 4
    Last Post: 02-21-2008, 09:39 AM
  4. My program, anyhelp
    By @licomb in forum C Programming
    Replies: 14
    Last Post: 08-14-2001, 10:04 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21