Sunday, March 18, 2007

Starting C Language

What is C?

C is a programming language invented in the early 1970s by Dennis Ritchie as a language for writing operating systems.

Here is a short overview and history of C.

The purpose of C is to precisely define a series of operations that a computer can perform to accomplish a task. Most of these operations involve manipulating numbers and text, but anything that the computer can physically do can be programmed in C.

Computers have no intelligence- they have to be told exactly what to do and this is defined by the programming language you use. Once programmed they can repeat the steps as many times as you wish at very high speed. Modern PCs are so fast they can count to a billion in a second or two.
...................................................................................................................................

Lets write a simple program.

In your editor type the following C code and save it as first.c.

#include
void main()
{
printf("\nHello World\n");
}

Compiling the program.

After you save the program you have to compile the program. This creates an executable file first.exe, which is then executed simply by typing its name.

The result is that the characters " Hello World'' are printed out, preceded by an empty line.

Explanation of the above program

Our first.c code calls printf, an output function from the I/O (input/output) library (defined in the file stdio.h). The original C language did not have any built-in I/O statements whatsoever. Nor did it have much arithmetic functionality. The original language was really not intended for ''scientific'' or ''technical'' computation.. These functions are now performed by standard libraries, which are now part of ANSI C. The K & R textbook lists the content of these and other standard libraries in an appendix.

The printf line prints the message ``Hello World'' on ``stdout'' (the output stream corresponding to the X-terminal window in which you run the code); ``\n'' prints a ``new line'' character, which brings the cursor onto the next line. By construction, printf never inserts this character on its own.

4 comments:

iSoftech said...

good job bro..

Rajesh said...

tanx friend

Eran Smith said...

great thing the way you use to teach is relay nice and easy to understand

.net Obfuscators

Unknown said...

good job :) but try to update some notes on java if possible!! it will help me a lot!!