--------------------------------------------------------------------------------
1. Fixed number is constant, directly written in the program called Direct volume (literal).
int total = 100-price;
#include <stdio.sh>int main () { int0; Initialize printf (" Please enter amount:"); scanf ("%d", &price); // Take Care not to forget to take the address symbol int -Price ; printf (" Find you%d Yuan ", change); }
2. We do not know what the above 100 is, and to make it easier for us to identify it, a constant is used here.
The const modifier multibyte is used before int to denote constants, attributes defined with const, and cannot be modified once initialized (PHP5); If you modify the constants to assign values, the compiler will error (read-only variable is not assignable) and use uppercase for the constant conventions.
const int AMOUNT = 100;
int change = Amount-price;
Const int - ; int 0 ; printf (" Please enter amount:"); scanf ("%d", &price); int change = AMOUNT-Price ; printf (" find you%d dollars "
3. If you do not want to define constants now, use multiple scanf
intamount; Not initializedintPrice;
/*
printf ("Please enter two integers:");
scanf ("%d%d", &amount, &price); Two numbers are separated by a space or carriage return; Note: When you encounter a non-numeric input such as a string, scanf will make an error, whatever is in memory
printf ("%d +%d =%d", amount, price, amount + price);
*/
Prinf ("Please enter the coupon:"); scanf ("%d", &amount);p rintf ("Please enter the amount:"); scanf ("%d", &Price );intChange = Amount-price;printf ("find you%d dollars", change);
@ Black eyed poet <www.chenwei.ws>
[C language] variables vs constants