1 3 char name10 Array name index Array

  • Slides: 64
Download presentation

1. 3 การเขยนคำสงรบขอมล ตวอยาง char name[10]; Array แบบไมม เชน name; index Array แบบม index

1. 3 การเขยนคำสงรบขอมล ตวอยาง char name[10]; Array แบบไมม เชน name; index Array แบบม index เชน name[5 ; [ main() }char position[10 ; [ int radius; scanf(“%s”, position; ( scanf(“%c”, &position[1; ([ scanf(“%d”, &radius; ( {

Try it ! Input : Department : Business Information System scanf(“%[a-z. A-Z]”, dep); Output

Try it ! Input : Department : Business Information System scanf(“%[a-z. A-Z]”, dep); Output : Department เพราะ input มเวนวรรค

Try it ! Input : Department : Business Information System 56 scanf(“%[0 -9 a-z.

Try it ! Input : Department : Business Information System 56 scanf(“%[0 -9 a-z. A-Z]”, dep); Output : Department

Try it ! Input : Department : Business Information System 56 scanf(“%[a-z. A-Z]%[0 -9]”,

Try it ! Input : Department : Business Information System 56 scanf(“%[a-z. A-Z]%[0 -9]”, dep); Output : Department

Try it ! Input : Department : Business Information System 56 scanf(“%[^0 -9]”, dep);

Try it ! Input : Department : Business Information System 56 scanf(“%[^0 -9]”, dep); Output : Department : Business Information System

Try it ! Input : Department : Business Information System 56 scanf(“%[^a-z]”, dep); Output

Try it ! Input : Department : Business Information System 56 scanf(“%[^a-z]”, dep); Output : D

1. 3 การเขยนคำสงรบขอมล ตวอยาง #include <stdio. h> void main() { float b, h, area

1. 3 การเขยนคำสงรบขอมล ตวอยาง #include <stdio. h> void main() { float b, h, area ; printf("Input Base : > "); scanf("%f", &b); printf("Input Height : > "); scanf("%f", &h); area = 0. 5*b*h ; printf("Area of triangle is %5. 2 f", area); } Input Base : > 12. 0 Input Height : > 6. 0 Area of triangle is 36. 00 Input Base : > 3. 2 Input Height : > 1. 2 Area of triangle is 1. 92

2. 2 การเขยนคำสงแสดง ผลขอมล #include <stdio. h> void main() { printf("Welcome to RMUTI ");

2. 2 การเขยนคำสงแสดง ผลขอมล #include <stdio. h> void main() { printf("Welcome to RMUTI "); printf("Department of Information System"); } ผลการทำงาน Welcome to RMUTI Department of Information System

2. 2 การเขยนคำสงแสดง ผลขอมล ตวอยาง #include <stdio. h> Backslash n ขนบรรทดใหม void main() {

2. 2 การเขยนคำสงแสดง ผลขอมล ตวอยาง #include <stdio. h> Backslash n ขนบรรทดใหม void main() { printf("Welcome to RMUTIn"); n printf("Department of Information System"); } ผลการทำงาน Welcome to RMUTI Department of Information System

การเขยนคำสงแสดง ผลขอมล รปแบบคำสง การแสดงผลโดยใช Format Code printf(“ขอความ format code”, variable list) int number =

การเขยนคำสงแสดง ผลขอมล รปแบบคำสง การแสดงผลโดยใช Format Code printf(“ขอความ format code”, variable list) int number = 50; printf(“my number is %d”, number); String Format Code my number is 50

2. 2 การเขยนคำสงแสดง รปแบบคำสง printf(“ขอความ Control Format Code”, variable ผลขอมล ตวอยาง list) my salary

2. 2 การเขยนคำสงแสดง รปแบบคำสง printf(“ขอความ Control Format Code”, variable ผลขอมล ตวอยาง list) my salary = 4750 th. B float salary, tax = 0. 05; salary = 50000 – (50000 * 0. 05); printf(“COMPANY n my salary = %f th. B”, salary); String Control String Format Code

2. 2 การเขยนคำสงแสดง รปแบบคำสง ผลขอมล ตวอยาง printf(“ขอความ Control Format Code”, var 1, var 2)

2. 2 การเขยนคำสงแสดง รปแบบคำสง ผลขอมล ตวอยาง printf(“ขอความ Control Format Code”, var 1, var 2) float salary, tax = 0. 05; tax = 0. 05 my salary = 4750. 000000 th. B salary = 50000 – (50000 * 0. 05); printf(“tax = %f my salary = %f th. B”, tax, salary);

2. 2 การเขยนคำสงแสดง รปแบบคำสง ผลขอมล ตวอยาง printf(“ขอความ Control Format Code”, value, var 1) float

2. 2 การเขยนคำสงแสดง รปแบบคำสง ผลขอมล ตวอยาง printf(“ขอความ Control Format Code”, value, var 1) float salary, tax = 0. 05; tax = 0. 05 my salary = 4750. 0000 th. B salary = 50000 – (50000 * 0. 05); printf(“tax = %f my salary = %f th. B”, 0. 05, salary);

2. 2 การเขยนคำสงแสดง รปแบบคำสง ผลขอมล printf(“ขอความ ตวอยาง Control Format Code”, String, var 1) float

2. 2 การเขยนคำสงแสดง รปแบบคำสง ผลขอมล printf(“ขอความ ตวอยาง Control Format Code”, String, var 1) float salary, tax = 0. 05; PATCHARA salary = 4750 th. B salary = 50000 – (50000 * 0. 05); printf(“%s salary = %f th. B”, “ PATCHARA”, salary);

Try it ! #include<stdio. h> void main(){ float num=10; printf("%f", num); } ����� 10.

Try it ! #include<stdio. h> void main(){ float num=10; printf("%f", num); } ����� 10. 000000

Try it ! #include<stdio. h> void main(){ float num=10; printf("%. 3 f", num); }

Try it ! #include<stdio. h> void main(){ float num=10; printf("%. 3 f", num); } ����� 10. 000

Try it ! #include<stdio. h> void main(){ float num=10; printf("%7. 3 f", num); }

Try it ! #include<stdio. h> void main(){ float num=10; printf("%7. 3 f", num); } ����� _10. 000

Try it ! #include<stdio. h> void main(){ char dep[5]="BIS"; printf("University: %s n Department: %s",

Try it ! #include<stdio. h> void main(){ char dep[5]="BIS"; printf("University: %s n Department: %s", "KKC. RMUTI", dep); } ����� University: KKC. RMUTI Department BIS

Try it ! #include<stdio. h> void main(){ char dep[5]="BIS"; int money; money = 258;

Try it ! #include<stdio. h> void main(){ char dep[5]="BIS"; int money; money = 258; printf("Department: %s money: %5 d", dep, money); } ����� Department BIS money _ _ 258

Try it ! #include<stdio. h> void main(){ char dep[5]="BIS"; int money; money = 258;

Try it ! #include<stdio. h> void main(){ char dep[5]="BIS"; int money; money = 258; printf("Department: %s money: %5 d", dep, money); } ����� Department BIS money _ _ 258