In: Computer Science
|
|
|
|
a) an array is a contiguos block of memory which is allocated during compile time to store data belonging to a particular datatype.Whereas the structure is defined as a template which can used to encapsulate related data into one object.
for example int a[10]; //this is an array
whereas struct student
{
string name;
string rollId;
}
this is a structure of student which acts as a template.
b)
struct StudentScore
{
string name;
string regNo;
string courseCode;
float marks;
};
c)StudentScore studentCS680[50];
d)
void input(){
cout<<"Enter data for 50 students";
float avg = 0.0;
for(int i = 0;i < 50;++i)
{
cout<<"\nName : ";
getline(cin,studentCS680[i].name);
cout<<"\nReg No: ";
getline(cin,studentCS680[i].regNo);
cout<<"\nCourseCode : ";
getline(cin,studentCS680[i].courseCode);
cout<<"\nMarks : ";
cin >> studentCS680[i].marks;
avg += studentCS680[i].marks;
}
avg = avg / 50;
cout<<"\nAverage "<<avg;
}