2 for 3 START int num num for

  • Slides: 33
Download presentation

โปรแกรมสตรคณแม 2 | for (3) START int num; num for num (num=1; num<=12; num++)

โปรแกรมสตรคณแม 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() {

โปรแกรม 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

โปรแกรม 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.

โปรแกรม 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

โปรแกรม 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)

ผงงานตวอยาง 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 int vowel=0, alphabet=0, count; char letter; vowel=0, alphabet=0,

โปรแกรมสตรคณแม 2 | for (3) START int vowel=0, alphabet=0, count; char letter; vowel=0, alphabet=0, count, letter count = 0 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++

โปรแกรมสตรคณแม 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,

โปรแกรมสตรคณแม 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

โปรแกรมสตรคณแม 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

โปรแกรม 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,

โปรแกรม 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='

โปรแกรมสตรคณแม 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

โปรแกรมสตรคณแม 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)

โปรแกรมสตรคณแม 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;

โปรแกรม 6. 5 โปรแกรมแสดงผลรปสเหลยมกลวง (7) #include<stdio. h> int main() { int num, i, j; char space=' '; printf ("Enter number : "); scanf ("%d", &num); //continue 29