#include <stdlib.h> void exit(int status) status : 終了状態
#include <stdio.h> #include <stdlib.h> int main() { int i1; long x[5], y[5]; for (i1 = 0; i1 < 5; i1++) x[i1] = 10 * i1; for (i1 = 0; i1 < 5; i1++) y[i1] = 3 - i1; for (i1 = 0; i1 < 5; i1++) { if (y[i1] != 0) printf("answer = %ld\n", x[i1]/y[i1]); else { printf("***error 0で割る!\n"); exit(1); } } return 0; }
answer = 0 answer = 5 answer = 20 ***error 0で割る!
菅沼ホーム | 本文目次 | 演習問題解答例 | 付録目次 | 索引 |