UNIT-I
INTRODUCTION TO C
History of C
C language is developed by Mr. Dennis Ritchie in the year 1972 at bell laboratory at USA,
C is a simple and structure Oriented Programming Language.
In the year 1988 C programming language standardized by ANSI
(American national standard institute), that version is called ANSI-C.
In the year of 2000 C programming language standardized by ISO that version is called C-99.
All other programming languages were derived directly or indirectly from C programming concepts
.
Overview of C
C is a computer programming language developed in 1972 by Dennis M. Ritchie at the Bell
Laboratories
C is a simple and structure oriented programming language.
C is also called mother Language of all programming Language.
It is the most widely used computer programming language, this language is used for develop
system software and Operating System.
All other programming languages were derived directly or indirectly from C programming
concepts.
Features/ Importance of C language
It is a robust language with rich set of built-in functions and operators that can be used to write
any complex program.
The C compiler combines the capabilities of an assembly language with features of a high-level
language.
Programs Written in C are efficient and fast. This is due to its variety of data type and
powerful operators.
It is many time faster than BASIC.
C is highly portable this means that programs once written can be run on another machines with little
or no modification.
Another important feature of C program, is its ability to extend itself.
A C program is basically a collection of functions that are supported by C library. We can also create
our own function and add it to C library.
C language is the most widely used language in operating systems and embedded system
development today.
SIMPLE C PROGRAM:
Step 1 : Open turbo C ,click on File and then click on New
#include<stdio.h>
#include<conio.h>
void main()
{
printf(“WELCOME”);
Step 2: Write the above example as it is
Step 3: Click on compile or press Alt+f9 to compile the program
Step 4: Click on Run or press Ctrl+f9 to run the code
Step 5: Output
WELCOME
BASIC STRUCTURE OF C PROGRAM
There are 6 main sections in C Program, they are
Documentation Section
This section consists of comment lines which include the name of programmer, the author and
other details like time and date of writing the program.
Documentation section helps anyone to get an overview of the program.
There are two ways in which we can write comments.
Using // - This is use to write a single line comment.
Using /* */ - This is use to write multi-line comments.
Link Section
The link section consists of the header files of the functions that are used in the program.
It provides instructions to the compiler to link functions from the system library.
Example:
#include<stdio.h>
#include<conio.h>
#include<math.h>
Definition Section
All the symbolic constants are written in definition section.
Macros are known as symbolic constants
Example:
#define PI3.14
#define TRUE1
Global Declaration Section
There are some variables that are used in more than one function.
Such variables are called global variables and are declared in the global declaration section that is
outside of all the functions.
Example:
int total ;
Main () Function Section:
Every C program must have one main function section.
This section contains two parts,
1. Declaration part: The declaration part declares all the variables used in the executable part.
2. Executable part: Write the statement in the executable part, which wants to execute
These two parts must appear between the opening and closing braces.
The program execution begins at the opening brace and ends at the closing brace.
The closing brace of the main function is the logical end of the program.
All statements in the declaration and executable part end with a semicolon.
Subprogram section:
If the program is amulti-function programthen the subprogram section contains all theuser-
defined functionsthat are called in the main ()function.
User-defined functions are generally placed immediately after the main () function, although they may appear in
anyorder
Example of Basic Structure of C Program:
/* Adding Two Integer Numbers*/ Documentation Section
#include<Stdio.h>
#include<conio.h>
Output:
Enter the two numbers : 1 2
The sum of two numbers is : 3