#include
#include
#define NMAX 10
#include
using namespace std;
struct pagella{
char cognome[21];
char nome[21];
char classe[3];
int ita;
int mate;
int ele;
};
int j=0;
Funzione di input
void input(int &n, pagella pagelle[]);
void output(int &n, pagella pagelle[]);
int main(){
int n;
pagella pagelle[20];
input(n, pagelle);
output(n, pagelle);
return 0;
}
void input(int &n, pagella pagelle[]){
do{
cout
cin>>n;
}while(n = 20);
coutendl;
for(int i=0; i
cout
cin>>pagelle.cognome;
cout
cin>>pagelle.nome;
do{
cout
cin>>pagelle.classe;
}while(pagelle.classe = "1SA");
do{
coutvoto di italiano: ";
cin>>pagelle.ita;
}while(pagelle.ita .ita >= 10);
do{
coutvoto di matematica: ";
cin>>pagelle.mate;
}while(pagelle.mate .mate >= 10);
do{
coutvoto di elettronica: ";
cin>>pagelle.ele;
}while(pagelle.ele .ele >= 10);
}
}
void output(int &n, pagella pagelle[]){
for(int i=0; i
cout.cognome
cout.nome
cout.classe
cout.ita
cout.mate
cout.ele
}
cout
}
Domande da interrogazione
- What is the purpose of the `pagella` structure in the code?
- How does the `input` function ensure valid data entry for student grades?
- What is the role of the `output` function in the program?
The `pagella` structure is designed to store student information, including their surname, name, class, and grades in Italian, mathematics, and electronics.
The `input` function uses `do-while` loops to repeatedly prompt the user for input until valid grades are entered, ensuring that each grade is between 0 and 10.
The `output` function iterates through the array of `pagella` structures and prints each student's details, including their surname, name, class, and grades, to the console.