MIS 24053 Lecture Notes - Lecture 3: Exchange Rate, David Lubar
Document Summary
#include directives int main(){ declarations declarations statements constant variable executable return 0; Constants and variables must be declared before they can be used. A constant declaration specifies the type, the name and the value of the constant. A variable declaration specifies the type, the name and possibly the initial value of the variable. For more on declarations, see www. courseware. ust. hk and choose english--> c++ --> declarations. Constants are used to store values that never change during the program execution. Using constants makes programs more readable and maintainable. const double us2hk = 7. 8; //exchange rate of us$ to tw$ const double us2tw = us2hk * hk2tw; const double hk2tw = 3. 98; Variables are used to store values that can be changed during the program execution. A variable is best thought of as a container for a value. Examples: int sum; int total = 3445; char answer = "y"; double temperature = -3. 14;