Two dimensional arrays in c++

this is my unfinished codes:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include<iostream>
#include<new>
using namespace std;

int main()
{
int i,n,c;
int * p;
cout<<"Enter student number of grades";
p=new (nothrow) int[i];
if (p==0)
cout<<"Invalid";
else
{
for (n=0; n<1; n++)
{
cout>>"Enter Grades:";
cin>>p[n];


I want to insert number of students like for example:
this is the sample output...
Enter Number of Students :2
Enter Number of Grades to be entered for every students: 3

Enter Student Number 1 Grades
1. 80
2. 90
3. 89
Enter Student Number 2 Grades
1. 89
2. 90
3. 95


NOW I want to Insert the Number of Students how can i insert it..
and i don't know what codes to be entered THANK YOU!!!
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include<iostream.h>

main()
{
	int student[1000],grade[1000];
	int i,j,ts,tg;

	cout<<"Enter Number of Students: ";
	cin>>ts;
	cout<<"Enter Number of Grades to be entered for every students: ";
	cin>>tg;
	cout<<endl;
		for(i=1;i<=ts;i++)
		{
		  cout<<"Enter Student Number "<<i<<" Grades";cout<<endl;
			for(j=1;j<=tg;j++)
			{

				cout<<j<<". ";cin>>grade[j];
			}
		}
}


you mean like this ran???
w8 i will put my full output .. hope that you can help me! tnx qabil
You could work with dynamic arrays

std::vector<type> varname

which is in the standard library (#include <vector>). set the size with varname.resize(int numberofelements).
example code for a struct Student:

1
2
3
4
5
6
7
8
struct Student {
    int id;
    std::vector<int> grades;
    
    Student(int numberofgrades) { // Constructor
        grades.resize(numberofgrades);
    }
};
closed account (S6k9GNh0)
If you do not know the size of the array at compile-time, it's usually a good idea to go with a vector.
Sir, this is the full output can u help with the codes . I am doing it for a week but i can't do exactly the output .Hope that you can help me thank you. God Bless.

Enter Number of Students : 2
Enter Number of Grades to be entered for every students : 3

Enter Student Number 1 Grades
1.80
2.80
3.80
Enter Student Number 2 Grades
1.90
2.90
3.90
Student-Lowest-Highest-Average
1 ----- 80 ----- 80 ----80
2 ----- 90 ----- 90 ----90
note:(the number must be aligned) without the dashes!
DO YOU WANT TO ENTER ANOTHER SET OF GRADES?[Y/N]:Y
Topic archived. No new replies allowed.