if (条件式)
{ 文(statement)1 } else { 文(statement)2 } |
(実行例)
gcc ex5-1.c -o ex5-1
./ex5-1
Input two interger numbers: 9 -10
max no. = 9
上の例では、a>b 条件式で
> | greater |
>= | greater than or equal to |
< | less than |
<= | less than or equal to |
== | equal to(=が2つに注意) |
!= | no equal to |
if (条件式1)
{ 文1 } else if (条件式2) { 文2 } ......... else
|
(課題5−2)
整数を入力し、それが正なら「PLUS」、負なら「MINUS」、0なら「ZERO」を出力するプログラム作成し、実行しなさい。
余裕のある人へ
(課題5−4)
switch-case 文を自分で勉強し、それを使って、
西暦で年を入力すると干支を出力するプログラムを作成し、実行せよ。
(12個の分岐がある。)