C langugae : Middle Level Language

C is often called a middle-level computer language. This does not mean that C is less powerful, harder to use, or less developed than a high-level language such as BASIC or Pascal, nor does it imply that C has the cumbersome nature of assembly language (and its associated troubles). Rather, C is thought of as a middle-level language because it combines the best elements of high-level languages with the control and flexibility of assembly language.
High Level Language : - Ada, Modula-2, Pascal, COBOL, FORTRAN, BASIC
Middle Level Language : - Java, C++, C , FORTH, Macro-assembler
Low Level Language : - Assembler
All high-level programming languages support the concept of data types. A data type defines a set of values that a variable can store along with a set of operations that can be performed on that variable. Common data types are integer, character, and floating-point. Although C has several builtin data types, it is not a strongly typed language, as are Pascal and Ada. C permits almost all type conversions. For example, you may freely intermix character and integer types in an expression.
C is special in that it allows the direct manipulation of bits, bytes, words, and pointers. This makes it well suited for system-level programming, where these operations are common.
Another important aspect of C is that it has only a small number of keywords, which are the commands that make up the C language. For example, C89 defined 32 keywords, and C99 adds only 5 more. High-level languages typically have many more keywords. As a comparison, consider that most versions of BASIC have well over 100 keywords!

C langugae : Seven Steps

Seven Steps of C Programming
Step 1: Define the Program Objectives
Step 2: Design the Program
Step 3: Write the Code
Step 4: Compile
Step 5: Run the Program
Step 6: Test and Debug the Program
Step 7: Maintain and Modify the Program

Compilers vs. Interpreters

There are two general methods by which a program can be executed.
* Compiler
* Interpreter
The compiler is a special program that reads the instructions stored in the source code file, examines each instruction, and then translates the information into the machine code understood only by the computer’s microprocessor.
* The compiler translates the information in the source code file into instructions the computer can understand. The linker then converts that information into a runnable program.
* The GCC compiler recommended and used in this book combines the compiling and linking steps. An object file is created by GCC, but it is automatically deleted when the final program file is created.
* Object code files end in OBJ or sometimes just O. The first part of the object file name is the same as the source code filename.
*Feel free to cheerfully forget all this object code nonsense for now.
*Text editor - Compiler.
*Source code - Program.
Interpreter reads the source code of your program one line at a time, performing the specific instructions contained in that line. This is the way earlier versions of BASIC worked.
Object code is alsoreferred to as binary code or machine code. Once the program is compiled, a line of source code is no longer meaningful in the execution of your program.In general, an interpreted program runs slower than a compiled program. A compiler converts a program's source code into object code that a computer can execute directly.

Library and Linking

All C compilers come with a standard library of functions that perform most commonly needed tasks.Standard C specifies a minimal set of functions that will be supported by all compilers.
When you call a library function, the C compiler ''remembers" its name. Later, the linker combines the code you wrote with the object code already found in the standard library. This process is called linking. Some compilers have their own linker, while others use the standard linker supplied by your operating system.
The functions in the library are in relocatable format. This means that the memory addresses for the various machine-code instructions have not been absolutely defined— only offset information has been kept. When your program links with the functions in the standard library, these memory offsets are used to create the actual addresses used.

A Simple Example of C

C : Compile Process

The compiler is just a way to transform your program from a source code file to an executable file.The program must go through one additional stage after compiling and before running. It is called the linking, or the link editing, stage your program is linked, the compiler sends runtime information to your program such as the memory addresses where variables and code will be stored when your program executes. You can also combine several compiled programs into one executable program by linking them. Most of the time, however, your compiler initiates the link editing stage and you do not have to worry about controlling the linking process.

The executable results of a source program that ends with the .C extension. Again, be as accurate as possible. In most programming languages—and especially in C—the characters you type in a program must be accurate. In this sample C program, for instance, you see parentheses, ( ), brackets, [], and braces, {}, but you cannot use them interchangeably.
The comments (words between the two symbols, /* and */) to the right of some lines do not need to end in the same alignments that you see in the listing.The new style requires only that a comment begin with two forward slashes (//) and continue until the end of the line.


Free Web Hosting