I'm setting up a program here in Pascal, where I have a record with 3 positions, each with name, age and weight. I also have a procedure called Query, which will allow me to search for a registered name, and return their age and weight. My problem is precisely this, how do I get that name? Do you have to use for? Do you have to create a new array? Give me a light: D
If you want to see the program, follow below:
Program Pzim ;
var opc, num: integer;
esc: char;
cad:array[1..3] of record
nome: string[30];
idade: integer;
peso: real;
end;
procedure menu;
begin
writeln;
writeln('1. Cadastro');
writeln('2. Consulta');
writeln('3. Exclusao');
writeln('4. Sair');
writeln;
write('Opcao: ');
readln(opc);
writeln;
end;
procedure cadastro;
begin
while (esc <> 'n') do
begin
writeln('Digite o seu nome:');
readln(cad[num].nome);
writeln('Digite a sua idade:');
readln(cad[num].idade);
writeln('Digite o seu peso:');
readln(cad[num].peso);
writeln('Cadastro concluído. Gostaria de realizar outro? (s: sim/n: nao)');
readln(esc);
num:=num+1;
end;
if (num>3) then
begin
writeln('Você só pode fazer 3 cadastros!');
menu;
end;
menu;
end;
procedure consulta;
begin
while (esc<>'n') do
begin
writeln('Digite o nome do usuário cadastrado:')
readln();
Begin
num:=1;
menu;
if opc=1 then
begin
cadastro;
end;
End.