Overview of C Language Overview of C Language: History History

You might also like

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

2/15/2023

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
2/15/2023

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


Link Section :- Definition Section :-
It provides instructions to the compiler to link It defines all symbolic constants.
function from the system library. eg. #define PI 3.14
# include Directive:- It tells the preprocessor It’s not a statement. Therefore it should not end
to insert the contents of another file into the with a semicolon.
source code at the point where the #include Generally written in uppercase.
directive is found.
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
1.) Local variable declaration section.
2.) Global variable declaration Two parts,
Global variables are declared out side the main 1) Declaration part: It declares all the
function. Scope of variable is whole program. variables used in the executable part.
Local variables are declared inside the main 2) Executable part: It contains instructions to
function. Scope of variable is the function in perform certain task.
which it is declared.

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


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

2
2/15/2023

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

Tokens Semicolons(;)
A token is either a keyword, an identifier, a It is a statement terminator.
constant, a string literal, or a symbol. Each individual statement must be ended with a
Eg. printf("Hello, World! \n"); semicolon.
The individual tokens are: It indicates the end of one logical entity.
printf Eg.
( printf("Hello, World! \n");
"Hello, World! \n" return 0;
) or
; printf("Hello, World! \n"); return 0;

Comments Identifiers
Comments are like helping text in your C program A C identifier is a name used to identify a
and they are ignored by the compiler. variable, function, or any other user-defined
Single line comment: //first program in c item.
Multiline comment: /* first An identifier starts with a letter A to Z or a to
z or an underscore _ followed by zero or more
program
letters, underscores, and digits (0 to 9).
in
C does not allow punctuation characters such as
C */ @, $, and % within identifiers.
C is a case sensitive programming language.
Eg. int money;
Here, money is identifier.

3
2/15/2023

Identifiers(Cont.) Keywords
Acceptable identifiers: They are reserved words in C.
mohan zara abc These reserved words may not be used as constant
move_name a_123 myname50 or variable or any other identifier names.
_temp j a23b9 Eg. int money;
retVal Here, int is keyword.

Whitespace
Whitespace describes blanks, tabs(\t),
newline(\n) characters.
Whitespace separates one part of a statement from
another and enables the compiler to identify
where one element in a statement, such as int,
ends and the next element begins.
Eg. int age;

Q & A
abc@12
xyz!
Smith
S09
A_b
$abc
12ab
float
break

You might also like