SlideShare a Scribd company logo
Website: www.batracomputercentre.comPh. No.: 8222066670, 4000670
Email: info.jatinbatra@gmail.com
BATRA COMPUTER CENTRE
ISO CERTIFIED 9001:2008
Website: www.batracomputercentre.comPh. No.: 8222066670, 4000670
Email: info.jatinbatra@gmail.com
The C Language
 Currently, the most commonly-used language for embedded
systems
 “High-level assembly”
 Very portable: compilers exist for virtually every processor
 Easy-to-understand compilation
 Produces efficient code
 Fairly concise
Website: www.batracomputercentre.comPh. No.: 8222066670, 4000670
Email: info.jatinbatra@gmail.com
C History
Developed between 1969 and 1973 along with Unix
Due mostly to Dennis Ritchie
Designed for systems programming
 Operating systems
 Utility programs
 Compilers
 Filters
Evolved from B, which evolved from BCPL
Website: www.batracomputercentre.comPh. No.: 8222066670, 4000670
Email: info.jatinbatra@gmail.com
Hello World in C
#include <stdio.h>
Void main ()
{
Printf(“Hello, world !n”);
}
Preprocessor used to
share information
among source files
- Clumsy
+ Cheaply implemented
+ Very flexible
Website: www.batracomputercentre.comPh. No.: 8222066670, 4000670
Email: info.jatinbatra@gmail.com
Hello World in C
#include <stdio.h>
Void main ()
{
Printf(“Hello, world !n”);
}
Program mostly a
collection of functions
“main” function special:
the entry point
“void” qualifier
indicates function does
not return anything
I/O performed by a
library function: not
included in the
language
Website: www.batracomputercentre.comPh. No.: 8222066670, 4000670
Email: info.jatinbatra@gmail.com
Euclid’s algorithm in C
Int gcd(int m, int n)
{
int r ;
while ( (r = m% n) != 0) {
}
return n ;
}
“New Style” function
declaration lists number
and type of arguments
Originally only listed
return type. Generated
code did not care how
many arguments were
actually passed.
Arguments are call-by-
value
Website: www.batracomputercentre.comPh. No.: 8222066670, 4000670
Email: info.jatinbatra@gmail.com
Euclid’s algorithm in C
int gcd(int m, int n)
{
int r;
while ( (r = m % n) != 0) {
m = n;
n = r;
}
return n;
}
Automatic variable
Storage allocated on stack
when function entered,
released when it returns.
All parameters, automatic
variables accessed w.r.t.
frame pointer.
Extra storage needed
while evaluating large
expressions also placed on
the stack
n
m
ret. addr.
r
Frame
pointer Stack
pointer
Excess
arguments
simply
ignored
Website: www.batracomputercentre.comPh. No.: 8222066670, 4000670
Email: info.jatinbatra@gmail.com
Euclid’s algorithm in C
int gcd(int m, int n)
{
int r;
while ( (r = m % n) != 0) {
m = n;
n = r;
}
return n;
}
Expression: C’s basic
type of statement.
Arithmetic and logical
Assignment (=) returns
a value, so can be used
in expressions
% is remainder
!= is not equal
Website: www.batracomputercentre.comPh. No.: 8222066670, 4000670
Email: info.jatinbatra@gmail.com
Euclid’s algorithm in C
int gcd(int m, int n)
{
int r;
while ( (r = m % n) != 0) {
m = n;
n = r;
}
return n;
} Each function returns a
single value, usually an
integer. Returned
through a specific
register by convention.
High-level control-flow
statement. Ultimately
becomes a conditional
branch.
Supports “structured
programming”
Website: www.batracomputercentre.comPh. No.: 8222066670, 4000670
Email: info.jatinbatra@gmail.com
uclid’ Compiled on PDP-1
.globl _gcd r0-r7
.text PC is r7, SP is r6, FP is r5
_gcd:
jsr r5,rsave save sp in frame pointer r5
L2:mov 4(r5),r1 r1 = n
sxt r0 sign extend
div 6(r5),r0 m / n = r0,r1
mov r1,-10(r5) r = m % n
jeq L3
mov 6(r5),4(r5) m = n
mov -10(r5),6(r5) n = r
jbr L2
L3:mov 6(r5),r0 return n in r0
jbr L1
L1:jmp rretrn restore sp ptr, return
int gcd(int m, int n)
{
int r;
while ( (r = m % n) != 0) {
m = n;
n = r;
}
return n;
}
Website: www.batracomputercentre.comPh. No.: 8222066670, 4000670
Email: info.jatinbatra@gmail.com
Pieces of C
 Types and Variables
 Definitions of data in memory
 Expressions
 Arithmetic, logical, and assignment operators in an infix notation
 Statements
 Sequences of conditional, iteration, and branching instructions
 Functions
 Groups of statements and variables invoked recursively
