ˆ F printf( ) scanf( )
printf ( )
printf( F F, F F, F F,...)
F F ˈ F
F F
F F ˈ F F F
F F
14
F F ˆ F printf
%d F F
%o
%x
%u F%u F
%e F F 2.13e45
%f
%g %e %f
F
%c F F
%s F
15
F
F F F F
( F F )
F ʽ FF ʽ F
ˈ F
Note F F F
F F %
F
16
scanf ( )
scanf( F F , F F, F F,...)
F F ˈ F
F F ˈ F F ( ) F FF F ˈ F F ( ) F F
F F
F F F 2
F F F
- F & F
F F ˈ F F
- F ˈ F F & F
17
F printf, scanf
#include <stdio.h>
main(){
int age;
float height;
char name[30];char name[30];
printf("Please enter your name, age and height: ");
scanf("%s%d%f",&name, &age, &height);
printf("Name: %s is %d years old",name,age);
printf(" and tall %f cms.n",height);
getch();
}
18

ฟังก์ชัน Printf&scanf

  • 1.
    ˆ F printf() scanf( ) printf ( ) printf( F F, F F, F F,...) F F ˈ F F F F F ˈ F F F F F 14
  • 2.
    F F ˆF printf %d F F %o %x %u F%u F %e F F 2.13e45 %f %g %e %f F %c F F %s F 15
  • 3.
    F F F FF ( F F ) F ʽ FF ʽ F ˈ F Note F F F F F % F 16
  • 4.
    scanf ( ) scanf(F F , F F, F F,...) F F ˈ F F F ˈ F F ( ) F FF F ˈ F F ( ) F F F F F F F 2 F F F - F & F F F ˈ F F - F ˈ F F & F 17
  • 5.
    F printf, scanf #include<stdio.h> main(){ int age; float height; char name[30];char name[30]; printf("Please enter your name, age and height: "); scanf("%s%d%f",&name, &age, &height); printf("Name: %s is %d years old",name,age); printf(" and tall %f cms.n",height); getch(); } 18