locked
C++ Managing Exam Results Help RRS feed

  • Question

  •  

    Hi guys

     

    I am trying to work out around my project but having few issues with. Hope you guys can help me out with that.

     

    (1) First of all my program is not sticked to screen just blow away (in other words auto exit without anything)

    (2) I am trying to update an Array but its not working for some reason, i dont know why.

    (3) How do I use search in this program? any suggestions?

     

    Thanks

     

    Cheers,

    Dev

     

    Here is my Program:

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

     

    #include <iostream>

    using std::cout;

    using std::cin;

    using std::endl;

    #include<iomanip>

    using std:: setw;

    #include <cctype> //For toupper

     

    //function declarations

    void modifyArray(int[], int);

    void modifyElement(int);

    //public variable

    int selectnum; /* defines input*/

    int GetResult; /* defines conversion input*/

    //main

    int main()

    {

    // Variable Declarations

    const int arraysize=5;

    int a [ arraysize ]={ 0, 0, 0, 0, 0 };//initialize a

    cout << "\n ********* Welcome to C++ Program for Managing Exam Results ********\n\n"; /*Displays Title*/

    cout << " 1. Read and Store Exam Results\n";

    cout << " 2. Sort and Display Results in Ascending Order\n";

    cout << " 3. Calculate Fail Rate\n";

    cout << " 4. Search for a particular Result\n";

    cout << " 5. Display All Result\n";

    cout << " 6. Exit\n\n\n";

    cout << " Enter 1/2/3/4/5/6: ";

    cin>>selectnum;

    if (selectnum<=6)

    {

    cout<<"The current Results are:\n";

    for (int i = 0; i < arraysize; i++) //output original array element

    cout << setw( 3 ) << aIdea; NOTE: it's " i " in brackets [ ] instead of light

    cout<<endl;

    cout<<"Do you wish to update the current results?:"<<endl;

    //pass array a TO modifyArray by reference

    modifyArray(a,arraysize);

    cout<<"The updated results are:\n";

    //ouput modified array elements

    for (int j=0;j<arraysize;j++)

    cout << setw( 3 ) << a[j];

    }

    return 0;

    }

    void modifyArray(int b[],int sizeOfArray)

    {

    //multiply each array by two

    for (int k = 0;k < sizeOfArray; k++)

    b[k]*=2;

    }

    void modifyElement(int e)

    {

    //multiply parameter by 2

    cout<<"Value of Element in modifyElement:"<<( e *= 2 )<<endl;

    }

    Thursday, January 31, 2008 9:45 AM

Answers