1. Home
  2. /
  3. Ada
  4. /
  5. Counter and Theme Toggle

Counter and Theme Toggle - Ada Typing CST Test

Loading…

Counter and Theme Toggle — Ada Code

Demonstrates a simple counter with theme toggling using Ada variables and console output.

with Ada.Text_IO; use Ada.Text_IO;
procedure Counter is
	Count : Integer := 0;
	Is_Dark : Boolean := False;

	procedure Update_UI is
	begin
		Put_Line("Counter: " & Integer'Image(Count));
		Put_Line("Theme: " & (if Is_Dark then "Dark" else "Light"));
	end Update_UI;

begin
	-- Initial display
	Update_UI;

	-- Increment counter
	Count := Count + 1;
	Update_UI;

	-- Increment counter again
	Count := Count + 1;
	Update_UI;

	-- Toggle theme
	Is_Dark := not Is_Dark;
	Update_UI;

	-- Decrement counter
	Count := Count - 1;
	Update_UI;

	-- Reset counter
	Count := 0;
	Update_UI;
end Counter;

Ada Language Guide

Ada is a statically typed, high-level programming language designed for safety-critical, real-time, and concurrent systems. Developed with reliability and maintainability in mind, Ada emphasizes strong typing, modularity, exception handling, and support for concurrent programming.

Primary Use Cases

  • ▸Safety-critical avionics systems
  • ▸Real-time embedded software
  • ▸Railway signaling and control
  • ▸Defense and military software
  • ▸Medical device software
  • ▸High-integrity systems requiring formal verification

Notable Features

  • ▸Strong static typing and compile-time checks
  • ▸Support for tasking (concurrency)
  • ▸Exception handling and robust error management
  • ▸Package-based modularity
  • ▸Design-by-contract with pre/post conditions

Origin & Creator

Ada was commissioned by the U.S. Department of Defense in the late 1970s and early 1980s, designed by Jean Ichbiah and his team at CII Honeywell Bull under the name 'Ada' in honor of Ada Lovelace.

Industrial Note

Ada is essential in avionics, railway control systems, nuclear power plant software, medical devices, and mission-critical defense applications where software failure is unacceptable.

More Ada Typing Exercises

Ada Simple AdditionAda FactorialAda Fibonacci SequenceAda Max of Two NumbersAda List SumAda Even Numbers FilterAda Conditional Counter IncrementAda Resettable CounterAda Theme Toggle Only

Practice Other Languages

CReactPythonC++RustTypeScriptKotlinPHPJavaC#RubyMqlCqlN1qlCypher