Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

39,844 questions

51,765 answers

573 users

How to insert an element in a set with Pascal

1 Answer

0 votes
program InsertElementInSet;

type
  TMySet = set of 1..10; // Define a set with elements from 1 to 10

var
  MySet: TMySet;
  i : Integer;

begin
  MySet := []; // Initialize the set as empty
  Include(MySet, 1); // Insert the element 1 into the set
  Include(MySet, 5); // Insert the element 5 into the set
  Include(MySet, 6); // Insert the element 6 into the set

  // Display the result
  if 5 in MySet then
    WriteLn('Element 5 has been successfully added to the set!');
    
  for i := Low(TMySet) to High(TMySet) do
    if i in MySet then
      WriteLn('Set contains: ', i);
end.




(*
run:
  
Element 5 has been successfully added to the set!
Set contains: 1
Set contains: 5
Set contains: 6

*)

 



answered Aug 5, 2025 by avibootz
edited Aug 5, 2025 by avibootz
...