Previous topic | Ada Home Page | Index

Parameter association

Example: program to swap integers

    with TEXT_IO;
    procedure swap_demo is

        package int_io is new TEXT_IO.INTEGER_IO(INTEGER);
        use text_io, int_io;

        A, B : INTEGER;


        procedure swap (X, Y : in out INTEGER) is
                -- Swaps the value of two integer variables
            temp : INTEGER;    -- temporary storage
        begin 
            temp := X;
            X := Y;
            Y := temp;
        end swap;


    begin -- swap_demo
        A :=  1;
        B := 23;
        put(A); put(B); NEW_LINE;
        swap (A, B);
        put(A); put(B); NEW_LINE;
    end swap_demo;

Formal parameters in procedure

Actual parameters in calling program


Previous topic | Ada Home Page | Index
c-lokan@adfa.oz.au / 14 Feb 96