Professional Documents
Culture Documents
Unit 1
Unit 1
Session 1
Agenda
• Overview of C
Introduction to C-Language
History of ‘C’ Language
• Edit Compile Link Execute- A Cyclic Process
• My First C Program
• Dissecting a C Program
• Structure of C Programs
• Constants, Variables and Data Types in C
• Escape Sequence
• Arrays: Single and Multidimensional
Introduction to C-Language
• C is a general-purpose language which has been closely
associated with the UNIX operating system
• C is often called a "Middle Level" programming language
• Currently, the most commonly-used language for
embedded systems
• Embedded Systems- Handheld Electronic Devices
• “High Level assembly”
• Very portable: compilers exist for virtually every processor
• Easy-to-understand compilation
• Produces efficient code- Memory Efficient
• Designed for systems programming
• Operating systems
• Utility programs
• Compilers
History of C-Language
• Developed between 1969 and 1973 along with Unix
• Due mostly to Dennis Ritchie, an employee from Bell Labs (AT&T)
• Few key ideas of C are borrowed from BCPL, developed by Martin
Richards
• Influenced by BCPL, though indirectly through the language B,
which was written by Ken Thompson in 1970 at Bell Labs
• BCPL and B are "type less" languages where as C has Data Types
• Dennis Ritchie wrote C in 1972 at Bell Labs
• Later in 1978, a publication The C Programming Language written
by Kernighan & Ritchie enlightened and created revolution
• In 1983, the American National Standards Institute (ANSI) formed
a committee to provide a modern, comprehensive definition of C
• Finally in 1988, ANSI standard, or "ANSI C", was completed late
1988.
Edit-Compile-Link-Execute A Cyclic Process
EDIT COMPILE
void main()
{
printf(“Hi
There!!!\n”);
}
Analysing a C Program-”Hi
There!!!”
Header File which
#include <stdio.h> stores definition of
printf function
Program mostly a
void main() collection of
functions
{ “main” function
printf(“Hi There!!! special: the entry
point
n”); “void” qualifier
indicates function
} does not return
anything
I/O performed by a
library function: not
included in the
language
Structure of C Programs
• Layout of C Programs
Pre-processor directives
Global declaration
main()
{
Local variable declaration
List of statements
}
Function1()
{
List of statement
}
……
FunctionN()
{
List of Statement
}
Structure of C Programs
• Layout of C Programs
Pre-processor directives
Global declaration
main()
{
Local variable declaration
List of statements
}
Function1()
{
List of statement
}
……
FunctionN()
{
List of Statement
}
Constants, Variables and Data
Types in C
C Identifiers and Keywords
• Identifier
Identifier is a alphanumeric character in C
It is a name giver to variables, function and user defined entities
An identifier can be composed of letters (both uppercase and
lowercase letters), digits and underscore '_' only
• Character Set
Character set are the set of alphabets, letters and some special
characters that are
Uppercase: A B C .................................... X Y Z
Lowercase: a b c ...................................... x y z
Digits: 0 1 2 3 4 5 6 7 8 9
Special Characters: , <> . _();$:%[]#?’&{}”?^/|-\~+ Space
White space Characters: blank space, new line, horizontal tab, carriage
return and form feed
C Identifiers and Keywords
• Identifier
Identifier is a alphanumeric character in C
It is a name giver to variables, function and user defined entities
An identifier can be composed of letters (both uppercase and
lowercase letters), digits and underscore '_' only
• Character Set
Character set are the set of alphabets, letters and some special
characters that are
Uppercase: A B C .................................... X Y Z
Lowercase: a b c ...................................... x y z
Digits: 0 1 2 3 4 5 6 7 8 9
Special Characters: , <> . _();$:%[]#?’&{}”?^/|-\~+ Space
White space Characters: blank space, new line, horizontal tab, carriage
return and form feed
C Identifiers and Keywords
• Identifier
Identifier is a alphanumeric character in C
It is a name giver to variables, function and user defined entities
An identifier can be composed of letters (both uppercase and
lowercase letters), digits and underscore '_' only
• Character Set
Character set are the set of alphabets, letters and some special
characters that are
Uppercase: A B C .................................... X Y Z
Lowercase: a b c ...................................... x y z
Digits: 0 1 2 3 4 5 6 7 8 9
Special Characters: , <> . _();$:%[]#?’&{}”?^/|-\~+ Space
White space Characters: blank space, new line, horizontal tab, carriage
return and form feed
C Variables
• Variable
Variables are memory location in computer's
memory to store data
Variable should have unique name
Variables are symbolic representation of a memory
location
Example: sum, _Sum, Result, result_data
Example:
main()
{
const float pi = 3.14;
}
C Data Types
• Fundamental data type
int (signed/unsigned)(2,4Bytes): used to store integers.
float, double(4,8Bytes): used to store a decimal number.
char (1Byte): used to store characters
Roll_Number[2][1] will fetch data from 3rd row and second column
i.e. Roll_Number[2][1]=6
C Standard Library