[ภาษาซี] การกําหนดค่าเริ่มต้นให้กับตัวแปร

4 Jan 2018,
Share: 

ในภาษาซี นอกจากประกาศตัวแปรขึ้นใช้งานแล้ว เรายังสามารถกําหนดค่าเริ่มต้นให้กับตัวแปรไปพร้อมกันได้ด้วย คือ

char str = 'a';
int number = 100;
double x = 1.59;

การกําหนดค่าให้กับกับแปรในภาษาซีอีกแบบนึงคือ ประกาศตัวแปรขึ้นมาก่อน แล้วจึงกําหนดค่าให้กับตัวแปร เช่น

int x;
char y;
double z;

x = 100;
y = 'a';
z = 1.48;

Copyright © 2019 - 2025 thiti.dev |  v1.58.0 |  Privacy policy | 

Build with ❤️ and Astro.

Github profile   Linkedin profile   Instagram   X profile   Nostr   Youtube channel   Telegram   Email contact   วงแหวนเว็บ