# Some Stuff on Programming ## Variables (變數) - Stores data associated with the defined variable name - EX: ```c= // 定義一個名為 "luckyNumber" 的變數(整數) int luckyNumber; // 設 luckyNumber 存的值為 5 luckyNumber = 5; // 顯示 luckyNumber 加一後的值,為整數 6 printf("%d", luckyNumber+1); ``` - Example usage: display user input ```c= int luckyNumber; // 把使用者的輸入的值存到名為 luckyNumber 的變數裡面 scanf("%d", &luckyNumber); // 顯示「你剛剛輸入的值是:%d」,在「%d」的部分顯示使用者剛剛輸入的值 printf("你剛剛輸入的值是:%d", luckyNumber); ``` ## Conditional statement - Kind of similar to 構成要件 - Concept is as follows: ```c= if (statement) { // Do something here } ``` - Example: ```c= int count = 3; // 如果變數 count 的值是等於(==)整數 3,執行括號內的程序 if (count == 3) { // 把 count 加一並存回於 count 裡 count = count + 1; } // count is now 4 ``` ## = 跟 == 的差別 - `=` 是設定值的(it's an assignment) - `==` 是比較用的(equal to?) ```c= // Assign the value of 2 to variable x int x = 2; // Checks if x is equal to 0 if (x == 0) { printf("x is equals to zero!"); } ```