Title: C programming Training in Chennai
1 C
PROGRAMMING
2- INTRODUCTION-
- C Programming is an ANSI/ISO standard and
effective programming dialect for growing
continuous applications. - C programming dialect was developed by Dennis
Ritchie at the Bell Laboratories in 1972. - It was imagined for executing UNIX working
framework. C is most broadly utilized programming
dialect even today. - All other programming dialects were gotten
specifically or by implication from C programming
ideas. - I clarifies every single essential idea in C like
history of C dialect, information writes,
catchphrases, constants, factors, administrators,
articulations, control proclamations, exhibit,
pointer, string, library capacities, structures
and associations and so on.
3- HIGHLIGHTS OF C PROGRAMMING LANGUAGE
- Â
- C dialect is one of the capable dialect. The
following are a portion of the highlights of C
dialect. - Â
- Unwavering quality
- Versatility
- Adaptability
- Intuitiveness
- Measured quality
- Proficiency and Effectiveness
4- EMPLOYEMENT OF C PROGRAMMING LANGUAGE
- Â The C programming dialect is utilized for
creating framework applications that structures a
noteworthy bit of working frameworks, for
example, Windows, UNIX and Linux. The following
are a few cases of C being utilized. - Â
- Database frameworks
- Designs bundles
- Word processors
- Spreadsheets
- Working framework improvement
- Compilers and Assemblers
- System drivers
- Mediators
5THE LEVEL OF C PROGRAMMING- Â There are 3
levels of programming dialects. They are,
 1.Middle Level dialects  Center level
dialects don't give all the implicit capacities
found in abnormal state dialects, however gives
all building hinders that we have to create the
outcome we need. Illustrations C, C Â 2.High
Level dialects  Abnormal state dialects give
nearly everything that the developer may need to
do as effectively incorporated with the dialect.
Case Java, Python  3.Low Level dialects
 Low level dialects gives nothing other than