Website: www.batracomputercentre.comPh. No.: 8222066670, 4000670
Email: info.jatinbatra@gmail.com
C Types
Basic types: char, int, float, and double
Meant to match the processor’s native types
 Natural translation into assembly
 Fundamentally nonportable
Declaration syntax: string of specifiers followed by a
declarator
Declarator’s notation matches that in an expression
Access a symbol using its declarator and get the basic type
back
Website: www.batracomputercentre.comPh. No.: 8222066670, 4000670
Email: info.jatinbatra@gmail.com
C StructuresA struct is an object with named fields:
struct {
char *name;
int x, y;
int h, w;
} box;
Accessed using “dot” notation:
box.x = 5;
box.y = 2;
Website: www.batracomputercentre.comPh. No.: 8222066670, 4000670
Email: info.jatinbatra@gmail.com
Struct bit-fields Way to aggressively pack data in memory
struct {
unsigned int baud : 5;
unsigned int div2 : 1;
unsigned int use_external_clock : 1;
} flags;
 Compiler will pack these fields into words
 Very implementation dependent: no guarantees of ordering,
packing, etc.
 Usually less efficient
 Reading a field requires masking and shifting
Website: www.batracomputercentre.comPh. No.: 8222066670, 4000670
Email: info.jatinbatra@gmail.com
C Unions
 Can store objects of different types at different times
union {
int ival;
float fval;
char *sval;
};
 Useful for arrays of dissimilar objects
 Potentially very dangerous
 Good example of C’s philosophy
*Provide powerful mechanisms that can be abused
Website: www.batracomputercentre.comPh. No.: 8222066670, 4000670
Email: info.jatinbatra@gmail.com
Website: www.batracomputercentre.comPh. No.: 8222066670, 4000670
Email: info.jatinbatra@gmail.com
ADDRESS:
SCO -15, Dayal Bagh,
Near Hanuman Mandir
Ambala Cantt-133001
Haryana
Ph. No.: 9729666670, 8222066670 &0171-4000670
Email ID: info.jatinbatra@gmail.com
Website: www.batracomputercentre.com
Website: www.batracomputercentre.comPh. No.: 8222066670, 4000670
Email: info.jatinbatra@gmail.com

More Related Content

PDF
C multiple choice questions and answers pdf
PDF
C mcq practice test 4
PDF
important C questions and_answers praveensomesh
PDF
Sample Paper 2 Class XI (Computer Science)
DOCX
Lab. Programs in C
PDF
Computer Science Sample Paper 2015
PPTX
C Language Training in Ambala ! Batra Computer Centre
PDF
CBSE Question Paper Computer Science with C++ 2011
C multiple choice questions and answers pdf
C mcq practice test 4
important C questions and_answers praveensomesh
Sample Paper 2 Class XI (Computer Science)
Lab. Programs in C
Computer Science Sample Paper 2015
C Language Training in Ambala ! Batra Computer Centre
CBSE Question Paper Computer Science with C++ 2011

What's hot (20)

