Good evening! When I was studying for the test I will do, I faced this question. However, when the program was done, it had a warning and did not perform what I did. I would like you to see my code in order to better understand my error. Thanks in advance.
Make a program that reads the degree of instruction (whole type) and age of a group of people and display the age of the oldest (consider that there is no tie) in each degree of instruction. End of reading: degree of instruction = 0. The following instruction codes are used: 1 - Illiterate, 2 - First degree, 3 - High school, 4 - Higher, 5 - Masters, 6 - PhD, 7 - Others. Do the following functions: a) initializes (): receives as a parameter a vector of integers and initialize it properly. b) displays (): receives as parameter a vector of already completed integers and displays the age of the oldest (consider that there is no tie) in every degree of instruction.
#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;
}