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?

More than 3 years have passed since last update.

計算する

Posted at

#計算式
計算式を書くと計算できます。式が自動的に計算結果に置き換わります。

fn main(){
    let answer = ( 1 + 3 ) * 4 + 5 ;//( 1 + 3 ) * 4 + 5を計算してanswerという名前をつける。
    println!("answer = {}",answer);
}
//実行結果:answer = 21

演算子には優先順位があります。掛け算割り算のほうが足し算引き算より先に計算されます。
演算子の優先順位は このページ に書いてあります。
多すぎて訳が分かりませんが、よく使うものだけ覚えていればいいでしょう。それ以外はカッコで順番を明確にすれば間違いが減ります。

目次

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?