Keywords
Keywords serve as the building blocks for program statements. All keywords have fixed meanings and these meanings cannot be changed. All keywords must be written in lower case. Example break else long switch void
Identifiers
Identifiers refer to the names of variables, functions and arrays. Thses are user-defined names and consist of a sequence of letters and digits, with a letter as a first character. Both uppercase and lowercase letters are permitted, although lowercase letters are commonly used.
Rules for Identifiers
1. First Character must be an alphabet(or underscore)
2.Must consist of only letters, digits or underscore.
3.Only first 31 character are significant.
4.Cannot use a keyword
5.Must not contain white space.
Constants
Constants in C refer to fixed values that do not change during the execution of a Program.
Types of Constants
Integer Constants refers to sequence of digits
Real Constants referes to number containing fractional parts like 17.548
String Character Constants contains a single character en-closed within a pait of single quote marks.
String Constants is a sequence of characters enclosed in double quotes.
Backslash Character Constants Escape Sequence
\a----audible alert
\b backspace
\f form feed
\n new line
\r carriage return
\\ backshash
\0 null
Variable
A variable is a data name that may be used to store a data value. Unlike constants that remain unchanged during the execution of a program, a variable may take different values at different time during execution.
Points to be noted while having variable
1. They mush begin with a letter. Some system permits underscore as a first character
2. A length of only 31 character are recognize by ANSI standared
3.Uppercase and Lowercase are significant
4.It should not be a keyword
5.White Space is not allowed
Data Types
Integer Types
Integers are whole numbers with a machine dependent range of values. C has three classes of integer storage namely short int, int and long int. All of this data types have signed and unsigned form
Floating Point types
Floating point number represents a real number with 6 digits precision. Floating point numbers are denoted by the key word float. When the accuracy of float is insufficient we can use the double to define the number. The double is same as float but with longer precision.
Void Type
Using void data type we can specify the data we can specify the type of function. It is a good practice to avoid functions that doesnot return any value to the calling function.
Character Type
A single character can be defined as a character type of data. Characters are usually stored in 8 bits of internal storage
No comments:
Post a Comment