C-Programming
C - Basic Introduction
C is a general-purpose high level language that was originally developed by Dennis Ritchie for the UNIX operating system. It was first implemented on the Digital Equipment Corporation PDP-11 computer in 1972. The UNIX operating system and virtually all UNIX applications are written in the C language. C has now become a widely used professional language for various reasons. Easy to learn
Structured language
It produces efficient programs.
It can handle low-level activities.
It can be compiled on a variety of computers.
Facts about C
C was invented to write an operating system called UNIX.
C is a successor of B language which was introduced around 1970
The language was formalized in 1988 by the American National Standard Institute (ANSI).
By 1973 UNIX OS was almost totally written in C.
Today C is the most widely used System Programming Language.
Most of the state of the art software have been implemented using C
C was initially used for system development work, in particular the programs that make-up the operating system. C was adopted as a system development language because it produces code that runs nearly as fast as code written in assembly language. Some examples of the use of C might be:
Operating Systems
Language Compilers
Assemblers
Text Editors
Print Spoolers
Network Drivers
Modern Programs
Data Bases
Language Interpreters
Utilities
C Compilers
When you write any program in C language then to run that program you need to compile that program using a C Compiler which converts your program into a language understandable by a computer. This is called machine language (i.e. binary format). So before proceeding, make sure you have C Compiler available at your computer. Some examples of C compilers are Turbo C and Borland C.
C - Program Structure
A C program basically has the following form:
Preprocessor Commands
Functions
Variables
Statements & Expressions
Comments
Preprocessor Commands: This command tells the compiler to do preprocessing before doing actual compilation. Like;
- #include stdio.h
The C Programming language provides a set of built-in functions. printf() is a C built-in function which is used to print anything on the screen.
Variables: Variables are used to hold numbers, strings and complex data for manipulation. Statements & Expressions: Expressions combine variables and constants to create new values. Statements are expressions, assignments, function calls, or control flow statements which make up C programs.
Comments: are used to give additional useful information inside a C Program. All the comments will be put inside /*...*/ as given in the example above. A comment can span through multiple lines.
Note the followings
C is a case sensitive programming language. It means in C printf and Printf will have different meanings.
C has a free-form line structure. End of each C statement must be marked with a semicolon.
Multiple statements can be one the same line.
White Spaces (ie tab space and space bar ) are ignored.
Statements can continue over multiple lines.
Data Types in C
A C language programmer has to tell the system before-hand, the type of numbers or characters he is using in his program. These are data types. There are many data types in C language. A C programmer has to use appropriate data type as per his requirement in the program he is going to do.