Presentation is loading. Please wait.

Presentation is loading. Please wait.

Chapter 2: C Fundamentals Dr. Ameer Ali. Overview C Character set Identifiers and Keywords Data Types Constants Variables and Arrays Declarations Expressions.

Similar presentations


Presentation on theme: "Chapter 2: C Fundamentals Dr. Ameer Ali. Overview C Character set Identifiers and Keywords Data Types Constants Variables and Arrays Declarations Expressions."— Presentation transcript:

1 Chapter 2: C Fundamentals Dr. Ameer Ali

2 Overview C Character set Identifiers and Keywords Data Types Constants Variables and Arrays Declarations Expressions Statements Symbolic constants

3 C Characters A-Z, a-z, 0-9 +, -, &, ^, $, #, @ etc.

4 Identifiers Variable: a name given to a value to access using program such as sum_1, x1, y1, etc. Identifiers are names that are given to various program elements such as variables, functions and arrays. Identifiers consists of letters and digits in any order except that the first character must be a letter. Both upper case and lower case letters are accepted, but not interchangeable. Such as: Sum and uSm are two different.

5 Identifiers _ can be used. Arbitrarily long, but some C implementation can use only 8 characters such as file name.

6 Keywords Some reserved words that have standard and predefined meaning in C is known as keywords. Can only use for their intended purpose, not for other use. The standard keywords are: autobreakcasecharconstdodoubleelse enumforfloatgotoifintlongshort signedsizeofstaticstructswitchunionvoidwhile

7 Data Types Data Types DescriptionMemory (Byte) int long int Integer2 or 1 4 charSingle character1 floatFloating point4 doubleDouble precision floating point8

8 Data Types Int: short, long, signed, unsigned integer Ordinary integer int can carry only -32,768 to +32767, while unsigned int can 0 to 65535 Char: One character 0 to 255 signed char can -128 to +127 Double, float can carry large values

9 Constants Four types of basic constants: Integers constant Floating point constant Character constants String constants Integer and floating-point constants are known as numeric constant and can be applied following rules Comma’s and blank spaces can not be included

10 Constants Constants can be preceded by – operator Value can not exceed minimum and maximum values

11 Integer Constants Is an integer valued numbers Consist of sequence of digits Can be written in three different format: Decimal Octal Hexa decimal Example: D-19278, O-12356, H-987ABC

12 Floating Point Constants 5.04736 5.036E-17=5.036*10 -17 3.45E5=3.45*10 5

13 Character Constants ASCII: American Standard Code for Information Interchange

14 Character Constants

15 EBCDIC: extended binary coded decimal interchange code

16 Escape Sequences \ and ‘ can be expressed as escape sequence Line feed (LF): \n Others \t horizontal tab\v vertical tab \aalert\0 null \bbackspace

17 String Constants “abcdefgh”

18 Variables and Arrays Variables: used to represent some specific type of information within designated portion of the program A, b, c, abh, xyz. A=3; b=5; Array: is an identifier that refers to a collection of data items that all have the same name.

19 Array 123195016751899 1 2 3 4 5 679 Index Value

20 Declarations Type Name; Int a; Float b; Char c; Double d; Type Name [Size] Int A[100]

21 Expression

22 Statements


Download ppt "Chapter 2: C Fundamentals Dr. Ameer Ali. Overview C Character set Identifiers and Keywords Data Types Constants Variables and Arrays Declarations Expressions."

Similar presentations


Ads by Google