Writing (6 ข้อ)
- ให้โค็ด for loop มาแล้วดูว่า output จะเป็นอะไร, ตัวอย่าง.
- เขียนโปรแกรมเกี่ยวกับธนาคาร (ยาก), ตัวอย่าง.
- เลือกเมนู ฝาก ถอน
Choices (35 ข้อ)
- ฐาน 2, 8, 10, 16 (ฐาน 8 ไม่ออก) (2 หลัก)
บท 1
- ถามหน่วย
- ประเภท Software
- ภาษาระดับใดเป็นไง
- SDLC ขั้นตอน
- Input / Output / Process
- Flowchart
- Type of Error
บท 2
- ขั้นตอน Compiler
- Global vs Local
scanf,printf- Keywords คำสงวน
- กฏการประกาศตัวแปร
- size ตัวแปร (เรียง!) (อย่าไปจำ มันขึ้นอยู่กับ Compiler)
char<short<int<float<long<double<long long<long doubleunsignedis same sizesigned
- printf % ต่างๆ
- scanf &
getchar,getch, ... อะไรแบบนี้ต่างกันไงgetchar: ขึ้น, Enter (1 ตัว)getch: ไม่ขึ้น, ไม่ Enter (1 ตัว) (#include <conio.h>)getche: ขึ้น, ไม่ Enter (1 ตัว) (#include <conio.h>)gets: ขึ้น, Enter (String)putchar: Put (1 ตัว)puts: Put (String)
บท 3
- ระดับของ Arithmatics operator (a++, ++a, +-*/, +=, %, ...) (เรียง!)
- ระดับของ Logic Operator
==,!=,!,&&,||
- Casting (จารย์ไม่เห็น)
- Shift bit
บท 4
if,forออกเยอะgotoไม่ออก- switch <-> if else
บท 5
- for, do while, while ออกเยอะ (มี psudoode)
- มี Code ถาม Output
บท 6
- Array สูงสุด 2 มิติ
- มี for มี Array ถาม Output
- String
ตัวอย่าง Writing
int A[10] = {1, 2, 3, ...};
for (i = 0; i < 10; i++) {
printf(A[i / 2]);
// 0 / 2 = 0
// 1 / 2 = 0
// 2 / 2 = 1
// 3 / 2 = 1
// 4 / 2 = 2
// ...
}// FROM
int b = 0, n = 0;
switch(b) {
case 0:
n = 1;
break;
case 1:
n = 2;
break;
default:
n = 0
break;
}
// TO
if(b == 0) {
n = 1;
} else if(b == 1) {
n = 2;
} else {
n = 0;
}// FROM
int b = 0, n = 0;
switch(b) {
case 0:
n = 1;
case 1:
n = 2;
break;
default:
n = 0
break;
}
// TO
if(b == 0) {
n = 1;
n = 2;
} else if(b == 1) {
n = 2;
} else {
n = 0;
}Banking ver. ต้นแก้ว
#include <stdio.h>
float amount = 1000;
int main()
{
int mode = 0;
float _x = 0;
while (1 == 1)
{
printf("mode? (1. Deposit, 2. Withdraw, 3. Balance): ");
scanf("%d", &mode);
switch (mode)
{
case 1:
printf("How much would you like to deposit?: ");
scanf("%f", &_x);
amount += _x;
printf("You have $%.2f\n", amount);
break;
case 2:
printf("How much would you like to withdraw?: ");
scanf("%f", &_x);
amount -= _x;
if (amount < 0)
{
printf("You don't have enough money D:\n");
amount += _x;
break;
}
printf("You have $%.2f\n", amount);
break;
case 3:
printf("You have $%.2f\n", amount);
break;
}
}
return 0;
}Back to cscourse