Generation

generate functionMon, 24 Jul 2023

int 型配列 a[20] を宣言し, 1-100 までのすべての整数を順次チェックし, 5 の倍数の数字のみを配列 a に格納し, その結果 を表示するプログラムとその実行結果を書きなさい.

#include <stdio.h> int main(void) { int i, j = 0; int a[20]; for (i = 1; i <= 100; i++) { if (i % 5 == 0) { a[j] = i; j++; } } for (i = 0; i < 20; i++) { printf("%d ", a[i]); } printf("\n"); }

Questions about programming?Chat with your personal AI assistant