Problem: Use a 2 dimensional static array with 3 rows & 2 columns to the course number and number grade you have received in that course. The program should have three functions called get information, printinformation, and convert. You need to send array to getinformation and printinformation functions as parameters. The get information will ask for course no. and their grades and fill up the array. The printinformation function will first print out the course numbers, then will call the convert function to convert the number grade to letter grade and then print out the letter grade.

After that change your program with dynamic array and decide total number of courses during runtime.

My program:

#include<string>
#include<iostream>
using namespace std;

char convert(int array[3][2]);
int main()
{

        int i, j; int array[3][2];
        for (i=0; i < 3; i++)
        {
                cout <<"First enter course number and then number grade "<<" : "<<endl;
                for (j=0; j < 2; j++)
                {

                        cin >> array[i][j];
                }
        }
        cout <<"     Course Number          Number Grade"<<endl;
        cout <<"     _____________          ____________"<<endl;
        cout <<endl;

        for (i=0; i < 3; i++)
        {
                for (j=0; j < 2; j++)
                {
                        cout <<"          "<< array[i][j]<<"          ";
                }
                cout <<endl;
        }
        for (i=0; i < 3; i++)
        {
                int j=0;
                cout <<"For course CSCE "<<array[i][j]<<" your grade is ";

                char Agrade[i][j]; int j=1, myarray[3][2];
                Agrade[i][j] = convert(myarray[i][j]);
                cout << Agrade[i][j]<<endl;
                return 0;

}
char convert(int array[3][2])
{
  int i, j=1;
        for (i=0; i < 3; i++)
        {
                char fgrade[i][j];
                if (myarray[i][j] >= 90)
                        fgrade[i][j] = 'A';
                else if (myarray[i][j] >= 80)
                        fgrade[i][j] = 'B';
                else if (myarray[i][j] >= 70)
                        fgrade[i][j] = 'C';
                else if (myarray[i][j] >= 60)
                        fgrade[i][j] = 'D';
                else
                        fgrade[i][j] = 'F';
                return fgrade[i][j];
        }


}

Edited 3 Years Ago by mike_2000_17: Fixed formatting

First, you will need to learn how to use code tags, see the announcement and the sticky threads at the top of the board, when posting code to this board. Without many of the more respected people who visit this board won't bother to respond to your post because the code looses it's format making difficult to read comfortably.

Second, start another project and do things one step at a time, from the beginning of your instructions. That is, start by declaring a static 2 dimensional array of ints, like you did in your post, and then passing it to a function called getInformtaion(). Obtain your data from within that function using something like this:

for (int i=0; i < 3;  i++)
{
    cout << "enter course number "<< endl;
    cin >> array[i][0];
    cout <<"enter number grade" << endl;
    cin >> array[i][1];
}

When that compiles, then write a funciton to display the array data that was enetered as a numeric value. Then add the function to convert the numeric value to a character value during the display process. And then rewrite the program using dynamic memory to declare the array to be used instead of static memory in the original program. DON'T start at the back end of the progra or create the entire project and then try to correct it.

This article has been dead for over six months. Start a new discussion instead.