Help with past yr exam paper

This is a discussion on Help with past yr exam paper within the C Programming forums, part of the General Programming Boards category; Can anyone help me with this question? I got this question in one of the past yr exam paper....how should ...

  1. #1
    Registered User
    Join Date
    Sep 2006
    Posts
    14

    Help with past yr exam paper

    Can anyone help me with this question?
    I got this question in one of the past yr exam paper....how should i write for this question?
    Write a short C program , mcopy to copy a list of marks from a source text file to a destination text file. The file names are given as command line arugments. The copy contains only failing marks. For example, the source list (92,34,23,50,51,49) should produce the destination list (34,23,49).
    The program should output the destination text file, the statistics: number of marks,number of failures,percentage failed.
    Please help me.thanks

  2. #2
    Registered User
    Join Date
    Oct 2006
    Location
    Canada
    Posts
    1,243
    post as much code as YOU have written then we'll help. we wont 'do' it for you.

  3. #3
    Devil's Advocate SlyMaelstrom's Avatar
    Join Date
    May 2004
    Location
    Out of scope
    Posts
    4,069
    You've been told before to post your code attempts. The admins of this forum give you more attempts at this than I would... please read the Homework Policy.
    Sent from my iPadŽ

  4. #4
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    The easiest way to code this I believe, is by just mimicing the way you would handle this problem, if you were doing it by hand:

    1) Open the input and output files, from the command line arguments, and while you have more data in the former, input a grade number. Increment the marks count variable.

    2) If the grade number is less than 50, then write it to the output file, increase the failure count variable.

    3) When the program reaches the end of the input file, calculate the percentage of failures found.

    4) Close the files, and print the stats.

    When you break it down into smaller steps, it just get's easier. If one step seems too difficult, consider breaking that step down into two steps - or maybe three.

    Take it step-by-step, and when you get stuck on the syntax or the logic, try and figure it out by studying your compiler's error messages, and checking out your variables values as your program progresses.

    If you're still stuck, post up your code and tell us what you're stuck on, what error messages you're getting, or inaccuracy you have not been able to get quite right.

    And be really clear. A destination file that's called a "copy" and a "destination list", can lead to a lot of confusion. Be VERY clear and precise - it will help you and us as well.

    Adak

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. rock paper Scissors
    By jackstify in forum C++ Programming
    Replies: 3
    Last Post: 12-14-2007, 09:16 PM
  2. Issues and questions about queues
    By Nazgulled in forum C Programming
    Replies: 36
    Last Post: 12-13-2007, 01:03 PM
  3. new problem with class
    By jrb47 in forum C++ Programming
    Replies: 0
    Last Post: 12-01-2006, 07:39 AM
  4. need help with rock paper scissors program
    By Mshock in forum C Programming
    Replies: 3
    Last Post: 04-22-2006, 07:44 AM
  5. Another rock paper scissor question
    By mattflick in forum C Programming
    Replies: 11
    Last Post: 09-29-2005, 09:41 PM

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