2 for 3 START int num num for
- Slides: 52
โปรแกรมสตรคณแม 2 | for (3) START int num; num for num (num=1; num<=12; num++) = 1 { num<=12 False True 2, num ("%4 d * %-2 d = %-3 dn", printf 2*num 2, num, 2*num); } num++ END 5
โปรแกรม 6. 1 สตร คณแม 2 | for (4) #include<stdio. h> int main() { int num; printf ("Multiplication tablen"); for (num=1; num<=12; num++) { printf ("%4 d * %-2 d = %-3 dn", 2, num, 2*num); } return 0; } 6
โปรแกรม 6. 1 สตร คณแม 2 | for (5) Multiplication table 2 * 1 = 2 2 * 2 = 4 2 * 3 = 6 2 * 4 = 8 2 * 5 = 10 2 * 6 = 12 2 * 7 = 14 2 * 8 = 16 2 * 9 = 18 2 * 10 = 20 2 * 11 = 22 2 * 12 = 24 7
โปรแกรม 6. 2 แสดงเลข 0. . 100 ใช while โปรแกรมแสดงเลข 0 - 100 #include<stdio. h> int main() { int count = 0; printf ("Show number from 0 to 100nn"); while (count<=100) { printf ("%d ", count); count++; } return 0; } 10
โปรแกรม 6. 3 แสดงเลขค 0. . 100 ใช while + if (3) โปรแกรมแสดงเลขคทอยระหวาง 0 - 100 #include<stdio. h> int main() { int count = 0; printf ("Show even number from 0 to 100nn"); while (count<=100) { if (count%2 == 0) printf ("%d ", count); count++; } return 0; } 13
ผงงานตวอยาง 1. 1 )แสดงเลข 0 – 100) ผงงานตวอยาง 1. 2 )แสดงเลขค 0 – 100) START count = 0 count<=100 False count<=100 True count%2==0 False True count++ False count END count++ END 14
โปรแกรมสตรคณแม 2 | for (3) START vowel=0, alphabet=0, count, letter int vowel=0, alphabet=0, count; char letter; False count<10 True count ++ letter ? ? ? for (count=0; count<10; count++) { letter = getche(); ? ? ? } 17
โปรแกรมสตรคณแม 2 | for True letter is vowel (4) letter = getche(); True vowel++ false alphabet++ if ((letter=='a')||(letter=='e')||(letter=='i') ||(letter=='o')||(letter=='u')) vowel++; else alphabet++; 18
โปรแกรมสตรคณแม 2 | for vowel alphabet (5) printf ("n***Result***n"); printf ("Vowel (a, e, i, o, u) = %dn", vowel); printf ("Other letter = %d", alphabet); END 19
โปรแกรมสตรคณแม 2 | for (6) START vowel=0, alphabet=0, count, letter count = 0 False count<10 True count ++ letter is vowel alphabet True vowel++ false alphabet++ END 20
โปรแกรม 6. 4 ตรวจสอบจำนวนสระ | for #include<stdio. h> #include<conio. h> int main() { int vowel=0, alphabet=0, count; char letter; for (count=0; count<10; count++) { printf ("n. Enter letter a-z : "); letter = getche(); if ((letter=='a')||(letter=='e')||(letter=='i') ||(letter=='o')||(letter=='u')) vowel++; else alphabet++; }//continue (7) 21
โปรแกรม 6. 4 ตรวจสอบจำนวนสระ printf return | for (8) ("n***Result***n"); ("Vowel (a, e, i, o, u) = %dn", vowel); ("Other letter = %d", alphabet); 0; } 22
โปรแกรมสตรคณแม 2 | forint START num, i, j, space=' ' num, i, j; space=' '; char (4) printf ("Enter number : "); scanf ("%d", &num); num i=1 i<=num False END True for (i=1; i<=num; i++) { Process of each row } i++ 26
โปรแกรมสตรคณแม 2 | for Process of each row "n" printf ("n"); (5) j=1 j<=num True Process of printing each character. False for (j=1; j<=num; j++) { Process of printing each character. } j++ 27
โปรแกรมสตรคณแม 2 | for Process of (6) printing each character. (i==1)|| (i==num)|| (j==1)|| (j==num) True '*' False ' ' if (i==1 || i==num || j==1 || j==num) printf ("*"); else printf ("%c", space); 28
โปรแกรม 6. 5 โปรแกรมแสดงผลรปสเหลยมกลวง (7) #include<stdio. h> int main() { int num, i, j; char space=' '; printf ("Enter number : "); scanf ("%d", &num); //continue 29
(4) START money, amount money True money (money > 20000) || (money%100!=0) False 2 34
2 A money/1000!=0 money/500!=0 False True (5) False True amount = money/1000 money = money%1000 amount = money/500 money = money%500 "1000฿" amount "500฿" amount X X A 3 35
(6) 3 money/100!=0 False True amount = money/100 money = money%100 "100฿" amount X END 36
โปรแกรม 6. 6 โปรแกรมต ATM (7) #include<stdio. h> int main() { int money, amount; printf ("Enter money : "); scanf ("%d", &money); while ((money > 20000) || (money%100!=0)) { printf ("Sorry, please enter money : "); scanf ("%d", &money); } //continue 37
โปรแกรม 6. 6 โปรแกรมต ATM (8) printf ("n. Total bank noten"); if (money/1000!=0) { amount = money/1000; money = money%1000; printf ("Banknote 1000 : %dn", amount); } if (money/500!=0) { amount = money/500; money = money%500; printf ("Banknote 500 : %dn", amount); } //continue 38
โปรแกรม 6. 6 โปรแกรมต ATM (9) if (money/100!=0) { amount = money/100; money = money%100; printf ("Banknote 100 : %dn", amount); } return 0; } 39
START (7) menu, money=0 m 1=0, m 2=0, m 3=0 menu == 1 False menu == 2 True money=money+150 m 1++ True money=money+50 m 2++ True money=money+25 m 3++ True money=money+10 m 4++ False menu == 3 False menu == 4 False m 1, m 2 m 3, m 4 True menu!=0 False money END 46
โปรแกรม 6. 7 โปรแกรมคำนวณคาอาหาร (8) #include<stdio. h> int main() { int menu, m 1=0, m 2=0, m 3=0, m 4=0, i; float money=0; printf ("Welcome to Restaurantn"); do { printf ("1. Pizza 150 Bn"); printf ("2. Hamburger 50 Bn"); printf ("3. Sandwich 25 Bn"); printf ("4. Water 10 Bn"); printf ("0. Calculate moneyn"); //continue 47
โปรแกรม 6. 7 โปรแกรมคำนวณคาอาหาร printf ("n. Select menu : "); scanf ("%d", &menu); for (i=0; i<34; i++) printf ("n"); if (menu==1) { money = money + 150; m 1++; } else if (menu==2) { money = money + 50; m 2++; } else if (menu==3) { money = money + 25; m 3++; } //continue (9) 48
โปรแกรม 6. 7 โปรแกรมคำนวณคาอาหาร else if (menu==4) { money = money + 10; m 4++; } printf ("nn. U have : n"); printf ("Pizza %d * 150 : printf ("Hamburger %d * 50 : printf ("Sandwich %d * 25 : printf ("Water %d * 10 : (10) %dn", m 1*150); %dn", m 2*50); %dn", m 3*25); %dnn", m 4*10); } while (menu!=0); printf ("n. Total payment = %. 2 fn", money); return 0; } 49
- Int sum(int a int n) int sum=0 i
- Int main int num 4
- Public int divide(int a int b)
- Int max(int x int y)
- Interface calculator public int add(int a int b)
- Public void drawsquare(int x, int y, int len)
- Int num;
- ++
- Num +1
- Int num
- Void func(int num)
- Int num
- Int num
- Num 2
- Int num
- Int num
- Int num
- Karttecken kraftledning
- Int factorial(int n)
- Int b
- Interface myinterface int foo(int x)
- Arduino const
- Mainint
- Int main(int argc, char** argv)
- Voidswap
- Void
- It's gotta start somewhere it's gotta start sometime
- Jump start triage algorithm
- Hur ser ett referat ut
- Bris för vuxna
- Smärtskolan kunskap för livet
- Rådet för byggkompetens
- Fimbrietratt
- Formel för lufttryck
- Kung som dog 1611
- Delegerande ledarstil
- Adressändring ideell förening
- Toppslätskivling effekt
- Borra hål för knoppar
- Lek med former i förskolan
- Mat för unga idrottare
- Teckenspråk minoritetsspråk argument
- Vilka tal pekar pilarna på
- Datorkunskap för nybörjare
- Elektronik för barn
- Ekologiskt fotavtryck
- Rita perspektiv
- Fspos vägledning för kontinuitetshantering
- Redogör för vad psykologi är
- Bamse för de yngsta
- Bästa kameran för astrofoto
- Etik och ledarskap etisk kod för chefer