Thread: Help with homework i am so lost

  1. #1
    Registered User
    Join Date
    Mar 2017
    Posts
    5

    Help with homework i am so lost

    The prompt for the program is:

    Write a program to grade an n-question multiple-choice exam (for n between 5 and 50) andprovide feedback about the most frequently missed questions. Your program will take datafrom the file examdat.txt . The first line of the file contains the number of questions onthe exam followed by a space and then an n-character string of the correct answers. Writea function fgetAnswers that inputs the answers from an open input file. Each of the linesthat follow contain an integer student ID followed by a space and then that student answers.Function fgetAnswers can also be called to input a student’s answers. Your program is to


    1



    produce an output file, report.txt , containing the answer key, each student ID and eachstudent’s score as a percentage, and then information about how many students missed eachquestion. Here are short sample input and output files.
    examdat.txt
    5 dbbac111 dabac102 dcbdc251 dbbac
    report.txt
    Exam ReportQuestion 1 2 3 4 5Answer d b b a c
    ID Score(%)111 80102 60251 100
    Function fgetAnswers() inputs n answers (characters) from the input file. Open the filein main() and pass the file pointer to the function, with prototype:
    void fgetAnswers(char answers[], int n, FILE *inp);
    Attached Files Attached Files
    • File Type: c main.c (829 Bytes, 126 views)

  2. #2
    Registered User
    Join Date
    May 2009
    Posts
    4,183
    Code:
    void fgetAnswers(char answers[], int n, FILE *inp);
    Is NOT called like you did it.

    Code:
    fgetanswers(&answers[n], &n, &examdat);
    Code:
        FILE *examdat;
    Code:
    #define MAX_ANSWERS 10
    char answers[MAX_ANSWERS];
    I would try calling it like

    Code:
    fgetanswers(answers, MAX_ANSWERS, examdat);
    Edit: The code you wrote for fgetanswers should be replaced with code that has a chance of working.
    I suggest you need to find a compiler and at least try to compile your code with warning on a high setting.

    Edit2: C is a case sensitive language "fgetAnswers" is NOT the same as "fgetanswers"!

    Edit3: The value of 10 for MAX_ANSWERS is NOT the best value for the program you are supposed to write.
    I have no plans to help you any more because you seem to NOT learning based on your last posts on this site.

    Tim S.
    Last edited by stahta01; 04-01-2017 at 06:06 PM.
    "...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.." Bill Bryson

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Please help! I am so lost as to how to fix this!
    By blackfox_1109 in forum C Programming
    Replies: 1
    Last Post: 03-02-2014, 08:34 PM
  2. Help with Recursion. I'm so lost on this homework problem.
    By Kurtanius21 in forum C Programming
    Replies: 11
    Last Post: 12-06-2012, 09:10 PM
  3. Lost
    By Aparavoid in forum General Discussions
    Replies: 36
    Last Post: 06-13-2009, 03:16 AM
  4. lost value??
    By Hussain Hani in forum C++ Programming
    Replies: 4
    Last Post: 06-09-2009, 06:55 AM
  5. I'm lost
    By rainman39393 in forum C++ Programming
    Replies: 8
    Last Post: 02-24-2008, 03:38 PM

Tags for this Thread