History of C
C is a programming language, developed in 1972 by Dennis Ritchie at AT & T's Bell laboratories of USA.
C is Middle Level Language
C is Middle Level Language because it has features of high level language and assembly language.
C behaves like a high level language through functions, and it also supports low level language like assembly language.
C language access the memory using Pointer
So, C language is neither called High Level nor a Low level language but it is a Middle Level Language.
High Level Language:
Languages that is more user friendly, machine independent , easy to learn.
It requires compiler to translate code in machine language. for example fortron, pascal, cobol
It requires compiler to translate code in machine language. for example fortron, pascal, cobol
Low Level Language:
Language that is machine dependent and execute faster as code is directly accepted by the machine.
for example Assembly Language.
Structured Programming ( or Modular Programming)
C Programming language divides the large problem in to the smaller modules(parts) called functions or procedures.Each function handles the particular task(solution) and the collection of all the functions is called a program, which solves the large problem.
Data moves freely around the system from one function to another function.
Structured programming follows top to bottom problem solving approach, so program is designed in to several sub modules(parts).Each module or sub modules can carry pre-defined set of functions.
C Structured programming is simple and easy to understand and use, programmer do not required any complex designing concepts to design the program.
Compiler and Interpreter
C involves a series of steps to run the program
1.Write(Code it) the program.
2.Compile the program.
3.Execute the program.
Compiler converts source code(program) in to the machine code.Machine can't understand the program written in high level language so we need to convert the source code in to the machine code and this is done by the compiler.Compiler also check the errors in the program and if the program is error free then it executes it.
Compiler
Hence,Compiler converts the program written in high level language into machine understandable language.
Compiler and Interpreter perform almost the same task but there is a different in their working method.
An Interpreter checks the program statement by statement.After checking the statement it convert the statement in to machine language and then execute the statement.
Interpreter
Different between Compiler and Interpreter
Basic structure of C Programs
C Program can be viewed as a group of functions(Modules). A function is a subroutine(Procedure) that may include one or more statements designed to perform a specific task.
1.The documentation section consist of a set of comment lines giving the name of the program, the author and other details which the programmer would like to use later.
2. The link section provides instructions to the compiler to link library functions from the system library.
3. The definition section defines all symbolic constants.
4. There are some variables called global variables and are declared in the global declaration section that is outside of all the functions.
5. Every C program must have one main() function section. It contains two parts, declaration part and executable part. The part declares the variables used in the executable part. There is at least one statement in the executable part.
6. These two parts must appear between the opening and the closing pair of braces. The program execution begins at the opening brace and ends at the closing brace.
7. The closing brace of the main function section is the logical end of the program.
8. All statements in the declaration and executable parts end with a semicolon.
9. The subprogram section contains all the user-defined functions that are called in the main function.
10.Userdefined functions are generally placed immediately after the main function, although they may appear in any order.
Header files
Header files are included in the program with preprocessor directive #include
Extension of the header file is .h
When we include header file to our program we can use the content of the header file
in our program.
There are two type of header files 1. In-built 2.User Define
Header file may contain function deceleration and macro definition.
C provides many inbuilt header files which contains common code and function
For example stdio.h, conio.h, string.h, math.h ,stdlib.h
#include<stdio.h>
#incude<conio.h>
Extension of the header file is .h
When we include header file to our program we can use the content of the header file
in our program.
There are two type of header files 1. In-built 2.User Define
Header file may contain function deceleration and macro definition.
C provides many inbuilt header files which contains common code and function
For example stdio.h, conio.h, string.h, math.h ,stdlib.h
#include<stdio.h>
#incude<conio.h>
0 comments:
Post a Comment