LoginSignup
0
0

More than 5 years have passed since last update.

Ada言語 6日目 if文

Last updated at Posted at 2018-12-18

はじめに

変数についてもっとやってからやろうと思ったのですが、やっぱり制御文がやりたくなってしまったので今日は条件文をやりました。

ソースと結果

main.adb

with Ada.Text_IO;
use Ada.Text_IO;

procedure main is

    hennsuu1 : Integer := 0;

begin

    if hennsuu1 = 1 then
        Ada.Text_IO.Put_Line("hennsuu1 = 1");
    elsif hennsuu1 = 2 then
        Ada.Text_IO.Put_Line("hennsuu1 = 2");
    else
        Ada.Text_IO.Put_Line("hennsuu1 = other");
    end if;

end main;

実行結果 : hennsuu1が1のとき "hennsuu1 = 1"
実行結果 : hennsuu1が2のとき "hennsuu1 = 2"
実行結果 : hennsuu1が1でも2でもないとき "hennsuu1 = other"

最後に

Ada言語では、C言語とは異なり、評価はイコール一つ(=)で記述するようです。
イコール二つ(==)にすると、== shuld be =と、エラーが出ます。

日記一覧へ

Ada言語を習得する日記一覧

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0