I want to thank you and congratulate you for downloading the book , Professional C Programming Made Easy: Expert C Programming Language Success In A Day For Any Computer User! . This book contains proven steps and strategies on how to understand and perform C programming.
C is one of the most basic programming tools used for a wide array of applications. Most people stay away from it because the language seem complicated, with all those characters, letters, sequences and special symbols. This book will break down every element and explain in detail each language used in the C program. By the time you are done with this book, C programming language will be easy to understand and easy to execute. Read on and learn. Thanks again for downloading this book.
Chapter 1 The Basic Elements Of C
The seemingly complicated C program is composed of the following basic elements: Character Set The alphabet in both upper and lower cases is used in C. The 0-9 digits are also used, including white spaces and some special characters. These are used in different combinations to form elements of a basic C program such as expressions, constants, variables, etc. Special characters include the following: + ,. * / % = & ! #?^ | / ( )< > { } [ ] ;: @ ~! White spaces include:
- Blank space
- Carriage return
- Horizontal tab
- Form feed
- New line
Identifiers An identifier is a name given to the various elements of the C program, such as arrays, variables and functions. These contain digits and letters in various arrangements.
However, identifiers should always start with a letter. The letters may be in upper case, lower case or both. However, these are not interchangeable. C programming is case sensitive, as each letter in different cases is regarded as separate from each other. Underscores are also permitted because it is considered by the program as a kind of letter. Examples of valid identifiers include the following: ab123 A stud_name average velocity TOTAL Identifiers need to start with a letter and should not contain illegal characters.
Examples of invalid identifiers include the following: 2nd - should always start with a letter Jamshedpur - contains the illegal character () stud name - contains a blank space, which is an illegal character stud-name - contains an illegal character (-) In C, a single identifier may be used to refer to a number of different entities within the same C program. For instance, an array and a variable can share one identifier. For example: The variable i s int difference, average, A[5]; // sum, average The identifier i s A[5 ] . In the same program, an array can be named A , too. __func_ _ Th e __func_ _ is a predefined identifier that provides functions names and makes these accessible and ready for use anytime in the function. The complier would automatically declareth e __func_ _ immediately after placing the opening brace when declaring the function definitions.
The compiler declares the predefined identifier this way: static const char _ _func_ _[] = Alex; Alex refers to a specific name of this particular function. Take a look at this example: #include void anna1(void) { printf("%sn",__func__); return; } int main() { myfunc(); } What will appear as an output will be anna1 Keywords Reserved words in C that come with standard and predefined meanings are called keywords. The uses for these words are restricted to their predefined intended purpose. Keywords cannot be utilized as programmer-defined identifiers. In C, there are 32 keywords being used, which include the following: auto break char case continue const do default double float else extern enum goto for if long int register short return sizeof signed switch typedef struct union switch void unsigned while volatile Data Types There are different types of data values that are passed in C. Each of the types of data has different representations within the memory bank of the computer.
These also have varying memory requirements. Data type modifiers/qualifiers are often used to augment the different types of data. Supported data types in C include int, char, float, double, void, _Bool, _Complex, arrays, and constants. int Integer quantities are stored in this type of data. The data type int can store a collection of different values, starting from INT_MAX to INT_MIN. An in-header file, , defines the range.
These int data types use type modifiers such as unsigned, signed, long, long long and short. Short int means that they occupy memory space of only 2 bytes. A long int uses 4 bytes of memory space. Short unsigned int is a data type that uses 2 bytes of memory space and store positive values only, ranging from 0 to 65535. Unsigned int requires memory space similar to that of short unsigned int. For regular and ordinary int, the bit at the leftmost portion is used for the integers sign.
Long unsigned int uses 4 bytes of space. It stores all positive integers ranging from 0 to 4294967295. An int data is automatically considered as signed. Long long int data type uses 64 bits memory. This type may either be unsigned or signed. Signed long long data type can store values ranging from 9,223,372,036,854,775,808 to 9,223,372,036,854,775,807.
Unsigned long long data type stores value range of 0 to 18,446,744,073,709,551,615. char Single characters such as those found in C programs character set are stored by this type of data. The char data type uses 1 byte in the computers memory. Any value from C programs character set can be stored as char. Modifiers that can be usedare eithe r unsigne d o r signe d . A char would always use 1 byte in the computers memory space, whether it is signed or unsigned.
The difference is on the value range. Values that can be stored as unsigned char range from 0 to 255. Signed char stores values ranging from 128 to +127. By default, a char data type is considered unsigned. For each of the char types, there is a corresponding integer interpretation. float A float is a data type used in storing real numbers that have single precision. float A float is a data type used in storing real numbers that have single precision.
That is, precision denoted as having 6 more digits after a decimal point. Float data type uses 4 bytes memory space. The modifier for this data type i s lon g , which uses the same memory space as that of double data type. double The double data type is used for storing real numbers that have double precision. Memory space used is 8 bytes. Double data type use s lon g as a type modifier.
This uses up memory storage space of 10 bytes. void Void data type is used for specifying empty sets, which do not contain any value. Hence, void data type also occupies no space (0 bytes) in the memory storage. _ Bool This is a Boolean type of data. It is an unsigned type of integer. It stores only 2 values, which is 0 and 1.
When using _Bool, include < stdboolh > . _ Complex This is used for storing complex numbers. In C, three types of _Complex are used. There is th e float _Comple x , double _Comple x , an d long double _Comple x . These are found in file. Arrays This identifier is used in referring to the collection of data that share the same name and of the same type of data.