Wite a program to use parrel arrays using Visual C++

Discussion in 'C++' started by alvinkumar9, Aug 10, 2011.

  1. alvinkumar9

    alvinkumar9 New Member

    Joined:
    Aug 10, 2011
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    Question: You are required to write a program to use parrel arrays to determine grades of students from their given marks using the instructions given below:
    i. Create a loop to read the students' IDs and their corresponding total marks in the course from the students.txt input file.
    *While reading store the ID numbers and Marks in two seperate parrel arrays. One array should contain IDs and another array should contain marks i.e string id[] and int marks[]
    *Hint: use a while loop structure to read data from a file.
    ii. Print out ID numbers and Marks of all the students on the screen after reading the data from the input file is done.
    iii. iii. The function: char determine_grade(int total_mark) defines how to
    determine the grade for each student according to the criteria in the following table:
    Marks Grade
    80-100 A
    65-79 B
    50-64 C
    0-49 D
    • The function receives as parameter the mark of a student and returns the grade
    character corresponding to the mark range. The function is already defined.
    • Determine the grade of each student by calling the determine_grade()
    2
    function within a loop that reads the mark of each student from the marks
    array. The grade returned is stored in the char grades[] array for each
    student.
    iv. Define the function: void print_students_records(string sid[],
    char sgrades[], int size) to print students’ IDs and their corresponding
    grades. The function receives the id, and grades arrays and size (size is the
    number of records to print). Call this function after the grades have been
    determined.
    v. Define the function: int total_failed_students(int smarks[],
    int size) to determine the number of students who have failed the course. The
    function receives the marks array and size and returns the number of students
    failed. Call this function after printing student records.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice