TIPS!
การทำ Workshop ให้ได้ประสิทธิภาพ
ควรจะค่อยๆทำความเข้าใจกับโค้ด ลองคาดคะเนผลของโค้ดหลังจาก compile
อย่าลอง compile โดยที่ยังไม่ได้ทำความเข้าใจนะครับ หากไม่เข้าใจแนะนำให้ย้อนกลับไปศึกษาอีกครั้งครับ
#include‹stdio.h>
//Copyright Noppawit Lertutsahakul & Nut Jankittivorapong & Sira Simmee
main()
{
//Variable Declaration
int input[10];
int ova ,avg ,n;
printf("This program will calculate the sum of 10 number you input\n");
printf("\n");
printf("----------------------------------------------------------\n");
//Loop receiving value for variable input
for (n=0;n<=10;n++) {
printf("Input Your number : ");
scanf("%d",&input[n]);
}
ova = 0;
//Loop calculating overall sum
for (n=0;n<=10;n++) {
ova = ova + input[n];
}
//Loop calculating average sum
for (n=0;n<=10;n++) {
avg = ova/10;
}
system("cls");
//Print calculated value
printf("Your overall sum of your input is %d\n",ova);
printf("Your average sum of your input is %d\n",avg);
return 0;
//END
}
|