Fala galera, beleza? Então, eu tenho que criar um programa que some números binários, e no geral creio que está dando certo mas agora eu tento compilar e diz que os dados informados no writeln da varivavel vetorial resp não são primitivos!(?) Segue o código de até agora:
Program Pzim ;
var bin1,bin2:string[4];
i,j,vai,expoente1,expoente2,tam1,tam2:integer;
deci,deci1,deci2:real;
resp:array[1..5] of string;
Begin
Writeln ('Soma de binários!');
Writeln ('Digite o primeiro número binário de quatro dígitos');
readln (bin1);
Writeln ('Digite o segundo número binário de quatro dígitos');
readln (bin2);
tam1:=length(bin1);
for i:=tam1 downto 1 do
Begin
If bin1='1' then
deci1:=deci1+(exp(expoente1*ln(2)));
expoente1:=expoente1+1;
End;
Writeln ('O número binário ',bin1,' é igual a ',deci1:0:0,' decimal');
tam2:=length(bin2);
for i:=tam2 downto 1 do
Begin
If bin2='1' then
deci2:=deci2+(exp(expoente2*ln(2)));
expoente2:=expoente2+1;
End;
Writeln ('O número binário ',bin2,' é igual a ',deci2:0:0,' decimal');
deci:=deci1+deci2;
Writeln ('A soma dos números em decimal é igual a ',deci:0:0);
Writeln;
//soma
vai:=0;
for i:=tam1 downto 1 do
Begin
if (bin1='0') and (bin2='0') and (vai=0) then
begin
Writeln ('Desce 0');
resp[j]:='0';
vai:=0;
end;
if (bin1='0') and (bin2='1') and (vai=0) then
begin
Writeln ('Desce 1');
resp[j]:='1';
vai:=0;
end;
if (bin1='1') and (bin2='0') and (vai=0) then
begin
Writeln ('Desce 1');
resp[j]:='1';
vai:=0;
end;
if (bin1='1') and (bin2='1') and (vai=0) then
begin
Writeln ('Sobe 1');
resp[j]:='0';
vai:=1;
end;
if (bin1='1') and (bin2='0') and (vai=1) then
begin
Writeln ('Sobe 1');
resp[j]:='0';
vai:=1;
end;
if (bin1='0') and (bin2='1') and (vai=1) then
begin
Writeln ('Sobe 1');
resp[j]:='0';
vai:=1;
end;
if (bin1='1') and (bin2='1') and (vai=1) then
begin
Writeln ('Sobe 1 e vai 1');
resp[j]:='1';
vai:=1;
end;
End;
if vai=1 then
Begin
Writeln ('Desce 1');
resp[j]:='1';
end;
Writeln (resp);
Writeln ('Aperte qualquer tecla para sair');
Readln;
End.