LoginSignup
0
0

More than 5 years have passed since last update.

Ada言語 11日目 while文

Last updated at Posted at 2018-12-24

はじめに

while文をやりました。
インクリメントを使用したかったのですが、C言語でいうところのa=a+1で実現しました。

ソースと結果

main.adb

with Ada.Text_IO;
with Ada.Integer_Text_IO;
use Ada.Text_IO;
use Ada.Integer_Text_IO;

procedure main is

    hennsuu : Integer := 1;

begin

    while hennsuu < 10 loop -- hennsuu <= 9 と同じ

        Ada.Integer_Text_IO.Put(hennsuu, 1);

        hennsuu := hennsuu + 1;

    end loop;

end main;

実行結果 : 123456789

ちなみに、C言語のwhile(1)をやろうとしてwhile 1 loopとしたところ、以下のようなエラーが出ました。
expected a boolean type
found type universal integer
で、インクリメントの部分を消して、while hennsuu = 1 loopで無限ループを試したところ、無限ループにはなったのですが、無限ループだよというワーニングが出ました。
variable "hennsuu" is not modified in loop body
possible infinite loop

最後に

基本的な文法はある程度できてきたのでそろそろキーボード入力なんてやってみたいですね。

日記一覧へ

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