mixed number to percentage

hi can anyone help me how to convert a mixed number into percentage one using function thank you for anyone who like to help me...

Comments

  • a=integer part
    b=numerator
    c=denominator

    [code][blue]function mixed2percentage(a,b,c:integer):real;
    begin
    mixed2percentage:=(a+b/c)*100;
    end;
    [/code]
  • Program try;
    uses crt;
    var i,o,p,s: integer;
    a:real;
    function Square(x,y:real):real;
    begin
    Square:=x/y*100;
    end;
    begin
    clrscr;
    writeln('Your whole number');
    readln(p);
    writeln('your numerator:');
    readln(i);
    writeln('your denaminator:');
    readln(o);
    a:=p*o+i;
    writeln(a/o:0:02);
    writeln('This is the result: ',Square(a,o):0:02,'%');
    readln;
    end.


    ok this is my codes hmmm ok anyway can you teach me how to do convert percent to proper fraction?i think that one is complicated
  • [code][color=Blue]program percentage_to_proper_fraction;


    function{ Returns the }biggest_common_divisor{ of }(a,{ and }b:longint):longint;
    var temp,remainder:longint;
    begin
    if a=b then begin
    biggest_common_divisor:=a;
    exit;
    end;
    if a0 then temp:=remainder;
    a:=b;
    b:=remainder;
    until remainder=0;
    biggest_common_divisor:=temp;
    end;

    var s:string;
    sl:byte absolute s; {lenght of s}
    r:real;
    code:integer;

    begin
    repeat
    write(#13#10,'Enter a percentage ( max. 3 decimals, must be <= 100 ) : ');
    readln(s);
    val(s,r,code);
    until ((sl>0) and (sl<7) and (code=0) and (r<=100));

    writeln(#13#10#32,trunc(r*1000) div biggest_common_divisor(trunc(r*1000),100000));
    writeln(#196#196#196#196);
    writeln(#32,100000 div biggest_common_divisor(trunc(r*1000),100000));

    readln;
    end.[/color][/code]
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories