0
Good night! When I was studying for the test I’m going to take, I faced that question. However, when I performed the program, I did not realize what I did. I would like you to see my code in order to better understand my mistake. Thank you very much.
Do a program that reads the instruction degree (whole type) and age of a group of people and display the age of the elder (consider that there is no tie) in each degree of instruction. End of reading: degree of instruction = 0. The following instruction grade codes are given: 1 - Illiterate, 2 - First degree, 3 - Second degree, 4 - Higher, 5 - Master’s degree, 6 - Doctorate, 7 - Others. Perform the following duties: a) initializes(): takes as parameter an array of integers and initialize it properly. b) displays():takes as parameter a integer vector already filled and displays the age of the oldest (consider that there is no tie) in each instruction grade.
#include <stdio.h>
#define TOT 7
void inicializa (int *vet){
int i;
for (i = 0; i < TOT; i++){
}
}
void exibe (int *vet){
int i;
int velho;
velho = 0;
for (i = 0; i < TOT; i++){
if (velho < vet[i])
velho = vet[i];
}
printf ("%d", velho);
}
int main (){
int *vet[TOT], cont, idade, pessoas, instrucao;
printf ("Digite a quantidade de pessoas\n");
scanf ("%d", &pessoas);
inicializa (vet);
for (cont = 0; cont < pessoas;cont++){
printf ("Digite o grau de instrucao\n");
scanf ("%d", &instrucao);
switch (instrucao)
{
case 1:
printf ("Analfabeto");
printf ("Digite sua idade");
scanf ("%d", &idade);
break;
case 2:
printf ("Primeiro Grau");
printf ("Digite sua idade");
scanf ("%d", &idade);
break;
case 3:
printf ("Segundo grau");
printf ("Digite sua idade");
scanf ("%d", &idade);
break;
case 4:
printf ("Superior");
printf ("Digite sua idade");
scanf ("%d", &idade);
break;
case 5:
printf ("Mestrado");
printf ("Digite sua idade");
scanf ("%d", &idade);
break;
case 6:
printf ("Doutorado");
printf ("Digite sua idade");
scanf ("%d", &idade);
break;
case 7:
printf ("Outros");
break;
default:
printf ("opcao invalida");
}
exibe (vet);
}
return 0;
}
It wouldn’t be to show 7 values every time
exibe
be called?– Marcelo Shiniti Uchimura