0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

計算機実習Ⅰ:データの型

Posted at

新しくプログラミング言語を習得するには、実際に書いてみることが最も効率的。
プログラムの解説は最低限に抑えて、①手を動かしながら、②出力結果を見ながら、習得する方針で作成している。

型宣言

variables.f90
program variables
  implicit none

  integer :: code
  real :: airtemp
  character(len=20) :: name

  code = 21
  airtemp = 298.15
  name = "It's rainy"

  print *, 'Code:', code
  print *, 'Air Temperature:', airtemp
  print *, 'Name: ', name

end program variables
  • implicit none
    全ての変数の型を明示的に宣言するようFortranに指示している。
  • integer :: code
    codeという名前の整数型変数を宣言している。
  • real :: airtemp
    airtempという名前の実数型変数を宣言している。
  • characetr(len=20) :: name
    nameという名前の文字型変数を宣言している。len=20は、この変数が最大20文字の長さを持つことを指定している。

組み込みデータ型の種類

強い型付け言語であり、静的型付け言語であるFortranは以下の5つの組み込みデータ型がある。型付け(typing)については「7つの言語 7つの世界」に詳しく書かれている。

組み込みデータ型 説明
整数型(integer) 正または負の整数
実数型(real) 浮動小数点
複素数型(complex) 実部と虚部からなるなる値
文字型(character) テキストデータ
論理型(logical) 真(.true.)または偽(.false.)のブール値

算術演算

算術演算子

また今度

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?