define an array to store marks of 30 students in 3 subjects
Answers
QUESTION :
Define an array
Answer:
In computer science, an array data structure, or simply an array, is a data structure consisting of a collection of elements, each identified by at least one array index or key. An array is stored such that the position of each element can be computed from its index tuple by a mathematical formula.
Explanation:
HOPE IT'S HELPFUL
KINDLY MARK AS A BRAINLIST ✌
️AND IF IT IS POSSIBLE THEN FOLLOW TOO
Answer:
- To store the records of 30 students and each having marks of three subjects we have to use the multidimensional array concept .
- The multidimensional array is used when more than one related value to be stored in a single array.
int array[30][3] ;
- We can use the array of Structure also to store the marks of 30 students in 3 subjects. Here, the Structure will hold the marks for three different subjects.
The following C++ program has been constructed based on the concept of ' Structure of Array'.
#include<iostream>
#include<conio.h>
using namespace std;
// structure to hold the marks for 3 different subjects
struct stud
{
float m1, m2, m3;
};
typedef stud S;
int main()
{
// Array of structure to hold the records for 30 students
S student[30];
for(int i =0 ; i < 30 ; i++)
{
cout << "\n Enter marks of three subjects :";
cin >> student[i].m1 >> student[i].m2 >> student[i].m3 ;
}
for(int i =0 ; i < 30 ; i++)
{
cout << "Marks of "<< i+1 <<"Student in 3 subjects : \n";
cout << student[i].m1 << "\n";
cout << student[i].m2 << "\n";
cout << student[i].m3 << "\n";
}
getch();
return 0;
}
Explanation:
- Input for three students
Enter marks of three subjects :12 23 34
Enter marks of three subjects :20 23 35
Enter marks of three subjects :23 34 45
- Output for three students
Marks of 1Student in 3 subjects :
12
23
34
Marks of 2Student in 3 subjects :
20
23
35
Marks of 3Student in 3 subjects :
23
34
45
For more similar type of Questions, please click here ->
https://brainly.in/question/37309185
https://brainly.in/question/2337020