access to the machines fundamental direction set.
Case Assembler
6- C LANGUAGE IS A STRUCTURED LANGUAGE
- Â
- 1.Structure situated dialect
- Â
- In this kind of dialect, huge projects are
separated into little projects called capacities - Prime spotlight is on capacities and strategies
that work on the information - Information moves unreservedly around the
frameworks starting with one capacity then onto
the next - Program structure takes after "Best Down
Approach" - Illustrations C, Pascal, ALGOL and Modula-2
7- II) Question situated dialect
- Â
- In this sort of dialect, programs are isolated
into objects - Prime concentration is in the information that is
being worked and not on the capacities or
techniques - Information is covered up and can't be gotten to
by outside capacities - Program structure takes after "Base UP Approach"
- Illustrations C, JAVA and C (C sharp)
- III) Non structure situated dialect
- Â
- There is no particular structure for programming
this dialect. Illustrations BASIC, COBOL,
FORTRAN
8C DATA TYPES There are four data types in C
language. They are,
TYPES DATATYPES
Basic data types int, char, float, double
Enumeration data type enum
Derived data type pointer, array, structure, union
Void data type void
9- BASIC DATA TYPES IN C LANGUAGE
- 1. INTEGER DATA TYPE
- Integer data type allows a variable to store
numeric values. - int keyword is used to refer integer data type.
- The storage size of int data type is 2 or 4 or 8
byte. - It varies depend upon the processor in the CPU
that we use. If we are using 16 bit processor, 2
byte  (16 bit) of memory will be allocated for
int data type. - Like wise, 4 byte (32 bit) of memory for 32 bit
processor and 8Â byte (64 bit) of memory for 64
bit processor is allocated for int datatype. - int (2 byte) can store values from -32,768 to
32,767 - int (4 byte) can store values from -2,147,483,648
to 2,147,483,647. - If you want to use the integer value that crosses
the above limit, you can go for long int and
long long int for which the limits are very
high.
10CHARACTER DATA TYPE Character data type allows a
variable to store only one character. Storage
size of character data type is 1. We can store
only one character using character data
type. 2.char keyword is used to refer
character data type. For example, A can be
stored using char datatype. You cant store more
than one character using char data type.
11- FLOATING POINT DATA TYPE
- Floating point data type consists of 2 types.
They are, - float
- Double
- 1. FLOAT
- Float data type allows a variable to store
decimal values. - Storage size of float data type is 4. This also
varies depend upon the processor in the CPU as
int data type. - We can use up-to 6 digits after decimal using
float data type. - For example, 10.456789 can be stored in a
variable using float data type. - 2. DOUBLE
- Double data type is also same as float data type
which allows up-to 10 digits after decimal. - The range for double datatype is from 1E37 to
1E37.
12- Â MODIFIERS IN C LANGUAGE
- The amount of memory space to be allocated for a
variable is derived by modifiers. - Modifiers are prefixed with basic data types to
modify (either increase or decrease) the amount
of storage space allocated to a variable. - For example, storage space for int data type is 4
byte for 32 bit processor. We can increase the
range by using long int which is 8 byte. We can
decrease the range by using short int which is 2
byte. - There are 5 modifiers available in C language.
They are, - short
- long
- signed
- unsigned
- long long
13C Data types /Â storage Size Range
char / 1 127 to 127
int / 2 32,767 to 32,767
float / 4 1E37 to 1E37 with six digits of precision
double / 8 1E37 to 1E37 with ten digits of precision
long double / 10 1E37 to 1E37 with ten digits of precision
long int / 4 2,147,483,647 to 2,147,483,647
short int / 2 32,767 to 32,767
unsigned short int / 2 0 to 65,535
signed short int / 2 32,767 to 32,767
long long int / 8 (2power(63) 1) to 2(power)63 1
signed long int / 4 2,147,483,647 to 2,147,483,647
unsigned long int / 4 0 to 4,294,967,295
14- Â
- C TOKENS
- C tokens are the basic buildings blocks in C
language which are constructed together to write
a C program. - Each and every smallest individual units in a C
program are known as C tokens. - C tokens are of six types.
- They are,
- Keywords        (eg int, while),
- Identifiers        (eg main, total),
- Constants        (eg 10, 20),
- Strings           (eg total,
hello), - Special symbols  (eg (), )
15- IDENTIFIERS IN C LANGUAGE
- Each program elements in a C program are given a
name called identifiers. - Names given to identify Variables, functions and
arrays are examples for identifiers. eg. x is a
name given to integer variable in above program. - RULES FOR CONSTRUCTING IDENTIFIER NAME IN C-
- First character should be an alphabet or
underscore. - Succeeding characters might be digits or letter.
- Punctuation and special characters arent allowed
except underscore. - Identifiers should not be keywords.
- 3. KEYWORDS IN C LANGUAGE
- Keywords are pre-defined words in a C compiler.
- Each keyword is meant to perform a specific
function in a C program. - Since keywords are referred names for compiler,
they cant be used as variable name. - C language supports 32 keywords which are given
below. Click on each keywords below for detail
description and example programs.
16TYPES OF C CONSTANT-
Constant type data type (Example)
Integer constants int (53, 762, -478 etc )unsigned int (5000u, 1000U etc)long int, long long int(483,647 2,147,483,680)
Real or Floating point constants float (10.456789)doule (600.123456789)
Octal constant int (Example 013 /starts with 0 /)
Hexadecimal constant int (Example 0x90 /starts with 0x/)
character constants char (Example A, B, C)
string constants char (Example ABCD, Hai)
17BACKSLASH CHARACTER CONSTANTS IN C-
Backslash_character Meaning
\b Backspace
\f Form feed
\n New line
\r Carriage return
\t Horizontal tab
\ Double quote
\ Single quote
\\ Backslash
\v Vertical tab
\a Alert or bell
\? Question mark
\N Octal constant (N is an octal constant)
\XN Hexadecimal constant (N hex.dcml cnst)
18- DECLARING INITIALIZING C VARIABLE
- Variables should be declared in the C program
before to use. - Memory space is not allocated for a variable
while declaration. It happens only on variable
definition. - Variable initialization means assigning a value
to the variable.
Type Syntax
Variable declaration data_type variable_nameExample int x, y, z char flat, ch
Variable initialization data_type variable_name value Example int x 50, y 30 char flag x, chl
19 TYPES OF C OPERATORS-
Types of Operators Description
Arithmetic_operators These are used to perform mathematical calculations like addition, subtraction, multiplication, division and modulus
Assignment_operators These are used to assign the values for the variables in C programs.
Relational operators These operators are used to compare the value of two variables.
Logical operators These operators are used to perform logical operations on the given two variables.
Bit wise operators These operators are used to perform bit operations on given two variables.
Conditional (ternary) operators Conditional operators return one value if condition is true and returns another value is condition is false.
Increment/decrement operators These operators are used to either increase or decrease the value of the variable by one.
Special operators , , sizeof( ) and ternary operators.
20DIFFERENCE BETWEEN PRE/POST INCREMENT DECREMENT
OPERATORS IN C Below table will explain the
difference between pre/post increment and
decrement operators in C programming language.
Operator Operator/Description
Pre increment operator (i) value of i is incremented before assigning it to the variable i
Post increment operator (i) value of i is incremented after assigning it to the variable i
Pre decrement operator (i) value of i is decremented before assigning it to the variable i
Post decrement operator (i) value of i is decremented after assigni
21IF, ELSE AND NESTED IF DECISION CONTROL
STATEMENTS IN C- if- Syntaxif
(condition)  Statements DescriptionIn
these type of statements, if condition is true,
then respective block of code is
executed. ifelse- Syntaxif
(condition)Â Â Statement1 Statement2
 else  Statement3 Statement4