DOCX
Exam for c
PPTX
Technical aptitude test 2 CSE
DOCX
C programming Lab 1
PPTX
Technical aptitude Test 1 CSE
PPTX
Simple c program
PDF
Sample Paper Class XI (Informatics Practices)
PDF
IP Sample paper 2 Class XI
DOCX
Important C program of Balagurusamy Book
PDF
Lec14-CS110 Computational Engineering
DOCX
C __paper.docx_final
PPT
PPTX
Seminar 2 coding_principles
PDF
Loan-defaulters-predictions(Python codes)
PDF
FP305 data structure june 2012
PDF
C- Programming Assignment 3
DOC
programming in C++ report
DOC
C lab-programs
PPT
Functions & Procedures [7]
PDF
C mcq practice test 1
DOCX
(Www.entrance exam.net)-tcs placement sample paper 2
Exam for c
Technical aptitude test 2 CSE
C programming Lab 1
Technical aptitude Test 1 CSE
Simple c program
Sample Paper Class XI (Informatics Practices)
IP Sample paper 2 Class XI
Important C program of Balagurusamy Book
Lec14-CS110 Computational Engineering
C __paper.docx_final
Seminar 2 coding_principles
Loan-defaulters-predictions(Python codes)
FP305 data structure june 2012
C- Programming Assignment 3
programming in C++ report
C lab-programs
Functions & Procedures [7]
C mcq practice test 1
(Www.entrance exam.net)-tcs placement sample paper 2
Ad

Viewers also liked (15)

PPTX
Computer Learning Point in Ambala ! Batra Computer Centre
PPTX
Ms Word Training Institute in Ambala ! Batra Computer Centre
PPTX
SEO Services in Ambala ! Batra Computer Centre
PDF
6 Week Computer Training In Ambala! Batra Computer Centre
PPTX
C & C++ Training in Ambala ! BATRA COMPUTER CENTRE
PDF
Tesis cuarta parte
PPTX
Photoshop Training in Ambala ! Batra Computer Centre
PPTX
Basic Computer Training in Ambala ! Batra Computer Centre
PPTX
C++ Programming Language Training in Ambala ! Batra Computer Centre
PPTX
Ms Word Training in Ambala ! Batra Computer Centre
DOC
6 Weeks Project Based Summer Training
PDF
Incremental Subdivision for Triangle Meshes
PPTX
SQL Training in Ambala ! Batra Computer Centre
PDF
La información al servicio de la investigación 2015
PPTX
Dental phobia
Computer Learning Point in Ambala ! Batra Computer Centre
Ms Word Training Institute in Ambala ! Batra Computer Centre
SEO Services in Ambala ! Batra Computer Centre
6 Week Computer Training In Ambala! Batra Computer Centre
C & C++ Training in Ambala ! BATRA COMPUTER CENTRE
Tesis cuarta parte
Photoshop Training in Ambala ! Batra Computer Centre
Basic Computer Training in Ambala ! Batra Computer Centre
C++ Programming Language Training in Ambala ! Batra Computer Centre
Ms Word Training in Ambala ! Batra Computer Centre
6 Weeks Project Based Summer Training
Incremental Subdivision for Triangle Meshes
SQL Training in Ambala ! Batra Computer Centre
La información al servicio de la investigación 2015
Dental phobia
Ad

Similar to C Programming Training In Ambala ! BATRA COMPUTER CENTRE (20)

PPT
C language
PPT
C language
PPT
Clanguage
PPTX
C Programming language
PPT
Clanguage
PPT
anjaan007
PPT
PPT
Introduction to c language and its application.ppt
PPTX
High performance computing seminar1.pptx
DOCX
Report on c and c++
PDF
Oh Crap, I Forgot (Or Never Learned) C! [CodeMash 2010]
PPTX
C language
PPTX
C programming language
PDF
Essential c
PDF
Essential c
PDF
Essential c
PDF
Essential c notes singh projects
PDF
Essential c
C language
C language
Clanguage
C Programming language
Clanguage
anjaan007
Introduction to c language and its application.ppt
High performance computing seminar1.pptx
Report on c and c++
Oh Crap, I Forgot (Or Never Learned) C! [CodeMash 2010]
C language
C programming language
Essential c
Essential c
Essential c
Essential c notes singh projects
Essential c

