# include <stdio.h>int main (void ) { printf(“Hello, Good morning. \n”); } ตัวอย่างโปรแกรม โปรแกรมที่ 1 เป็นโปรแกรมสั่งพิมพ์ข้อความ Hello, Good morning.
9.
โปรแกรมที่ 2# include <stdio.h> main ( ) { float point; printf("\n\nPut your score in\n"); scanf("%f", &point); printf("Your score is %f point\n\n", point); } เป็นโปรแกรมรับคะแนนและเก็บค่าที่ตัวแปร point หลังจากนั้นสั่งให้มีการพิมพ์ คะแนน ออกมา
ตัวอย่างโปรแกรม # include<stdio.h> main ( ) { char newline; newline = ‘\n’; printf(“Hello, Good morning. %c”,newline); printf(“Hello, Good morning.\n”); }
17.
ข้อมูลและตัวแปรชนิดจำนวนเต็ม จำนวนเต็มในภาษาซีสามารถใช้แทนได้ 4 รูปแบบคือ int, short, long และ unsigned สำหรับการกำหนดตัวแปรแบบ unsigned คือจำนวนเต็มที่ไม่คิดเครื่องหมาย นั้นจะต้องใช้ควบคู่กับรูปแบบข้อมูลจำนวนเต็มชนิดอื่น ๆ คือ int หรือ short หรือ long ตัวอย่างเช่น unsigned int plusnum; unsigned long width; unsigned short absno; /* absolute number */
คำสั่งวนรอบแบบที่ตรวจสอบเงื่อนไขทีหลัง :do while รูปแบบ do statement; while ( นิพจน์เงื่อนไข ) ; เช่น num = 2; do { num++; printf(“Now no is %d\n”,num); } while (num == 10)