Fundamentals
• C is a programming
language developed at
AT & T’s lab.
• Designed by Dennis
Ritchie.
• It is reliable, simple
and easy to use.
• It is a structured
programming
language.
Why bother to learn “C”
• Provides basic programming skills to work
further with C++, java, etc.
• Many OS are still written in C.
• Speed and performance is high.
• Mobile devices and consumer devices getting
smarter with C programming.
• Popular games are built with C language.
Features of C language
 Portability
 Modularity
 Flexibility
 Speed
 Extensibility
 Compactness
 Case sensitive
 Computers were programmed in binary
numbers also known as low level. These are
machine dependent.
 Assembly language came into existence that
used assembler as converter. Still were
machine dependent.
 Later, high level language was introduced
which was machine independent.
Compiling program
 Compiler is a software program.
 It analyzes program and translates for
execution.
 Program is typed into a file known as
source program with name like
prog.c which is a valid name.
Steps for compilation
 Compiler examines each source program statement.
 Checks with syntax or rules and semantics of language.
 Error if occurred will be reported to the user.
 Compilation process ends there.
 Once errors corrected, compiler converts each
statement to lower form.
 Compilation process converts assembly language to
actual machine code called as object code.
 After this conversion, it is ready to be linked.
 Final linked file is stored in another file ready to be
run.
INTEGRATED DEVELOPMENT
ENVIRONMENTS
The process of editing,
compiling, running and
debugging programs is done by
single application known as IDE.
It is a windows based program.
It helps programmers to develop
software.
Language interpreters
 In high level languages, interpreters
are used.
 Interpreter analyzes and executes
the statements at the same time.
 This method is helpful in debugging
programs easily.
 It can execute the source code
directly.
Structure of C program
• C program has a group of building blocks
called functions.
• A function is a subroutine that may have
one or more statements to perform a
certain task.
• To write a C program, first create
functions.
Structure
Comments serves as some purpose for
statement.
How to use:
/* some comments */
Ex: /*sum*/
Its is not necessary, any number of comments
can be written.
A multi line comment can be made.
Ex: /* this comment has
three lines
in it */
// this comment has
// three lines
// in it.
Any alphabet, digit or special symbol is
a character.
Alphabets – a,b,c……/A,B,C….
Digits – 0……8, 9
Special symbols- , ; : ? * & ^ and so on
C tokens
Smallest individual unit in a C program is called as a
token.
integer real character
decimal octal Hexadecimal
unary binary ternary
Data type
primary
Integer
Float
Double
Character
secondary
structure
union
Array or string
User-
defined
Enumerated
typedef
void pointer
Primary datatype
1 byte (8 bits)
2 byte (16 bits)
4 byte (32 bits) long int
4 byte (32 bits)
8 byte (64 bits)
User-defined
datatype
Symbolic constant or #define
statement
 A name substituted for a variable.
 It’s value cannot be changed during the execution of
program.
 Symbolic constants are also called as C-Preprocessor.
 Also known as compiler directives.
Syntax:
#define symbolicname symbolicConstant
Ex: #define PI 3.142
#define NAME “RAJ”
Operators in C
A symbol to perform some operation on operands.
operand1 operator operand2
1. Arithmetic operator
2. Relational operator
3. Logical operator
4. Assignment operator
5. Increment /decrement operator
6. Conditional operator or ternary operator
7. Bitwise operator
8. Special operator
1. Arithmetic operators
2. Relational operator
3. Logical operator
4. Assignment operator
a=3;
a=a+3;
a+=3;
5. Increment/
decrement operator
6. Conditional operator
“?:”
7. Bitwise operator
Or
8. Special operator

C programming

  • 2.
    Fundamentals • C isa programming language developed at AT & T’s lab. • Designed by Dennis Ritchie. • It is reliable, simple and easy to use. • It is a structured programming language.
  • 3.
    Why bother tolearn “C” • Provides basic programming skills to work further with C++, java, etc. • Many OS are still written in C. • Speed and performance is high. • Mobile devices and consumer devices getting smarter with C programming. • Popular games are built with C language.
  • 4.
    Features of Clanguage  Portability  Modularity  Flexibility  Speed  Extensibility  Compactness  Case sensitive
  • 5.
     Computers wereprogrammed in binary numbers also known as low level. These are machine dependent.  Assembly language came into existence that used assembler as converter. Still were machine dependent.  Later, high level language was introduced which was machine independent.
  • 6.
    Compiling program  Compileris a software program.  It analyzes program and translates for execution.  Program is typed into a file known as source program with name like prog.c which is a valid name.
  • 7.
    Steps for compilation Compiler examines each source program statement.  Checks with syntax or rules and semantics of language.  Error if occurred will be reported to the user.  Compilation process ends there.  Once errors corrected, compiler converts each statement to lower form.  Compilation process converts assembly language to actual machine code called as object code.  After this conversion, it is ready to be linked.  Final linked file is stored in another file ready to be run.
  • 9.
    INTEGRATED DEVELOPMENT ENVIRONMENTS The processof editing, compiling, running and debugging programs is done by single application known as IDE. It is a windows based program. It helps programmers to develop software.
  • 10.
    Language interpreters  Inhigh level languages, interpreters are used.  Interpreter analyzes and executes the statements at the same time.  This method is helpful in debugging programs easily.  It can execute the source code directly.
  • 11.
    Structure of Cprogram • C program has a group of building blocks called functions. • A function is a subroutine that may have one or more statements to perform a certain task. • To write a C program, first create functions.
  • 12.
  • 13.
    Comments serves assome purpose for statement. How to use: /* some comments */ Ex: /*sum*/ Its is not necessary, any number of comments can be written. A multi line comment can be made. Ex: /* this comment has three lines in it */ // this comment has // three lines // in it.
  • 14.
    Any alphabet, digitor special symbol is a character. Alphabets – a,b,c……/A,B,C…. Digits – 0……8, 9 Special symbols- , ; : ? * & ^ and so on
  • 15.
    C tokens Smallest individualunit in a C program is called as a token. integer real character decimal octal Hexadecimal unary binary ternary
  • 17.
  • 18.
    Primary datatype 1 byte(8 bits) 2 byte (16 bits) 4 byte (32 bits) long int 4 byte (32 bits) 8 byte (64 bits)
  • 19.
  • 20.
    Symbolic constant or#define statement  A name substituted for a variable.  It’s value cannot be changed during the execution of program.  Symbolic constants are also called as C-Preprocessor.  Also known as compiler directives. Syntax: #define symbolicname symbolicConstant Ex: #define PI 3.142 #define NAME “RAJ”
  • 21.
    Operators in C Asymbol to perform some operation on operands. operand1 operator operand2 1. Arithmetic operator 2. Relational operator 3. Logical operator 4. Assignment operator 5. Increment /decrement operator 6. Conditional operator or ternary operator 7. Bitwise operator 8. Special operator
  • 22.
    1. Arithmetic operators 2.Relational operator
  • 23.
    3. Logical operator 4.Assignment operator a=3; a=a+3; a+=3;
  • 24.
    5. Increment/ decrement operator 6.Conditional operator “?:”
  • 25.
    7. Bitwise operator Or 8.Special operator