Write an Pascal Program For Variants Initialization - Computer Programming

Latest

C C++ Java Python Perl Programs Examples with Output -useful for Schools & College Students

Saturday, September 23, 2017

Write an Pascal Program For Variants Initialization

 Pascal - Variants

Program:
Program exVariant;

uses variants;
type
color = (red, black, white);

var
v : variant;
i : integer;
r: real;
c : color;
as : ansistring;


begin
i := 100;
v:= i;
writeln('Variant as Integer: ', v);

r:= 234.345;
v:= r;
writeln('Variant as real: ', v);

c := red;
v := c;
writeln('Variant as Enumerated data: ', v);

as:= ' I am an AnsiString';
v:= as;
writeln('Variant as AnsiString: ', v);
end.


Output:
Variant as Integer: 100
Variant as real: 234.345
Variant as Enumerated data: 0

Variant as AnsiString: I am an AnsiString

No comments:

Post a Comment