100% Free Forever
AI-Powered Learning
Industry Expert Content
Certificates & Badges
Learn At Your Own Pace

Ada Cheat Sheet

Ada Cheat Sheet

Key Ada syntax covering strong typing, control flow, packages, and exception handling for safety-critical software.

2 PagesIntermediateApr 2, 2026

Hello World

A minimal Ada procedure.

ada
with Ada.Text_IO; use Ada.Text_IO;procedure Hello_World isbegin   Put_Line ("Hello, World!");end Hello_World;

Types & Variables

Declaring variables and custom types.

ada
declare   X : Integer := 42;   Y : Float := 3.14;   Name : String := "Ada";   type Day is (Mon, Tue, Wed, Thu, Fri, Sat, Sun);  -- enumeration   type Percentage is range 0 .. 100;                -- constrained subtype   Today : Day := Wed;begin   Put_Line ("X = " & Integer'Image (X));end;

Control Flow

Conditionals, loops, and procedures.

  • if / elsif / else- if cond then ... elsif cond2 then ... else ... end if;
  • for loop- for I in 1 .. 10 loop ... end loop; counts over a range
  • while loop- while cond loop ... end loop; condition-checked loop
  • case statement- case Day is when Mon => ... when others => ...; end case;
  • loop with exit- loop ... exit when cond; end loop; explicit-exit loop
  • procedure Name (Arg : Integer) is ... end Name;- Procedure declaration

Packages

Splitting specification and body across a package.

ada
package Math_Utils is   function Square (X : Integer) return Integer;end Math_Utils;package body Math_Utils is   function Square (X : Integer) return Integer is   begin      return X * X;   end Square;end Math_Utils;

Exceptions

Raising and handling errors.

  • exception when Constraint_Error => ...- Handles a specific predefined exception
  • raise Program_Error;- Explicitly raises an exception
  • Ada.Exceptions- Package for inspecting/handling exception information
  • others =>- Catch-all branch in an exception handler
  • My_Error : exception;- Declares a user-defined exception
  • begin ... exception ... end;- Block structure pairing handlers with a scope
Pro Tip

Lean on Ada's strong typing — define distinct subtypes with explicit ranges (type Percentage is range 0 .. 100) so the compiler catches out-of-range and unit-mixing bugs before runtime.

Was this cheat sheet helpful?

Explore Topics

#Ada#AdaCheatSheet#Programming#Intermediate#HelloWorld#TypesVariables#ControlFlow#Packages#ErrorHandling#CheatSheet#SkillVeris
Advertisement
Sri Hayavadhana Info-Tech

Professional Web Designing Services

  • Responsive Websites
  • E-commerce Solutions
  • SEO Friendly Design
  • Fast & Secure
  • Support & Maintenance
Get a Free Quote

Share this Cheat Sheet