Saturday, October 13, 2007

Introduction to C programming

Introduction to C programming

Powerful features, simple syntax, and portability make C a preferred language among programmers for business and industrial applications. Portability means that C programs written for a computer with a particular kind of processor, say Intel, can be executed on computers with different processors such as Motorola, Sun Sparc, or IBM with little or no modification.

C language is widely used in the development of operating systems. An Operating System(OS) is a software(collection of programs) that controls the various functions of a computer. Also it makes other programs on your computer work. For example, you cannot work with a word processor program, such as Microsoft Word, if there is no operating system installed on your computer. Windows, Unix, Linux, Solaris, and MacOS are some of the popular operating systems.

Origin of C

Dennis M. Ritchie, a systems engineer at Bell Laboratories, New Jersey developed C in the early 1970’s. Although designed for the Unix operating system, it soon proved itself a powerful, general purpose programming language. You can learn more about the history and development of C by visiting the following Web page: http://cm.bell-labs.com/cm/cs/who/dmr/chist.html

Where is C useful?

C’s ability to communicate directly with hardware makes it a powerful choice for system programmers. In fact, popular operating systems such as Unix and Linux are written entirely in C. Additionally, even compilers and interpreters for other languages such as FORTRAN, Pascal, and BASIC are written in C. However, C’s scope is not just limited to developing system programs. It is also used to develop any kind of application, including complex business ones. The following is a partial list of areas where C language is used:

Ø Embedded Systems

Ø Systems Programming

Ø Artificial Intelligence

Ø Industrial Automation

Ø Computer Graphics

Ø Space Research

Ø Image Processing

Ø Game Programming

What kind of language is C?

C is a structured programming language, which means that it allows you to develop programs using well-defined control structures (you will learn about control structures in the articles to come), and provides modularity (breaking the task into multiple sub tasks that are simple enough to understand and to reuse).

C is often called a middle-level language because it combines the best elements of low-level or machine language with high-level languages.

Why you should learn C?

You should learn C because:

· C is simple.

· There are only 32 keywords so C is very easy to master. Keywords are words that have special meaning in C language.

· C programs run faster than programs written in most other languages.

· C enables easy communication with computer hardware making it easy to write system programs such as compilers and interpreters.

C-Language keywords

auto double if static

break else int struct

case enum long switch

char extern near typedef

const float register union

continue far return unsigned

default for short void

do goto signed while

Getting equipped to write C programs

The tools required for C programming are simple. All you need are:

  1. A text editor: A text editor allows you to type in, modify, and save your program. Notepad in Windows, Edit in DOS, and vi and Emacs in Unix/Linux are some popular text editors.

  1. A C compiler: A compiler is a program that converts the high-level language (HLL) program (referred to as source code) into machine language (object code). Borland C, GCC, and Microsoft C are some of the popular compilers.

Earlier text editors and compiler had to be used separately. However, today most software vendors provide them as a package called IDE (Integrated Development Environment). Popular IDE’s include Turbo C from Borland Inc., and Microsoft C from Microsoft Inc.

No comments: