- คอมเมนต์ : คอมเมนต์มีไว้สำหรับโปรแกรมเมอร์. เวลาโปรแกรมทำการคอมไพร์ ช่องไฟ และคอมเมนต์จะถูกตัดออก ดึงนั้น คอมเมนต์ไม่มีผลอะไรต่อโปรแกรมทั้งนั้น. เช่นโปรแกรมที่มีคอมเมต์มากๆ ก็เร็วเท่ากับโปรแกรมที่ไม่มีคอมเมนต์เลย แต่อย่างไรก็ตามคอมเมนต์ก็จะทำให้ซอสโค๊ดใหญ่ขึ้น (ซึ่งไม่ได้มีความสำคัญเท่าไหร่) . โปรแกรมที่มีคอมเมนต์จะทำให้อ่านโค๊ดแล้วเข้าใจง่าย
- บล๊อก กับ สเตทเมนต์ ( Block and Statement ) : บล๊อกคือเครืองหมายปีกกาเปิด-ปิด ภายในบล๊อกอาจจะว่างเปล่าหรือมีกี่สเตทเมนต์ก็ได้
ภาษาซีมีฟังก์ชั่น 2 ชนิดคือ
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
int product(int a ,int b); | |
int main(void) | |
{ | |
setbuf(stdout,NULL); | |
int first , second , result; | |
/* Get the first number*/ | |
printf("Enter first number : "); | |
scanf("%d",&first); | |
// Get the second number | |
printf("Enter second number : "); | |
scanf("%d",&second); | |
// Calculate and display the product. | |
result = product(first,second); | |
printf("%d time %d = %d\n",first,second,result); | |
{ | |
// int first , second , result; | |
// first = 3; | |
// second = 9; | |
// result = first * second; | |
printf("%d time %d = %d\n",first,second,result); | |
} | |
return 0; | |
} | |
int product(int a, int b) | |
{ | |
return a * b; | |
} |