scanf includestdio h int main float point char

  • Slides: 24
Download presentation

ตวอยางการใชคำสง scanf #include<stdio. h> int main() { float point; char name[20]; printf ("Enter your

ตวอยางการใชคำสง scanf #include<stdio. h> int main() { float point; char name[20]; printf ("Enter your name : "); scanf ("%s", name); printf ("Enter your point : "); scanf ("%f", &point); return 0; } ����� �� ����� & ���������� � ������ & ����� 5

ตวอยางการใชคำสง printf และ scanf #include<stdio. h> int main() { char first[20], last[20]; printf ("Enter

ตวอยางการใชคำสง printf และ scanf #include<stdio. h> int main() { char first[20], last[20]; printf ("Enter your name and surname : "); ������� 1 scanf ("%s %s", first, last); ������ printf ("Hi %s %sn. How are you? ", first, last); ������� return 0; ������ } Enter your name and surname : Somsak Jaidee Hi Somsak Jaidee How are you? 6

ตวอยางการใชคำสง printf และ scanf #include<stdio. h> int main() { char name[40]; float gpa; printf

ตวอยางการใชคำสง printf และ scanf #include<stdio. h> int main() { char name[40]; float gpa; printf ("Enter your name : "); scanf ("%[^n]", name); printf ("Enter your GPA : "); scanf ("%f", &gpa); printf ("Name : %sn", name); printf ("Gpa : %f", gpa); return 0; } 8

4. 2. 3 ตวดำเนนการ Type 1 int Operator +, -, *, / & ตวถกดำเนนการ

4. 2. 3 ตวดำเนนการ Type 1 int Operator +, -, *, / & ตวถกดำเนนการ Type 2 int Result int +, -, *, / float +, -, *, / int float +, -, *, / float int % int Exam 3*3 9 19/2 9 3*3. 0 9. 000000 19/2. 0 9. 500000 3. 0*3 9. 000000 19. 0/2 9. 500000 3. 0*3. 0 9. 000000 19. 0/2. 0 9. 500000 7%4 3 8%4 0 13

ตวอยางคำสงแสดงผล และรบขอมล char ch 1, ch 2; printf ("Enter Character 1 : "); ch

ตวอยางคำสงแสดงผล และรบขอมล char ch 1, ch 2; printf ("Enter Character 1 : "); ch 1 = getchar(); printf ("Enter Character 2 : "); ch 2 = getch(); puts ("n**** Output ****"); printf ("Char 1 = %cn. Char 2 = %c", ch 1, ch 2); Enter Character 1 : J Enter Character 2 : **** Output **** Char 1 = J Char 2 = O ��������� �� 22

4. 4 คำถามทายบท 1. จากตวอยางโปรแกรมตอไปน #include <stdio. h> int main() { char name[20]; int

4. 4 คำถามทายบท 1. จากตวอยางโปรแกรมตอไปน #include <stdio. h> int main() { char name[20]; int age; printf("Enter your name: "); scanf("%s", name); printf("Enter your age "); scanf("%d", age); printf("Your name is : %sn", name); printf(" Your age is : %dn", age); return 0; } เมอ Run แลวจะไดผลอยางไร 23