hi ^^/
i'm new here ,, & i have some questions :pretty: ,,
mmm,, it may sound easy to u ,, but what can i do i'm just a beginner:icon_sad: ..

can some1 explain to me how to do this program using 2-dimentional arreys ?
pls dont write the code ,, its my assignment :icon_cheesygrin: ,, & i wanna learn not cheat :P


[/B]
[B]Enter the grades for student #1[/B]
[B]Exam1:  65[/B]
[B]Exam2:  77[/B]
[B]Exam3:  76[/B]
[B] [/B]
[B]Enter the grades for student #2[/B]
[B]Exam1:  78[/B]
[B]Exam2:  92[/B]
[B]Exam3:  88[/B]
[B] [/B]
[B]Enter the grades for student #3[/B]
[B]Exam1:  78[/B]
[B]Exam2:  68[/B]
[B]Exam3:  89[/B]
[B] [/B]
[B]Student grades are as follows:[/B]
[B]______________________________[/B]
[B]        Exam1   Exam2   Exam3[/B]
[B]St-1    65      77      76[/B]
[B]St-2    78      92      88[/B]
[B]St-3    78      68      89[/B]
[B] [/B]
[B]Lowest grade:   65 by student 1[/B]
[B]Highest grade:   92 by student 2[/B]
[B] [/B]
[B]The average grade for student 1 is +72.7[/B]
[B]The average grade for student 2 is +86.0[/B]
[B]The average grade for student 3 is +78.3[/B]
[B]Press any key to continue [/B]
[B]



btw the user have to enter the grades ,
when i tried to do it , it didnt loop corectly ! i used a for loop twice , one for the row and the other for the column but it come out WRONG T_T ,,

help:icon_cheesygrin:

Recommended Answers

All 4 Replies

Post your code and we'll take a look at it. :)

Post your code and we'll take a look at it. :)

ok ,, i'll try to write it again :confused: ,,

heloO :) ..
i coudnt complete it ,, :sad: but at leasti did the first part,,
mmm but still i need som1 to explain it 2 me ,, cuz i did it in the most retarded way ever:-/ ,, & how can i [COLOR=#000000]print the scores in that tabular format :?: ..

#include<iostream>


int main()
{
using namespace std;

int studentGrades[3][3], ST[3]={1,2,3};

for (int row=0; row<3 ; row++)
{
for (int col=0; col<3; col++)
{
cout<< "Enter the grade for student#" <<ST[row++] << ":\n";
for (int i=1; i<=3; i++)
{
cout << "Exam" << i << ":\t" ;
cin >> studentGrades[row][col];

}
cout << endl;
}
}
cout << "Student grades are as follows:\n\n"

<< "________________________________\n"

<< "\tExam\tExam2\tExam3\n";


return 0;
}

>cuz i did it in the most retarded way ever
Not really. You're on the right path. You need to split up the data entry and printing parts. They can both be written using a simple nested loop for a two dimensional array:

// Read the student's grades
for ( int i = 0; i < 3; i++ ) {
  for ( int j = 0; j < 3; j++ ) {
    // Enter a grade into studentGrades[i][j]
  }
}

// Print the report header

// Print the grades
for ( int i = 0; i < 3; i++ ) {
  for ( int j = 0; j < 3; j++ ) {
    // Print studentGrades[i][j]
  }
}

Then it's just a matter of tweaking the formatting until you have a nice table.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.