ตัวอย่างโค้ดโปรแกรมภาษาซีวนรับค่าตัวเลขทศนิยม จำนวน 5 ค่า จากคีย์บอร์ด แล้วเก็บค่าที่รับเข้ามาไว้ในตัวแปรที่เหมาะสม จากนั้นคำนวณหาผลรวมของตัวเลขทศนิยมทั้งหมดที่ป้อนเข้ามา แล้วนำค่าที่ป้อนเข้ามาทุกค่า และผลรวมแสดงออกจอภาพ
ตัวอย่าง Flowchart

ตัวอย่างโค้ด
/***************************************************
* Author : CS Developers
* Author URI: https://www.comscidev.com
* Facebook : https://www.facebook.com/CSDevelopers
***************************************************/
#include <stdio.h>
int main()
{
//step 1
float input[5];
float sum;
int i = 0;
//step 2
do{
printf("Enter float number : ");
scanf("%f", &input[i]);
i++;
}while(i<5);
printf("\n\n");
//step 3
for(i=0; i<5; i++){
printf("output : %.2f \n", input[i]);
sum += input[i];
}
//step 4
printf("\nSum total is %.2f \n\n", sum);
return 0;
}
คำอธิบาย
Step 1 คือ การประกาศตัวแปรที่เหมาะสมเอาไว้รับค่าที่ป้อนเข้ามา
Step 2 คือ วนรับค่าที่ป้อนเข้ามาจำนวน 5 รอบ
Step 3 คือ วนแสดงค่าที่เก็บไว้ในตัวแปร และ วนหาผลรวมทั้งหมด
Step 4 คือ แสดงค่าผลรวมที่ได้
ผลลัพธ์
