บทที่ 6 1 ฟังก์ชัน printf scanf [slide]

2,204 views
2,093 views

Published on

Published in: Education, Technology, Business
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
2,204
On SlideShare
0
From Embeds
0
Number of Embeds
4
Actions
Shares
0
Downloads
67
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

บทที่ 6 1 ฟังก์ชัน printf scanf [slide]

  1. 1. กF Printf(); Printf(); Scanf(); Scanf(); ก ก กก
  2. 2. ก ก F printf F scanf F F ก F Fprintf scanf ก ก F F stdio.h กF FกF printf scanf F F #include<stdio.h>
  3. 3. กF printf() printf()printf() ก F 1. F ก printf( F ); F printf( Hello world ); 2. ก printf( ก , ); F F printf( My age is %dn , myAge);
  4. 4. กformat code %d ก (int, short, unsigned short, long, unsigned long %u ก ก (unsigned short, unsigned long %o ก ก %x ก ก ก %f ก (float, double, long double) %e ก ก E ( e) กก (float, double, long double) %c ก ก 1 (char) %s ก F (ก กก F 1 ) %p ก F (pointer)
  5. 5. Fmain(){ int i =12345; float x=350.875; printf( %dn ,i); printf( %fn ,x);}
  6. 6. F12345350.875000
  7. 7. กF scanf(); scanf();Scanf( ) ก F F ก F • กF F C ก ก scanf( ) • F ก keyboard F ก F F F (memory address ) ก ก F function scanf( ) F F F F (address) F F function scanf( )
  8. 8. ก F กF scanf(); scanf(); scanf( format string , &variable);1. format string Fก ก ก F2. &variable ( ก F F ก F ) F Fก F F&name
  9. 9. F ก F กF scanf(); scanf();F F Fint month ,year;scanf( %d %d , &month, &year); ก ก F Fint i;float x;scanf( %d %f ,&i,&x);
  10. 10. F#include<stdio.h>#include<conio.h>int main(){ int year; float salary; clrscr(); printf(“Insert year experience and salary : ”); scanf(“%d %f”,&year,&salary); printf(“You worked for %d years.n”,year); printf(“Your salary is %.2fn”,salary); return(0);}

×