DescriptionIn these type of statements, group
of statements are executed when condition is
true. If condition is false, then else part
statements are executed.
22- nested if-
- Syntaxif (condition1)Â Statement1Â else_if(con
dition2)  Statement2  else Statement 3 - DescriptionIf condition 1 is false, then
condition 2 is checked and statements are
executed if it is true. If condition 2 also gets
failure, then else part is executed. - Loop control statements in C are used to perform
looping operations until the given condition is
true. Control comes out of the loop statements
once condition becomes false.
23- TYPES OF LOOP CONTROL STATEMENTS IN C
- There are 3 types of loop control statements in C
language. They are, - for
- while
- do-while
- For-
- for (exp1 exp2 expr3)Â statementsÂ
- Where,exp1 variable initialization( Example
i0, j2, k3 )exp2 condition checking(
Example igt5, jlt3, k3 )exp3
increment/decrement( Example i, j, k )
24While- while (condition) statements where,Â
condition might be agt5, ilt10 do
while- do  statements while
(condition) Â where,condition might be agt5,
ilt10
25DIFFERENCE BETWEEN WHILE DO WHILE LOOPS IN C
LANGUAGE
while do while
Loop is executed only when condition is true. Loop is executed for first time irrespective of the condition. After executing while loop for first time, then condition is checked.
26- Array-
- C Array is a collection of variables belongings
to the same data type. You can store group of
data of same data type in an array. - Array might be belonging to any of the data types
- Array size must be a constant value.
- Always, Contiguous (adjacent) memory locations
are used to store array elements in memory. - It is a best practice to initialize an array to
zero or null while declaring, if we dont assign
any values to array - TYPES OF C ARRAYS
- There are 2 types of C arrays. They are,
- One dimensional array
- Multi dimensional array
- Two dimensional array
- Three dimensional array
- four dimensional array etc
27- Pointers-
- Pointers in C language is a variable that
stores/points the address of another variable. - A Pointer in C is used to allocate memory
dynamically i.e. at run time. - The pointer variable might be belonging to any of
the data type such as int, float, char, double,
short etc. - Pointer Syntax data_type var_name Example
int p  char p - Where, is used to denote that p is pointer
variable and not a normal variable.
28USES OF C FUNCTIONS C functions are used to
avoid rewriting same logic/code again and again
in a program. There is no limit in calling C
functions to make use of same functionality
wherever required. We can call functions any
number of times in a program and from any place
in a program. A large C program can easily be
tracked when it is divided into functions. The
core concept of C functions are, re-usability,
dividing a big task into small pieces to achieve
the functionality and to improve
understandability of very large C programs Â
29- Structure-
- Structure is a collection of different data types
which are grouped together and each element in a
C structure is called member. - If you want to access structure members in C,
structure variable should be declared. - Many structure variables can be declared for same
structure and memory will be allocated for each
separately. - It is a best practice to initialize a structure
to null while declaring, if we dont assign any
values to structure
30- Union-
- C Union is also like structure, i.e. collection
of different data types which are grouped
together. Each element in a union is called
member. - Union and structure in C Â are same in concepts,
except allocating memory for their members. - Structure allocates storage space for all its
members separately. - Whereas, Union allocates one common storage space
for all its members - We can access only one member of union at a time.
- We cant access all member values at the same
time in union. But, structure can access all
member values at the same time. - This is because, Union allocates one common
storage space for all its members.
Where as Structure allocates storage space for
all its members separately. - Many union variables can be created in a program
and memory will be allocated for each union
variable separately.
31- BASIC FILE OPERATIONS IN C PROGRAMMING
- There are 4Â basic operations that can be
performed on any files in C programming language.
They are, - Opening/Creating a file
- Closing a file
- Reading a file
- Writing in a file
- 1.fopen()Â To open a file
- Declaration FILE fopen (const char filename,
const char mode) - fopen() function is used to open a file to
perform operations such as reading, writing etc.
In a C program, we declare a file pointer and use
fopen() as below. fopen() function creates a new
file if the mentioned file name does not exist. - FILE fpfpfopen (filename, mode)
- Where,fp  file pointer to the data type
FILE.filename  the actual file name with full
path of the file.mode refers to the operation
that will be performed on the file. Example r,
w, a, r, w and a. Please refer below the
description for these mode of operations
322.fclose() To close a file Declaration int fcl
ose(FILE fp) fclose() function closes the file
that is being pointed by file pointer fp. In a C
program, we close a file as below.fclose (fp) 3
. fgets()Â To read a file Declaration char
fgets(char string, int n, FILE fp) fgets
function is used to read a file line by line. Â In
a C program, we use fgets function as
below.fgets (buffer, size, fp) where,buffer
buffer to  put the data in.size size of the
bufferfp file pointer 4. fprintf()Â Â To write
into a file Declarationint fprintf(FILE fp,
const char format, )fprintf() function writes
string into a file pointed by fp. In a C program,
we write string into a file as below.fprintf
(fp, some data) orfprintf (fp, text d,
variable_name)
33- MODE OF OPERATIONS PERFORMED ON A FILE IN C
LANGUAGE - There are many modes in opening a file. Based on
the mode of file, it can be opened for reading or
writing or appending the texts. They are listed
below. - r Opens a file in read mode and sets pointer to
the first character in the file. It returns null
if file does not exist. - w Opens a file in write mode. It returns null
if file could not be opened. If file exists, data
are overwritten. - a Opens a file in append mode. It returns null
if file couldnt be opened. - r Opens a file for read and write mode and
sets pointer to the first character in the file. - w opens a file for read and write mode and
sets pointer to the first character in the file. - a Opens a file for read and write mode and
sets pointer to the first character in the file.
But, it cant modify existing contents.
34(No Transcript)
35Thank You You Visit my website www.greenstechnolo
gys.com www.trainingintambaram.net Contact
8939925577,9384637514 PlaceChennai,Bangalore,Tamb
aram