Ask Question

Name:
Title:
Your Question:

Answer Question

Name:
Your Answer:
User Submitted Source Code!


Description:
  covertisseu
Language: PASCAL
Code:
program Convertir;
var
 test:boolean ;
 ch,ch1,ch2:string;
s,p,n,r,e,i:integer;
begin
 repeat
  writeln('entrer  ch ');
  Readln(ch);
   Test:=true;
    For i:=1 to length(ch) do
     if ch[i] not in ["0".."7"] then 
      test:=false ;
   until(test=true);
s:=0;
p:=1;
 For i:=length(ch) down to 1 do 
  VAL(ch[i],n,e);
  s:=s+p*n;
  p:=p*8;
ch1:=""
 Repeat
  r:=smod2;
  STR(r,ch2);
  ch1:=ch2+ch1;
  s:=sdiv2;
 until (sdiv2=0);
writeln("le code octale ",ch,"vaut ",ch1,"en binaire"); 
end.          
Comments: