Computer Fundamental
วันอาทิตย์ที่ 13 กันยายน พ.ศ. 2558
Lab 4 : Calculate sum of integers from 1 to N
void setup() {
int n=50;
println("Sum = "+number(n));
}
int number(int n) {
int x = 1;
int sum = 0;
while (x <= n) {
sum = sum+x;
x++;
}
return sum;
}
ไม่มีความคิดเห็น:
แสดงความคิดเห็น
บทความใหม่กว่า
บทความที่เก่ากว่า
หน้าแรก
สมัครสมาชิก:
ส่งความคิดเห็น (Atom)
ไม่มีความคิดเห็น:
แสดงความคิดเห็น