my program is to calculate the student gpa first prompt the user to enter the score and display the grade and also calculate the total grade
this is my program i stuck in the half way please help:
Printable View
my program is to calculate the student gpa first prompt the user to enter the score and display the grade and also calculate the total grade
this is my program i stuck in the half way please help:
Here is what I saw...
Here is a start. You need to pass data into input_table(), have it operate on some data, and then return something. In other wordsCode:#include<stdio.h>
#include<stdlib.h>
#define column_size 30
#define row_size 50
char scoretograde(int score);
void compute_grade_distribution(int list_size,const char letter_grades[],int distribution[]);
void input_table(int *rows,int *column,int arr[][column_size]);
void output_table(int rows,int columns,const int arr[][column_size]);
int main()
{
int test_score[row_size][column_size];
int rows,columns,score;
float GPA;
input_table(&rows,&columns,test_score);
output_table(rows,columns,test_score);
return 0;
}
void input_table(int *no_of_rows,int *no_of_columns,int arr[][column_size])
{
int i,j;
printf("\n");
printf("\t\t\tKOLEJ TUNKU ABDUL RAHMAN\n");
printf("\t\t\t------------------------\n");
printf("\n");
printf("Enter number of rows : ");
scanf("%d",&(*no_of_rows));
printf("Enter number of columns : ");
scanf("%d",&(*no_of_columns));
for(i=1;i<=*no_of_rows;i++)
for(j=1;j<=*no_of_columns;j++)
{
printf("Enter value of test score [%d][%d] :",i,j);
scanf("%d",&arr[i][j]);
}
}
void output_table(int rows,int columns,const int arr[][column_size])
{
int i,j;
system("cls");
printf("\n");
printf("\t\t\tEXAMINATION PERFORMANCE REPORT\n");
printf("\t\t\t------------------------------\n");
printf("\n");
printf("Student No\tAACS1084\tAACS1123\tGrade Point Average\n");
printf("----------\t--------\t--------\t-------------------\n");
for(i=1;i<=rows;i++){
printf("\t\n%3d",i);
for(j=1;j<=columns;j++)
printf("\t\t%3d",arr[i][j]);
}
printf("\n\n");
printf("AVERAGE GPA = %d\n ");
printf("\n");
printf("HIGHEST GPA = %d obtained by student No.=\n");
printf("LOWEST GPA = %d obtained by student No.=\n");
}
should appear before input_table() in main().Code:int i,j;
printf("\n");
printf("\t\t\tKOLEJ TUNKU ABDUL RAHMAN\n");
printf("\t\t\t------------------------\n");
printf("\n");
printf("Enter number of rows : ");
scanf("%d",&(*no_of_rows));
printf("Enter number of columns : ");
scanf("%d",&(*no_of_columns));
Now, for the second thing.
Code:for(i=1;i<=*no_of_rows;i++)
for(j=1;j<=*no_of_columns;j++)
{
printf("Enter value of test score [%d][%d] :",i,j);
scanf("%d",&arr[i][j]);
}
When you loop over a multidimensional array, you would do something like the following
In other words, you want 'i' to be the first row in the array, then you use another loop to iterate over the colums in first array. Then you increase the value of 'i' so it it would the second row in the array and then iterate over the columns in the second row. Of course this would be differenf if this was an array of pointers.Code:/*This loop runs in quadratic time. But I don't think it's relevant to the issue at hand*/
int i, j;
i=1;
j=1;
for(i=1;i<=no_of_rows[i][j];i++) {
for(j=1;j<=no_of_columns[i][j];j++){
/ *do stuff*/
}
}
Just my 2 cents on the problem.