冯毅《程序设计基础c2014-c2.ppt

冯毅《程序设计基础c2014-c2

* A floating constant consists of an integer part, a decimal part, a fraction part, an e or E, an optionally signed integer exponent and an optional type suffix, one of f, F, l, or L. The integer and fraction parts both consist of a sequence of digits. Either the integer part, or the fraction part (not both) may be missing; either the decimal point or the e and the exponent (not both) may be missing. The type is determined by the suffix; F or f makes it float, L or l makes it long double, otherwise it is double. 08 bits 23 bits 101000…………….0 significand exponent 整数 . 小数 e 指数 * at execution time 美国信息交换标准码 American Standard Code for Information Interchange * a variable, is a location in storage Represent storage units in a program Used to store/retrieve data over life of program Type of variable determines what can be placed in the storage unit Assignment – process of placing a particular value in a variable Variables must be declared before they are assigned The value of a variable can change; A constant always has the same value Naming variables When a variable is declared it is given a name Good programming practices Choose a name that reflects the role of the variable in a program, e.g. Good: customer_name, ss_number; Bad : cn, ss; Don’t be afraid to have long names if it aids in readability Restrictions Name must begin with a letter; otherwise, can contain digits or any other characters. C is CASE SENSITIVE! Use 31 or fewer characters to aid in portability Variable names in C may only consist of letters, digits, and underscores and may not begin with a digit Variable names in C are case sensitive ANSI standard requires only 31 or fewer characters. Enhances portability to follow this rule Should be very descriptive In most cases, variables have no meaningful value at this stage. Memory is set aside for them, but they are not meaningful until assigned * Be careful to assign proper type – contract between declaration and assignments must be honored int x

文档评论(0)

1亿VIP精品文档

相关文档