2
I need to print only the notes above >=6, in which place of the code I put the if
or some other instruction?
I tried and I couldn’t find the right place.
#include <iostream>
#include <string.h>
using namespace std;
#define MAX 50
struct aluno {
char nome[50];
int matricula;
float nota;
};
void imprime(aluno v[], int num);
int main(void) {
// Declara um aluno
aluno alunos[MAX];
alunos[0].matricula = 12014432;
alunos[0].nota = 7.5;
strcpy(alunos[0].nome,"Fulano");
alunos[1].matricula = 13022301;
alunos[1].nota = 5.9;
strcpy(alunos[1].nome,"Sicrano");
alunos[2].matricula = 11024122;
alunos[2].nota = 4.0;
strcpy(alunos[2].nome,"Beltrano");
alunos[3].matricula = 11014120;
alunos[3].nota = 6.1;
strcpy(alunos[3].nome,"Huguinho");
alunos[4].matricula = 11024012;
alunos[4].nota = 8.0;
strcpy(alunos[4].nome,"Zezinho");
alunos[5].matricula = 11014117;
alunos[5].nota = 3.5;
strcpy(alunos[5].nome,"Luizinho");
imprime(alunos, 6);
}
void imprime(aluno v[], int num) {
int i;
for (i=0; i<num; i++) {
cout << "Mat.: " << v[i].matricula << endl;
cout << "Nome: " << v[i].nome << endl;
cout << "Nota: " << v[i].nota << endl;
}
}
I almost got had put if (note[i]>=6), thank you very much again.
– Paulo Roberto
To print the note you used
v[i].nota
, To verify which note is, it doesn’t have to be different. The note is the note, it can’t be one way in one place and another in another place. in this case you’re taking the fieldnota
of the element indicated byi
vectorv
.– Maniero