2.overview of C Language

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

3/7/2022

History
Overview of C language  C is a structured programming language developed by
Dennis Ritchie in 1973 at Bell Laboratories.
 C programming language features were derived from
an earlier language called “B”.
 C language was invented for implementing UNIX
operating system.
 Today's most popular Linux OS and RBDMS MySQL
have been written in C.

Features

 Simple
 Portable
 Structured programming language
 Rich library
 Memory Management
 Speed
 Pointer
 Recursion
 Middle level language

Basic Structure of ‘C’ Basic Structure of ‘C’ (Cont.)


 Documentation Section :-
 It has set of comment lines(name of program, author
details).
 Non-executable statement.
 Can’t be nested.
 eg. /* Program to find factorial of a number
By: Smith */

/* Welcome /* friends */ ! */ Illegal

1
3/7/2022

Basic Structure of ‘C’ (Cont.) Basic Structure of ‘C’ (Cont.)


 Link Section :-  Definition Section :-
 It provides instructions to the compiler to link function  It defines all symbolic constants.
from the system library.  eg. #define PI 3.14
 # include Directive:- It tells the preprocessor to insert  It’s not a statement. Therefore it should not end with a
the contents of another file into the source code at the semicolon.
point where the #include directive is found.  Generally written in uppercase.
 stdio– Standard Input /Output
 conio– Console input/Output
 math- contains mathematical functions like(cos(), sin(),
sqrt(), abs())
 Eg. #include<stdio.h>

Basic Structure of ‘C’ (Cont.) Basic Structure of ‘C’ (Cont.)


 Global Declaration Section :-  main() function Section :-
 Two types of declarations:  Every C program must have one main function section.
1.) Local variable declaration  Two parts,
2.) Global variable declaration 1) Declaration part: It declares all the variables used in
 Global variables are declared out side the main the executable part.
function. Scope of variable is whole program. 2) Executable part: It contains instructions to perform
 Local variables are declared inside the main function. certain task.
Scope of variable is the function in which it is declared.

Basic Structure of ‘C’ (Cont.) Example 1


 Subprogram Section :-  /*Documentation Section: Program to find the area of
 It contains body of user defined function. circle*/
 Eg. int sum (int a, int b) #include <stdio.h> /*link section*/
{ #include <conio.h>/*link section*/
int c; #define PI 3.14 /*definition section*/
c=a+b; float area; /*global declaration section*/
return c; void main()
} {
float r; /*declaration part*/
printf("Enter the radius of the circle\n"); /*executable
part starts here*/

2
3/7/2022

Example 1(Cont.)
scanf("%f",&r);
area=PI*r*r;
printf("Area of the circle=%f",area);
getch();
}

You might also like