วันอาทิตย์, มิถุนายน 1, 2025
Latest:
วิชาการเขียนโปรแกรมด้วยภาษาซี (c)

คำสั่ง if else ภาษาซี c programming

คำสั่ง if จากบทความที่ผ่านมา สามารถทำงานได้เพียงแค่ทางเดียว และกรณีที่มีค่าความจริงเป็นจริงเท่านั้น จึงมีการสร้างคำสั่งที่สามารถมีทางเลือกให้ทำงานได้ 2 ทางคือ เป็นจริง และเป็นเท็จ เป็นคำสั่งที่นิยมใช้ในการสร้างโปรแกรมมาก ๆ เนื่องจากสามารถเลือกกระทำได้ 2 ทาง

ตัวอย่างคำสั่ง if else ภาษาซี (c)

#include <stdio.h>
main()
{
int a =20;
int b =30;
if (a>b){
	printf("a>b");
	}
	else{
	printf("a<b");
	}
}

ผลลัพธ์ที่ได้

a<b

slot gacor hari ini slot qris slot gacor maxwin slot online slot gacor gampang menang slot gacor hari ini slot online slot slot slot guci777 wortel21 guci777 guci777 wortel21 wortel21 wortel21