More from jatin batra (20)

PDF
Best SMO Training &Coaching in Ambala
PDF
Best HTML Training &Coaching in Ambala
PDF
Best SEO Training & Coaching in Ambala
PDF
Best Photoshop Training in Ambala
PDF
Best C Programming Training & Coaching in Ambala
PDF
BASIC COMPUTER TRAINING & COACHING CENTRE IN AMBALA CANTT
PPTX
Web Browser ! Batra Computer Centre
PPTX
Search Engine Training in Ambala ! Batra Computer Centre
PPTX
Networking Training in Ambala ! Batra Computer Centre
PPTX
SQL Training in Ambala ! BATRA COMPUTER CENTRE
PPTX
Networking ! BATRA COMPUTER CENTRE
PPTX
Ms Office 2010 Training in Ambala ! BATRA COMPUTER CENTRE
PPTX
Basic Computer Training Centre in Ambala ! BATRA COMPUTER CENTRE
PPTX
Corel Draw Training Institute in Ambala ! BATRA COMPUTER CENTRE
PPTX
Basic Computer Training Institute ! BATRA COMPUTER CENTRE
PPTX
HTML Training Institute in Ambala ! Batra Computer Centre
PPTX
Benefits of Web Browser ! Batra Computer Centre
PPTX
SEO Training in Ambala ! Batra Computer Centre
PPTX
Internet Training Centre in Ambala ! Batra Computer Centre
PPTX
Basic Computer Training Centre in Ambala ! Batra Computer Centre
Best SMO Training &Coaching in Ambala
Best HTML Training &Coaching in Ambala
Best SEO Training & Coaching in Ambala
Best Photoshop Training in Ambala
Best C Programming Training & Coaching in Ambala
BASIC COMPUTER TRAINING & COACHING CENTRE IN AMBALA CANTT
Web Browser ! Batra Computer Centre
Search Engine Training in Ambala ! Batra Computer Centre
Networking Training in Ambala ! Batra Computer Centre
SQL Training in Ambala ! BATRA COMPUTER CENTRE
Networking ! BATRA COMPUTER CENTRE
Ms Office 2010 Training in Ambala ! BATRA COMPUTER CENTRE
Basic Computer Training Centre in Ambala ! BATRA COMPUTER CENTRE
Corel Draw Training Institute in Ambala ! BATRA COMPUTER CENTRE
Basic Computer Training Institute ! BATRA COMPUTER CENTRE
HTML Training Institute in Ambala ! Batra Computer Centre
Benefits of Web Browser ! Batra Computer Centre
SEO Training in Ambala ! Batra Computer Centre
Internet Training Centre in Ambala ! Batra Computer Centre
Basic Computer Training Centre in Ambala ! Batra Computer Centre

Recently uploaded (20)

