Sunteți pe pagina 1din 6

Programming Language:*A programming language is designed to process certain kinds of data consisting of numbers, characters and strings and

to provide useful output known as information. *The processing of data is accomplished by executing a sequence of precise instruction called program. *The instructions are formed using certain symbols and words according to some rigid rules known as syntax rules or grammar. Programming Language Machine (+1300042774 +1400593419 +1200274027) Assembly Language

(LOAD A

ADD B S TORE C)

High Level Language

(C=A+B)

C Language:*The C language was written in 1970 for the first UNIX system by Dennis Ritchie and was implemented at Bell Laboratories. *Today, C is running under a number of operating system including MS-DOS, Windows, and Linux etc. *In 1988, the American National Standards Institute (ANSI) adopted a new and improve version of C, known today asANSI C. Importance of C:1.

It is a robust language whose rich set of built in functions and operators can be used to write any complex program.

2. The compiler combines the capabilities of an assembly language with the feature of a high level language. 3. Program written in C are efficient and fast. It is many times faster than BASIC.

For Example a program to increment a variable from 0 to 15000 takes one second in C while it takes more than 50 seconds in BASIC.

4. C is highly portable .This means that C programs written for one computer can be run on another with little or no modification. A First Program :/* Hello World Program*/ #include<stdio.h> #include<conio.h> void main() { clrscr(); printf("Hello World\n"); getch(); }

Running the program:


1. 2.

Save the file in hello.c extension. Press Alt+F9 to compile

3. Press ctrl+F9 to execute Example Explained: 1. The program will start form main function. The main function establishes the overall logic of the code. 2. All C codes must have a main function. 3. Use more than one main () is illegal. 4. The empty pair of parentheses immediately following main indicated that the function main has no arguments or parameters.

5.

The opening brace { indicates the beginning of the function and closing} indicates the end of the function.

6. All the statements between these two braces form the function body. The function body contains a set of instructions to perform the given task. 7. printf(), an output function form the I/O ( input/output )library (defined in the file stdio.h )
8.

\n prints a new line character, which brings the cursor onto the next line.

9. Every statement in C should end with a semicolon (;) mark.


10. The

first statement is #include <stdio.h>. The .h files are by convention header files which contain definition of variables and functions necessary for the functioning of a program. lines beginning with /* and ending with */ are known as comment lines. These are used in a program to enhance its readability. Comment lines are not executable statements and therefore anything between /* and */ is ignored by the complier.

11. The

The C Compilation Model :-we will briefly highlight key features of the C Compilation model here

The Preprocessor:-The Preprocessor accepts source code as input and is responsible for .Removing comments .Interpreting special Preprocessor directives denoted by #. -For Example #include includes contents of a named file. Files usually called header files. e.g.: #include <math .h>-standard library maths files #definedefines a symbolic name or constant . e.g.:#define MAX_ARRAY_SIZE 100 Int array [MAX _ARRAY_SIZE]

*C Compiler

-The C Compiler translates source to assembly code. The source code is received from the preprocessor.

*Assembler -The assembler creates object code. On a UNIX system you may see files with a .o suffix (.OBJ on MSDOS) to indicate object code files. *Link Editor -If a source file references library functions or functions defined in other source files the link editor combines these functions {With main()} to create an executable file.

Executing A C Program:*Executing a program written in c involves a series of steps. These are: - creating the program. - Compiling the program. - Linking the program with function that are needed from the C library . - Executing the program. ----------------- 0 ---------------------

S-ar putea să vă placă și