"C' is one of the most popular programming language, it was developed by Dennis Ritchie at AT & T's Bell Laboratories at USA in 1972. It is an upgraded version of two earlier languages, called BCPL and B, which were also developed at Bell laboratories.
C stands in between both high level language and low level language categories. It is neither a low level language nor a high level language. It is a middle level language. It means it performs the task of low level language as well as high level language. We can write the codes for Operating system, Application programs, and Assembly language programs in 'C' language. UNIX Operating System is written in 'C' language.
Structure of c program
A 'C' program may contain one or more sections given below.
Documentation section : It consists a set of comment lines used to specify the name of program, the author and other details etc.,
- Comments : Comments are very helpful in identifying the program features and underlaying logic of the program. The lines begins with '/*' and ending with '*/' are known as comment lines. These are not executable, the compiler is ignored anything in between /* and */.
- Preprocessor section : It is used to link system library files, for defining the macros and for defining the conditional inclusion. Eg : #include<stdio.h>, #define A 10, #if def, #endif... etc.
- Global Declaration Section : The variables that are used in more than one function throughout the program are called global variables and declared outside of all the function i.e., before main().
- Declaration part : This part is used to declare all the variables that are used in the executable part of the program and these are called local variables.
- Executable part : It contains atleast one valid 'C' statement. The execution of a program begins with opening brace '{' and ends with closing brace '}'. The closing brace of the main function is the logical end of the program.
Documentation section
Preprocessor section
Definition section
Global declaration section
main()
{
Declaration part;
Executable part;
}
sub program section
{
Body of the subprogram;
}
Comments in C
Comments : Comments are very helpful in identifying the program features and underlaying logic of the program. The lines begins with '/*' and ending with '*/' are known as comment lines. These are not executable, the compiler is ignored any thing in between /* and */.
Include & Define Structure
Preprocessor section : It is used to link system library files, for defining the macros and for defining the conditional inclusion.
Eg : #include<stdio.h>, #define A 10, #if def, #endif... etc.
The Main() Function
Declaration part : This part is used to declare all the variables that are used in the executable part of the program and these are called local variables.
Executable part : It contains atleast one valid 'C' statement. The execution of a program begins with opening brace '{' and ends with closing brace '}'. The closing brace of the main function is the logical end of the program.
Data types in C
Data type is the type of the data, that are going to access within the program. 'C' supports different data types, each data type may have predefined memory requirement and storage representation.
'C' supports the following 4 classes of data types
“C' Data Types
Primary Userdefined Derived Empty
char arrays
int typedef pointer void
float structures
double union
Constants in C
The item whose values cannot be changed during the execution of program are called constants.
C Constants (1) Numeric constant : (i) Integer constants (ii) Real constant
(2) Character constant : (i) Single Character constant (ii) string constant
Using Format Strings
String Constants : A string constant is a sequence of characters enclosed in double quotes, the characters may be letters, numbers, special characters and blank spaces etc. At the end of string '\0' is automatically placed.
Example : "HI"
"Muni"
"39.77"
"50"
excellent
ReplyDelete