12/20 c언어 배열
C
#include <stdio.h>
int main() {
//배열이 필요한 이유
int class1=30;
int class2=29;
int class3=28;
printf("1반에는 %d명 다니고 있습니다.\n",class1);
printf("2반에는 %d명 다니고 있습니다.\n",class2);
printf("3반에는 %d명 다니고 있습니다.\n",class3);
//배열 선언하기
// int class[3];
// class[0];
// class[1];
// class[2];
//배열 선언과 초기화하기
int class[10] = {1,2,3,4,5,6,7,8,9,10};
for(int i=0;i<10;i++){
printf("%d반에는 %d명 다니고 있습니다.\n", i+1, class[i]);
}
}
Output
Embed on website
To embed this program on your website, copy the following code and paste it into your website's HTML:
Comments
This comment belongs to a banned user and is only visible to admins.
This comment belongs to a deleted user and is only visible to admins.