Hi there,
absolute beginner here.
Got this piece of code and have to phrase pre and postcondition as well as commenting what the program does.
As a precondition I got a > 0.
If I enter test value a = 7 the program calculates b = 111, for a = 10 b is 1010.
I can't figure out what the program does so any help would be appreciated.
Thanks and best
program Whathappens (input, output);
var
a,b,c: integer;
begin
b := 0;
c := 1;
writeln ('Bitte a eingeben');
readln(a);
while a>0 do
begin
b := b + c*(a mod 10);
a := a div 2;
c := 10 * c;
end;
writeln(b);
end.