PPTX
Microbial diseases, their pathogenesis and prophylaxis
PDF
Anesthesia in Laparoscopic Surgery in India
PPTX
202450812 BayCHI UCSC-SV 20250812 v17.pptx
PPTX
UV-Visible spectroscopy..pptx UV-Visible Spectroscopy – Electronic Transition...
PDF
A systematic review of self-coping strategies used by university students to ...
PPTX
Tissue processing ( HISTOPATHOLOGICAL TECHNIQUE
PPTX
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
PDF
Paper A Mock Exam 9_ Attempt review.pdf.
PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PDF
Computing-Curriculum for Schools in Ghana
PDF
LDMMIA Reiki Yoga Finals Review Spring Summer
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PPTX
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
PDF
What if we spent less time fighting change, and more time building what’s rig...
PPTX
Orientation - ARALprogram of Deped to the Parents.pptx
PDF
01-Introduction-to-Information-Management.pdf
PDF
RMMM.pdf make it easy to upload and study
PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PDF
Practical Manual AGRO-233 Principles and Practices of Natural Farming
PDF
Supply Chain Operations Speaking Notes -ICLT Program
Microbial diseases, their pathogenesis and prophylaxis
Anesthesia in Laparoscopic Surgery in India
202450812 BayCHI UCSC-SV 20250812 v17.pptx
UV-Visible spectroscopy..pptx UV-Visible Spectroscopy – Electronic Transition...
A systematic review of self-coping strategies used by university students to ...
Tissue processing ( HISTOPATHOLOGICAL TECHNIQUE
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
Paper A Mock Exam 9_ Attempt review.pdf.
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
Computing-Curriculum for Schools in Ghana
LDMMIA Reiki Yoga Finals Review Spring Summer
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
What if we spent less time fighting change, and more time building what’s rig...
Orientation - ARALprogram of Deped to the Parents.pptx
01-Introduction-to-Information-Management.pdf
RMMM.pdf make it easy to upload and study
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
Practical Manual AGRO-233 Principles and Practices of Natural Farming
Supply Chain Operations Speaking Notes -ICLT Program

C Programming Training In Ambala ! BATRA COMPUTER CENTRE

  • 1. Website: www.batracomputercentre.comPh. No.: 8222066670, 4000670 Email: info.jatinbatra@gmail.com BATRA COMPUTER CENTRE ISO CERTIFIED 9001:2008
  • 2. Website: www.batracomputercentre.comPh. No.: 8222066670, 4000670 Email: info.jatinbatra@gmail.com The C Language  Currently, the most commonly-used language for embedded systems  “High-level assembly”  Very portable: compilers exist for virtually every processor  Easy-to-understand compilation  Produces efficient code  Fairly concise
  • 3. Website: www.batracomputercentre.comPh. No.: 8222066670, 4000670 Email: info.jatinbatra@gmail.com C History Developed between 1969 and 1973 along with Unix Due mostly to Dennis Ritchie Designed for systems programming  Operating systems  Utility programs  Compilers  Filters Evolved from B, which evolved from BCPL
  • 4. Website: www.batracomputercentre.comPh. No.: 8222066670, 4000670 Email: info.jatinbatra@gmail.com Hello World in C #include <stdio.h> Void main () { Printf(“Hello, world !n”); } Preprocessor used to share information among source files - Clumsy + Cheaply implemented + Very flexible
  • 5. Website: www.batracomputercentre.comPh. No.: 8222066670, 4000670 Email: info.jatinbatra@gmail.com Hello World in C #include <stdio.h> Void main () { Printf(“Hello, world !n”); } Program mostly a collection of functions “main” function special: the entry point “void” qualifier indicates function does not return anything I/O performed by a library function: not included in the language
  • 6. Website: www.batracomputercentre.comPh. No.: 8222066670, 4000670 Email: info.jatinbatra@gmail.com Euclid’s algorithm in C Int gcd(int m, int n) { int r ; while ( (r = m% n) != 0) { } return n ; } “New Style” function declaration lists number and type of arguments Originally only listed return type. Generated code did not care how many arguments were actually passed. Arguments are call-by- value
  • 7. Website: www.batracomputercentre.comPh. No.: 8222066670, 4000670 Email: info.jatinbatra@gmail.com Euclid’s algorithm in C int gcd(int m, int n) { int r; while ( (r = m % n) != 0) { m = n; n = r; } return n; } Automatic variable Storage allocated on stack when function entered, released when it returns. All parameters, automatic variables accessed w.r.t. frame pointer. Extra storage needed while evaluating large expressions also placed on the stack n m ret. addr. r Frame pointer Stack pointer Excess arguments simply ignored
  • 8. Website: www.batracomputercentre.comPh. No.: 8222066670, 4000670 Email: info.jatinbatra@gmail.com Euclid’s algorithm in C int gcd(int m, int n) { int r; while ( (r = m % n) != 0) { m = n; n = r; } return n; } Expression: C’s basic type of statement. Arithmetic and logical Assignment (=) returns a value, so can be used in expressions % is remainder != is not equal
  • 9. Website: www.batracomputercentre.comPh. No.: 8222066670, 4000670 Email: info.jatinbatra@gmail.com Euclid’s algorithm in C int gcd(int m, int n) { int r; while ( (r = m % n) != 0) { m = n; n = r; } return n; } Each function returns a single value, usually an integer. Returned through a specific register by convention. High-level control-flow statement. Ultimately becomes a conditional branch. Supports “structured programming”
  • 10. Website: www.batracomputercentre.comPh. No.: 8222066670, 4000670 Email: info.jatinbatra@gmail.com uclid’ Compiled on PDP-1 .globl _gcd r0-r7 .text PC is r7, SP is r6, FP is r5 _gcd: jsr r5,rsave save sp in frame pointer r5 L2:mov 4(r5),r1 r1 = n sxt r0 sign extend div 6(r5),r0 m / n = r0,r1 mov r1,-10(r5) r = m % n jeq L3 mov 6(r5),4(r5) m = n mov -10(r5),6(r5) n = r jbr L2 L3:mov 6(r5),r0 return n in r0 jbr L1 L1:jmp rretrn restore sp ptr, return int gcd(int m, int n) { int r; while ( (r = m % n) != 0) { m = n; n = r; } return n; }
  • 11. Website: www.batracomputercentre.comPh. No.: 8222066670, 4000670 Email: info.jatinbatra@gmail.com Pieces of C  Types and Variables  Definitions of data in memory  Expressions  Arithmetic, logical, and assignment operators in an infix notation  Statements  Sequences of conditional, iteration, and branching instructions  Functions  Groups of statements and variables invoked recursively
  • 12. Website: www.batracomputercentre.comPh. No.: 8222066670, 4000670 Email: info.jatinbatra@gmail.com C Types Basic types: char, int, float, and double Meant to match the processor’s native types  Natural translation into assembly  Fundamentally nonportable Declaration syntax: string of specifiers followed by a declarator Declarator’s notation matches that in an expression Access a symbol using its declarator and get the basic type back
  • 13. Website: www.batracomputercentre.comPh. No.: 8222066670, 4000670 Email: info.jatinbatra@gmail.com C StructuresA struct is an object with named fields: struct { char *name; int x, y; int h, w; } box; Accessed using “dot” notation: box.x = 5; box.y = 2;
  • 14. Website: www.batracomputercentre.comPh. No.: 8222066670, 4000670 Email: info.jatinbatra@gmail.com Struct bit-fields Way to aggressively pack data in memory struct { unsigned int baud : 5; unsigned int div2 : 1; unsigned int use_external_clock : 1; } flags;  Compiler will pack these fields into words  Very implementation dependent: no guarantees of ordering, packing, etc.  Usually less efficient  Reading a field requires masking and shifting
  • 15. Website: www.batracomputercentre.comPh. No.: 8222066670, 4000670 Email: info.jatinbatra@gmail.com C Unions  Can store objects of different types at different times union { int ival; float fval; char *sval; };  Useful for arrays of dissimilar objects  Potentially very dangerous  Good example of C’s philosophy *Provide powerful mechanisms that can be abused
  • 16. Website: www.batracomputercentre.comPh. No.: 8222066670, 4000670 Email: info.jatinbatra@gmail.com
  • 17. Website: www.batracomputercentre.comPh. No.: 8222066670, 4000670 Email: info.jatinbatra@gmail.com ADDRESS: SCO -15, Dayal Bagh, Near Hanuman Mandir Ambala Cantt-133001 Haryana Ph. No.: 9729666670, 8222066670 &0171-4000670 Email ID: info.jatinbatra@gmail.com Website: www.batracomputercentre.com
  • 18. Website: www.batracomputercentre.comPh. No.: 8222066670, 4000670 Email: info.jatinbatra@gmail.com