I`m new in Programming stuffs.
So here is my codes:

#include<iostream.h>
#include<conio.h>

float records[5][5];
float ave;
int ctrX, ctrY;

main()
{
	clrscr();

	ctrY=0;
	for(ctrX=0;ctrX<=4;ctrX++)
	{
		cout<<"Student Number: ";
		cin>>records[ctrX][ctrY];
		ctrY++;

		do {
		cout<<"Quiz 1 Score: ";
		cin>>records[ctrX][ctrY];
			if ((records[ctrX][ctrY]<0)||(records[ctrX][ctrY]>30))
			{
				cout<<"The score supplied must be from 0 to 30 only!" <<endl;
			}
		} while ((records[ctrX][ctrY]<0)||(records[ctrX][ctrY]>30));
		ctrY++;

		do {
		cout<<"Quiz 2 Score: ";
		cin>>records[ctrX][ctrY];
			if ((records[ctrX][ctrY]<0)||(records[ctrX][ctrY]>30))
			{
				cout<<"The score supplied must be from 0 to 30 only!" <<endl;
			}
		} while ((records[ctrX][ctrY]<0)||(records[ctrX][ctrY]>30));

		do {
		cout<<"Quiz 3 Score: ";
		cin>>records[ctrX][ctrY];
			if ((records[ctrX][ctrY]<0)||(records[ctrX][ctrY]>30))
			{
				cout<<"The score supplied must be from 0 to 30 only!" <<endl;
			}
		} while ((records[ctrX][ctrY]<0)||(records[ctrX][ctrY]>30));
	}

		for (ctrX=0;ctrX<=4;ctrX++) {
			ctrY=1;
			ave=(records[ctrX][ctrY] + records[ctrX][ctrY++] + records[ctrX][ctrY++]) / 3;
		}

	getch();
	return 0;
}

My problem is, this code must display it in a column form. Then, I cannot display also the average.

Any comments / help will do.
Thanks in Advance!

Remove the .h from iostream.h - it it just #include <iostream>

You have not specified a namespace, so cout and cin should not work - they should be std::cout and std::cin. If your compiler lets you get away with this, it really shouldn't.

main() is illegal - your compile should refuse to compile this. A correct form is int main(void)

conio.h, clrscr() and getch() are non-standard and if you rely on them you'll have problems when you try to work on a different PC.

I cannot display also the average.

Try std::cout << ave;

Edited 5 Years Ago by Moschops: n/a

To get all your output in a column, put a std::endl on the end of each output

std::cout << "1st row" << std::endl;
std::cout << "2nd row" << std::endl;
std::cout << "3rd row" << std::endl;
This article has been dead for over six months. Start a new discussion instead.