2. introduction
C is general purpose languagewhich is very closely
associated with unix for which it was developed in bell
laboratories.
Most of the programs UNIX are written and run with
help of c
Many of ideas from of c stem are from BCPL, BY
Martin Richards
In 1972 Dennis ritchie at bell laboratories wrote c
language which caused a revoultion in computing
world
3. About c
C is a programmin language which can used to develop
the softwares or applications
C can be defined as Mother language because different
programmin languages c++,python,.net.
C can be defined as structure oriented programming
language
C program instructions will executed line-by-line one
after the another and we need to write few statements
in specified place only
C can be defined as procedure oriented programmin
language.
4. Translator
Are the softwares which can translate the program
instruction s from one format to another
Types of translatores :-
1 compiler :H.L.L -> M.L(At a time all scan)
2 Assembler :A.L ->M.l
3 Interpreter : H.L.L->M.L(at one time line by
• line scanning)
• H.L.L means high level language
• M.L - middle level
• A.L - Assemble language
5. High level language :- I is nothing but general english
language
Middle level language:H.L.L+Assemble language
6. SOFTWARE
Software:- a software is a programor a set of programs
system software:- are the software specially designed from
system
ex: drivers-audio
-printers
Application software:- software are designeed from users
Desktop application – which installation to use .
als known as stand alone applications
Web application – are the application runs on the server
this is shareable
ex :- gmail.com
7. History of c
BASIC-beginners all purpose symbolic insruction code
Cobol-commom business oriented language
Fortran-formula transaltion
Pascal
Algol- algorthamic language
Cpl-combined programming laguage
BCPL – basic combined programming laguage
Traditional c
Ansic(american national standard instution)
C95
c99
8. features
1 middle level language –h.l.l +a.l
c programs can be written using H.L.L as well as
Assemble language
so c is called middle level language
Writing c programs much easier than assemble Language
2 pre-defined language c:- c language offers pre-defined
function
3 Modularity a program can divieded into su programs to
perform different operations.here such program called
“function”
9. 4 Extensibilty c programs can extend usily
5 Memory Management:- in c language we can
allocated the memory dynamically as our requrement
so that use of memory efficient and no wastage of
memory
6.Fast and efficient
7.portable
10. C programs built from
Variable and type declarations
Functions
Statements
Expressions
11. a sample c program
#include<stdio.h>
Int man{
Other statements
}
12. Header files
The files specified include section is called as header
file.
These are precompiled files has some functions
defined in them
Source file is extension .c
Header file is extension .h
13. Main function
This is entry point of program
When file is executed the start point is main function
From the main function the flow goes as programmers
choice
Main function is compoulsory of any c program
14. Tokens type in c
Constants:-
Integer Constants – Refers to sequence of digits such as
decimal integer, octal integer and hexadecimal integer. –
Some of the examples are 112, 0551, 56579u, 0X2 etc.
• Real Constants – The floating point constants such as
0.0083, -0.78, +67.89 etc.
• Single Character Constants – A single char const contains a
single character enclosed within pair of single quotes [ ‘ ’ ].
For example, ‘8’, ‘a’ , ‘i’ etc.
• String Constants – A string constant is a sequence of
characters enclosed in double quotes [ “ ” ]; For example,
“0211”, “Stack Overflow” etc
15. Data types
All Variables use data-type during declaration to
restrict the type of data to be stored. We can say that
data types are used to tell the variables the type of data
it can store.
Primitive Data Types: Predefined Data Types and can
be used directly by the user to declare variables.
Example:- int, char, float, etc.
User defined data types:- These data types are defined
by user itself.
Example :- Defining a Strucute in C or a union.
16. variables
Variables is a name of a memory location which holds
any data
When you create a variable in C, you must give it a data
type. You can assign a value to the variable at the time
you create it or later in your program code. This is
known as initializing the variable.
Example:- int myVar = 0;
Rules :-
No space
36-40 no lengthy characters
17. operators
Operators are the foundation of any programming
language. We can define operators as symbols that helps us
to perform specific mathematical and logical computations
on operands. Types:-
Arithmetic operators:- used to perform mathematical
operation.(+,-,*,/,%,++,--).
Relational operators:- used for comparison of the values of
two operands.(==,>,=,<=).
Logical operators:- used to combine two or more
conditions.(True or false)
Bitwise operators:- used to perform bit-level operations on
the operands. And many more
18. statements
Output statement:-
*printf is a pre-defined function it can used to prints
message,values or result of the program
Syntax
printf(“ this is c programming”)
Input statement:-
Scanf():-
It is pre-defined function it can be used to read the values to
variables from keyoard at runtime of program
Syntax:- scanf(“format specifier list”,variable list with address
operator
19. If statement
The if statements are concerned with Boolean logic. If
the statement is true, the block of code associated with
the if statement is executed. If the statement is false ,
control either falls through to the line after the if
statement, or after the closing curly brace of an if
statement block.
Eg:- char response = ‘y’;
if (response == ‘y’ || response == ‘Y’)
{ cout << “positive response received” << endl ;}
20. Switch staements
If there are too many else if statements, code can
become messy and difficult to follow.in this scenario, a
better solution is to use a switch statement . The
switch statement simply replaces multiple else if
statements.
Eg:- char response = ‘y’ ;
Switch (response) { case ‘y’ : break ;
Case ‘n’ : break ;
Default : brea
21. Loops :-
A loop is a reptative process.
Types :-
1.while
Syntax:-while(condition)
{
satatements
}
2.Do-while
syntax:- do{statements;
}while(condition);
3.For loop- for(intilization,condtion,inc/dec)
Advantage:
1.reduce length of file
2.save time
22. Arrays in c
Array is a collection of data items all of same types
Three types of array
1.one dimensional array
2. two dimensional array
3. multi dimensional array
Array declaration syntax: data type arr_name[array_size];
Learnt how to declare and initialize at compile time and run time
STRING IN C
A string in C is merely an array of characters
The length of a string is determined by a terminating null character:
'0‘
String has some in built functions so it can save our time space and
efficient
23. Functions
A Function is a block of statementswhich can useed to
perform any operation
Pre-defined
User defined
Function terminology:-
function prototype
Function calling
Function definition
Parametres
Return type
25. Strucure and union
Strucure:- collection of hetrogenous elements
each member have memory location
Struct is keyword
individual members are accesed at a time
Several members are initialised at once
Union:
Memory allocated individual member
Union is keyword
only first members are intilised
Only one meber is accesd
26. pointers
pointres:- it holds address of another varibel
1 & address of pointer
2. (*) value at addres pointer
Types
1,wild poiunter;- a pointer is not intilaised
2dangling:-which pointer arise an object is deleted or deallocated
without modifying value of pointer.
3.Null pointer:- initialize a pointer variable when that pointer
variable isn’t assigned any valid memory address A
4.void pointer is a pointer that has no associated data type with
it. A void pointer can hold address of any type and can be
typcasted to a
any type. Advantage :- malloc() calloc() is allocated at any type
27. DYNAMIC MEMORY ALLOCATION
It is aprocess of allocating memory during execution time (or)
run time.
Header file:- alloc.h or stdlib.h
There are four types In this
1.malloc
2.calloc
3.realloc
4.free
By malloc and calloc we can increase our memory dynamically
By using realloc we can reallocate the memory if we want
After the programme has completed we can free our memory by
using free statement
28. File handling
It is a place on the disk we are a group of data stored
permananentlry
Types
Text file :-
It is humanread file
It is modifed
Extension is doc
Binary file :-
It is not human readable file
Extension is fof,efof
29. Types of file
Sequentaial
Random access
File operations :-
Read
Opening a file
Creating a file
Writing a file
Modifing a file