SlideShare a Scribd company logo
Ph. No.: 8222066670, 4000670
Email: info.jatinbatra@gmail.com
Website: www.batracomputercentre.com
BATRA COMPUTER CENTRE
ISO CERTIFIED 9001:2008
• 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
Ph. No.: 8222066670, 4000670
Email: info.jatinbatra@gmail.com
Website: www.batracomputercentre.com
• 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 BCPLPh. No.: 8222066670, 4000670
Email: info.jatinbatra@gmail.com
Website: www.batracomputercentre.com
#include <stdio.h>
void main()
{
printf(“Hello,
world!n”);
}
Preprocessor used to
share information among
source files
- Clumsy
+ Cheaply implemented
+ Very flexible
Ph. No.: 8222066670, 4000670
Email: info.jatinbatra@gmail.com
Website: www.batracomputercentre.com
#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
Ph. No.: 8222066670, 4000670
Email: info.jatinbatra@gmail.com
Website: www.batracomputercentre.com
int gcd(int m, int n)
{
int r;
while ( (r = m % n) != 0)
{
m = n;
n = r;
}
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
Ph. No.: 8222066670, 4000670
Email: info.jatinbatra@gmail.com
Website: www.batracomputercentre.com
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
Ph. No.: 8222066670, 4000670
Email: info.jatinbatra@gmail.com
Website: www.batracomputercentre.com
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
Ph. No.: 8222066670, 4000670
Email: info.jatinbatra@gmail.com
Website: www.batracomputercentre.com
int gcd(int m, int n)
{
int r;
while ( (r = m % n) != 0) {
m = n;
n = r;
}
return n;
}
High-level control-flow statement.
Ultimately becomes a conditional
branch.
Supports “structured
programming”
Each function returns a
single value, usually an
integer. Returned
through a specific
register by convention.
Ph. No.: 8222066670, 4000670
Email: info.jatinbatra@gmail.com
Website: www.batracomputercentre.com
.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;
}
Ph. No.: 8222066670, 4000670
Email: info.jatinbatra@gmail.com
Website: www.batracomputercentre.com
.globl _gcd
.text
_gcd:
jsr r5,rsave
L2:mov 4(r5),r1
sxt r0
div 6(r5),r0
mov r1,-10(r5)
jeq L3
mov 6(r5),4(r5)
mov -10(r5),6(r5)
jbr L2
L3:mov 6(r5),r0
jbr L1
L1:jmp rretrn
Very natural mapping from C into
PDP-11 instructions.
Complex addressing modes make
frame-pointer-relative accesses
easy.
Another idiosyncrasy: registers
were memory-mapped, so taking
address of a variable in a register
is straightforward.
Ph. No.: 8222066670, 4000670
Email: info.jatinbatra@gmail.com
Website: www.batracomputercentre.com
• 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 invokedPh. No.: 8222066670, 4000670
Email: info.jatinbatra@gmail.com
Website: www.batracomputercentre.com
• 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 backPh. No.: 8222066670, 4000670
Email: info.jatinbatra@gmail.com
Website: www.batracomputercentre.com
int i;
int *j, k;
unsigned char *ch;
float f[10];
char nextChar(int,
char*);
int a[3][5][10];
int *func1(float);
int (*func2)(void);
Integer
j: pointer to integer, int k
ch: pointer to unsigned char
Array of 10 floats
2-arg function
Array of three arrays of five …
function returning int *
pointer to function returning int
Ph. No.: 8222066670, 4000670
Email: info.jatinbatra@gmail.com
Website: www.batracomputercentre.com
• Type declarations recursive,
complicated.
• Name new types with typedef
• Instead of
int (*func2)(void)
use
typedef int afunc2t(void);
func2t *func2;
Ph. No.: 8222066670, 4000670
Email: info.jatinbatra@gmail.com
Website: www.batracomputercentre.com
• A 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;
Ph. No.: 8222066670, 4000670
Email: info.jatinbatra@gmail.com
Website: www.batracomputercentre.com
• 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 shiftingPh. No.: 8222066670, 4000670
Email: info.jatinbatra@gmail.com
Website: www.batracomputercentre.com
• 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
Ph. No.: 8222066670, 4000670
Email: info.jatinbatra@gmail.com
Website: www.batracomputercentre.com
• Most processors require n-byte objects to be in
memory at address n*k
• Side effect of wide memory busses
• E.g., a 32-bit memory bus
• Read from address 3 requires two accesses,
shifting
4 3 2
1
4 3 2 1
Ph. No.: 8222066670, 4000670
Email: info.jatinbatra@gmail.com
Website: www.batracomputercentre.com
• Compilers add “padding” to structs to ensure proper
alignment, especially for arrays
• Pad to ensure alignment of largest object (with biggest
requirement)
struct {
char a;
int b;
char c;
}
a
bbbb
c
a
bbbb
c
Pad
Ph. No.: 8222066670, 4000670
Email: info.jatinbatra@gmail.com
Website: www.batracomputercentre.com
#include <stdlib.h>
int global_static;
static int file_static;
void foo(int auto_param)
{
static int func_static;
int auto_i, auto_a[10];
double *auto_d = malloc(sizeof(double)*5);
}
Linker-visible.
Allocated at fixed
location
Visible within file.
Allocated at fixed
location.
Visible within func.
Allocated at fixed
location.
Ph. No.: 8222066670, 4000670
Email: info.jatinbatra@gmail.com
Website: www.batracomputercentre.com
#include <stdlib.h>
int global_static;
static int file_static;
void foo(int auto_param)
{
static int func_static;
int auto_i, auto_a[10];
double *auto_d =
malloc(sizeof(double)*5);
}
Space allocated on
stack by function.
Space allocated on
stack by caller.
Space allocated on heap by
library routine.
Ph. No.: 8222066670, 4000670
Email: info.jatinbatra@gmail.com
Website: www.batracomputercentre.com
• Array: sequence of identical
objects in memory
• int a[10]; means space for ten
integers
 By itself, a is the address of the first integer
 *a and a[0] mean the same thing
 The address of a is not stored in memory: the
compiler inserts code to compute it when it
appears
 Ritchie calls this interpretation the biggest
conceptual jump from BCPL to C
Ph. No.: 8222066670, 4000670
Email: info.jatinbatra@gmail.com
Website: www.batracomputercentre.com
• Traditional mathematical expressions
y = a*x*x + b*x + c;
• Very rich set of expressions
• Able to deal with arithmetic and bit
manipulation
Ph. No.: 8222066670, 4000670
Email: info.jatinbatra@gmail.com
Website: www.batracomputercentre.com
• arithmetic: + – * / %
• comparison: == != < <= > >=
• bitwise logical: & | ^ ~
• shifting: << >>
• lazy logical: && || !
• conditional: ? :
• assignment: = += -=
• increment/decrement: ++ --
• sequencing: ,
• pointer: * -> & []
Ph. No.: 8222066670, 4000670
Email: info.jatinbatra@gmail.com
Website: www.batracomputercentre.com
• c = a < b ? a + 1 : b – 1;
• Evaluate first expression. If true, evaluate
second, otherwise evaluate third.
• Puts almost statement-like behavior in
expressions.
• BCPL allowed code in an expression:
a := 5 + valof{ int i, s = 0; for (i = 0 ; i < 10 ; i++)
s += a[I];
return s; }
Ph. No.: 8222066670, 4000670
Email: info.jatinbatra@gmail.com
Website: www.batracomputercentre.com
• From BCPL’s view of the world
• Pointer arithmetic is natural: everything’s an
integer
int *p, *q;
*(p+5) equivalent to p[5]
• If p and q point into same array, p – q is number
of elements between p and q.
• Accessing fields of a pointed-to structure has a
shorthand:
p->field means (*p).field
Ph. No.: 8222066670, 4000670
Email: info.jatinbatra@gmail.com
Website: www.batracomputercentre.com
• Expression
• Conditional
– if (expr) { … } else {…}
– switch (expr) { case c1: case c2: … }
• Iteration
– while (expr) { … } zero or more
iterations
– do … while (expr) at least one
iteration
– for ( init ; valid ; next ) { … }
• Jump
– goto label
– continue; go to start of loop
– break; exit loop or switch
– return expr; return from function
Ph. No.: 8222066670, 4000670
Email: info.jatinbatra@gmail.com
Website: www.batracomputercentre.com
Ph. No.: 8222066670, 4000670
Email: info.jatinbatra@gmail.com
Website: www.batracomputercentre.com
ADDRESS:
SCO -15, Dayal Bagh,
Near Hanuman Mandir
Ambala Cantt-13300, Haryana
Ph. No.: 9729666670, 8222066670 &0171-4000670
Email ID: info.jatinbatra@gmail.com
Website: www.batracomputercentre.com
Ph. No.: 8222066670, 4000670
Email: info.jatinbatra@gmail.com
Website: www.batracomputercentre.com
Ph. No.: 8222066670, 4000670
Email: info.jatinbatra@gmail.com
Website: www.batracomputercentre.com

More Related Content

Similar to C Language Training in Ambala ! Batra Computer Centre

C++ Programming Language Training in Ambala ! Batra Computer Centre
C++ Programming Language Training in Ambala ! Batra Computer CentreC++ Programming Language Training in Ambala ! Batra Computer Centre
C++ Programming Language Training in Ambala ! Batra Computer Centre
jatin batra
 
C Programming Training in Ambala ! Batra Computer Centre
C Programming Training in Ambala ! Batra Computer CentreC Programming Training in Ambala ! Batra Computer Centre
C Programming Training in Ambala ! Batra Computer Centre
jatin batra
 
45 Days C Language Training In Ambala! Batra Computer Centre
45 Days C Language Training In Ambala! Batra Computer Centre45 Days C Language Training In Ambala! Batra Computer Centre
45 Days C Language Training In Ambala! Batra Computer Centre
jatin batra
 
C programming Training Institute in Ambala ! Batra Computer Centre
C programming Training Institute in Ambala ! Batra Computer CentreC programming Training Institute in Ambala ! Batra Computer Centre
C programming Training Institute in Ambala ! Batra Computer Centre
jatin batra
 
C Language Training in Ambala ! Batra Computer Centre
C Language Training in Ambala ! Batra Computer CentreC Language Training in Ambala ! Batra Computer Centre
C Language Training in Ambala ! Batra Computer Centre
jatin batra
 
Modern C++
Modern C++Modern C++
Modern C++
Michael Clark
 
45 Days C++ Programming Language Training in Ambala
45 Days C++ Programming Language Training in Ambala45 Days C++ Programming Language Training in Ambala
45 Days C++ Programming Language Training in Ambala
jatin batra
 
Learn c++ Programming Language
Learn c++ Programming LanguageLearn c++ Programming Language
Learn c++ Programming Language
Steve Johnson
 
Data type
Data typeData type
Data type
myrajendra
 
Writing good std::future&lt;c++>
Writing good std::future&lt;c++>Writing good std::future&lt;c++>
Writing good std::future&lt;c++>
corehard_by
 
Writing good std::future&lt;c++>
Writing good std::future&lt;c++>Writing good std::future&lt;c++>
Writing good std::future&lt;c++>
Anton Bikineev
 
Patterns of 64-bit errors in games
Patterns of 64-bit errors in gamesPatterns of 64-bit errors in games
Patterns of 64-bit errors in games
Andrey Karpov
 
Tech talks#6: Code Refactoring
Tech talks#6: Code RefactoringTech talks#6: Code Refactoring
Tech talks#6: Code Refactoring
Nguyễn Việt Khoa
 
Intro To C++ - Class #17: Pointers!, Objects Talking To Each Other
Intro To C++ - Class #17: Pointers!, Objects Talking To Each OtherIntro To C++ - Class #17: Pointers!, Objects Talking To Each Other
Intro To C++ - Class #17: Pointers!, Objects Talking To Each Other
Blue Elephant Consulting
 
Basic Computer Training Centre in Ambala ! Batra Computer Centre
Basic Computer Training Centre in Ambala ! Batra Computer CentreBasic Computer Training Centre in Ambala ! Batra Computer Centre
Basic Computer Training Centre in Ambala ! Batra Computer Centre
jatin batra
 
Big Data-Driven Applications with Cassandra and Spark
Big Data-Driven Applications  with Cassandra and SparkBig Data-Driven Applications  with Cassandra and Spark
Big Data-Driven Applications with Cassandra and Spark
Artem Chebotko
 
Old code doesn't stink
Old code doesn't stinkOld code doesn't stink
Old code doesn't stink
Martin Gutenbrunner
 
C++ process new
C++ process newC++ process new
C++ process new
敬倫 林
 
Efficient Data Storage for Analytics with Parquet 2.0 - Hadoop Summit 2014
Efficient Data Storage for Analytics with Parquet 2.0 - Hadoop Summit 2014Efficient Data Storage for Analytics with Parquet 2.0 - Hadoop Summit 2014
Efficient Data Storage for Analytics with Parquet 2.0 - Hadoop Summit 2014
Julien Le Dem
 
Efficient Data Storage for Analytics with Apache Parquet 2.0
Efficient Data Storage for Analytics with Apache Parquet 2.0Efficient Data Storage for Analytics with Apache Parquet 2.0
Efficient Data Storage for Analytics with Apache Parquet 2.0
Cloudera, Inc.
 

Similar to C Language Training in Ambala ! Batra Computer Centre (20)

C++ Programming Language Training in Ambala ! Batra Computer Centre
C++ Programming Language Training in Ambala ! Batra Computer CentreC++ Programming Language Training in Ambala ! Batra Computer Centre
C++ Programming Language Training in Ambala ! Batra Computer Centre
 
C Programming Training in Ambala ! Batra Computer Centre
C Programming Training in Ambala ! Batra Computer CentreC Programming Training in Ambala ! Batra Computer Centre
C Programming Training in Ambala ! Batra Computer Centre
 
45 Days C Language Training In Ambala! Batra Computer Centre
45 Days C Language Training In Ambala! Batra Computer Centre45 Days C Language Training In Ambala! Batra Computer Centre
45 Days C Language Training In Ambala! Batra Computer Centre
 
C programming Training Institute in Ambala ! Batra Computer Centre
C programming Training Institute in Ambala ! Batra Computer CentreC programming Training Institute in Ambala ! Batra Computer Centre
C programming Training Institute in Ambala ! Batra Computer Centre
 
C Language Training in Ambala ! Batra Computer Centre
C Language Training in Ambala ! Batra Computer CentreC Language Training in Ambala ! Batra Computer Centre
C Language Training in Ambala ! Batra Computer Centre
 
Modern C++
Modern C++Modern C++
Modern C++
 
45 Days C++ Programming Language Training in Ambala
45 Days C++ Programming Language Training in Ambala45 Days C++ Programming Language Training in Ambala
45 Days C++ Programming Language Training in Ambala
 
Learn c++ Programming Language
Learn c++ Programming LanguageLearn c++ Programming Language
Learn c++ Programming Language
 
Data type
Data typeData type
Data type
 
Writing good std::future&lt;c++>
Writing good std::future&lt;c++>Writing good std::future&lt;c++>
Writing good std::future&lt;c++>
 
Writing good std::future&lt;c++>
Writing good std::future&lt;c++>Writing good std::future&lt;c++>
Writing good std::future&lt;c++>
 
Patterns of 64-bit errors in games
Patterns of 64-bit errors in gamesPatterns of 64-bit errors in games
Patterns of 64-bit errors in games
 
Tech talks#6: Code Refactoring
Tech talks#6: Code RefactoringTech talks#6: Code Refactoring
Tech talks#6: Code Refactoring
 
Intro To C++ - Class #17: Pointers!, Objects Talking To Each Other
Intro To C++ - Class #17: Pointers!, Objects Talking To Each OtherIntro To C++ - Class #17: Pointers!, Objects Talking To Each Other
Intro To C++ - Class #17: Pointers!, Objects Talking To Each Other
 
Basic Computer Training Centre in Ambala ! Batra Computer Centre
Basic Computer Training Centre in Ambala ! Batra Computer CentreBasic Computer Training Centre in Ambala ! Batra Computer Centre
Basic Computer Training Centre in Ambala ! Batra Computer Centre
 
Big Data-Driven Applications with Cassandra and Spark
Big Data-Driven Applications  with Cassandra and SparkBig Data-Driven Applications  with Cassandra and Spark
Big Data-Driven Applications with Cassandra and Spark
 
Old code doesn't stink
Old code doesn't stinkOld code doesn't stink
Old code doesn't stink
 
C++ process new
C++ process newC++ process new
C++ process new
 
Efficient Data Storage for Analytics with Parquet 2.0 - Hadoop Summit 2014
Efficient Data Storage for Analytics with Parquet 2.0 - Hadoop Summit 2014Efficient Data Storage for Analytics with Parquet 2.0 - Hadoop Summit 2014
Efficient Data Storage for Analytics with Parquet 2.0 - Hadoop Summit 2014
 
Efficient Data Storage for Analytics with Apache Parquet 2.0
Efficient Data Storage for Analytics with Apache Parquet 2.0Efficient Data Storage for Analytics with Apache Parquet 2.0
Efficient Data Storage for Analytics with Apache Parquet 2.0
 

More from jatin batra

Best SMO Training &Coaching in Ambala
Best SMO Training &Coaching in AmbalaBest SMO Training &Coaching in Ambala
Best SMO Training &Coaching in Ambala
jatin batra
 
Best HTML Training &Coaching in Ambala
Best HTML Training &Coaching in AmbalaBest HTML Training &Coaching in Ambala
Best HTML Training &Coaching in Ambala
jatin batra
 
Best SEO Training & Coaching in Ambala
Best SEO Training & Coaching in AmbalaBest SEO Training & Coaching in Ambala
Best SEO Training & Coaching in Ambala
jatin batra
 
Best Photoshop Training in Ambala
 Best Photoshop Training  in Ambala Best Photoshop Training  in Ambala
Best Photoshop Training in Ambala
jatin batra
 
Best C Programming Training & Coaching in Ambala
Best C Programming Training & Coaching in AmbalaBest C Programming Training & Coaching in Ambala
Best C Programming Training & Coaching in Ambala
jatin batra
 
BASIC COMPUTER TRAINING & COACHING CENTRE IN AMBALA CANTT
BASIC COMPUTER TRAINING & COACHING CENTRE IN AMBALA CANTTBASIC COMPUTER TRAINING & COACHING CENTRE IN AMBALA CANTT
BASIC COMPUTER TRAINING & COACHING CENTRE IN AMBALA CANTT
jatin batra
 
Web Browser ! Batra Computer Centre
Web Browser ! Batra Computer CentreWeb Browser ! Batra Computer Centre
Web Browser ! Batra Computer Centre
jatin batra
 
Search Engine Training in Ambala ! Batra Computer Centre
Search Engine Training in Ambala ! Batra Computer CentreSearch Engine Training in Ambala ! Batra Computer Centre
Search Engine Training in Ambala ! Batra Computer Centre
jatin batra
 
Networking Training in Ambala ! Batra Computer Centre
Networking Training in Ambala ! Batra Computer CentreNetworking Training in Ambala ! Batra Computer Centre
Networking Training in Ambala ! Batra Computer Centre
jatin batra
 
SQL Training in Ambala ! BATRA COMPUTER CENTRE
SQL Training in Ambala ! BATRA COMPUTER CENTRESQL Training in Ambala ! BATRA COMPUTER CENTRE
SQL Training in Ambala ! BATRA COMPUTER CENTRE
jatin batra
 
Networking ! BATRA COMPUTER CENTRE
Networking ! BATRA COMPUTER CENTRENetworking ! BATRA COMPUTER CENTRE
Networking ! BATRA COMPUTER CENTRE
jatin batra
 
Ms Office 2010 Training in Ambala ! BATRA COMPUTER CENTRE
Ms Office 2010 Training in Ambala ! BATRA COMPUTER CENTREMs Office 2010 Training in Ambala ! BATRA COMPUTER CENTRE
Ms Office 2010 Training in Ambala ! BATRA COMPUTER CENTRE
jatin batra
 
Basic Computer Training Centre in Ambala ! BATRA COMPUTER CENTRE
Basic Computer Training Centre in Ambala ! BATRA COMPUTER CENTREBasic Computer Training Centre in Ambala ! BATRA COMPUTER CENTRE
Basic Computer Training Centre in Ambala ! BATRA COMPUTER CENTRE
jatin batra
 
Corel Draw Training Institute in Ambala ! BATRA COMPUTER CENTRE
Corel Draw Training Institute in Ambala ! BATRA COMPUTER CENTRECorel Draw Training Institute in Ambala ! BATRA COMPUTER CENTRE
Corel Draw Training Institute in Ambala ! BATRA COMPUTER CENTRE
jatin batra
 
Basic Computer Training Institute ! BATRA COMPUTER CENTRE
Basic Computer Training Institute ! BATRA COMPUTER CENTREBasic Computer Training Institute ! BATRA COMPUTER CENTRE
Basic Computer Training Institute ! BATRA COMPUTER CENTRE
jatin batra
 
HTML Training Institute in Ambala ! Batra Computer Centre
HTML Training Institute in Ambala ! Batra Computer CentreHTML Training Institute in Ambala ! Batra Computer Centre
HTML Training Institute in Ambala ! Batra Computer Centre
jatin batra
 
Benefits of Web Browser ! Batra Computer Centre
Benefits of Web Browser ! Batra Computer CentreBenefits of Web Browser ! Batra Computer Centre
Benefits of Web Browser ! Batra Computer Centre
jatin batra
 
SEO Training in Ambala ! Batra Computer Centre
SEO Training in Ambala ! Batra Computer CentreSEO Training in Ambala ! Batra Computer Centre
SEO Training in Ambala ! Batra Computer Centre
jatin batra
 
Internet Training Centre in Ambala ! Batra Computer Centre
Internet Training Centre in Ambala ! Batra Computer CentreInternet Training Centre in Ambala ! Batra Computer Centre
Internet Training Centre in Ambala ! Batra Computer Centre
jatin batra
 
Web Designing Training in Ambala ! Batra Computer Centre
Web Designing Training in Ambala ! Batra Computer CentreWeb Designing Training in Ambala ! Batra Computer Centre
Web Designing Training in Ambala ! Batra Computer Centre
jatin batra
 

More from jatin batra (20)

Best SMO Training &Coaching in Ambala
Best SMO Training &Coaching in AmbalaBest SMO Training &Coaching in Ambala
Best SMO Training &Coaching in Ambala
 
Best HTML Training &Coaching in Ambala
Best HTML Training &Coaching in AmbalaBest HTML Training &Coaching in Ambala
Best HTML Training &Coaching in Ambala
 
Best SEO Training & Coaching in Ambala
Best SEO Training & Coaching in AmbalaBest SEO Training & Coaching in Ambala
Best SEO Training & Coaching in Ambala
 
Best Photoshop Training in Ambala
 Best Photoshop Training  in Ambala Best Photoshop Training  in Ambala
Best Photoshop Training in Ambala
 
Best C Programming Training & Coaching in Ambala
Best C Programming Training & Coaching in AmbalaBest C Programming Training & Coaching in Ambala
Best C Programming Training & Coaching in Ambala
 
BASIC COMPUTER TRAINING & COACHING CENTRE IN AMBALA CANTT
BASIC COMPUTER TRAINING & COACHING CENTRE IN AMBALA CANTTBASIC COMPUTER TRAINING & COACHING CENTRE IN AMBALA CANTT
BASIC COMPUTER TRAINING & COACHING CENTRE IN AMBALA CANTT
 
Web Browser ! Batra Computer Centre
Web Browser ! Batra Computer CentreWeb Browser ! Batra Computer Centre
Web Browser ! Batra Computer Centre
 
Search Engine Training in Ambala ! Batra Computer Centre
Search Engine Training in Ambala ! Batra Computer CentreSearch Engine Training in Ambala ! Batra Computer Centre
Search Engine Training in Ambala ! Batra Computer Centre
 
Networking Training in Ambala ! Batra Computer Centre
Networking Training in Ambala ! Batra Computer CentreNetworking Training in Ambala ! Batra Computer Centre
Networking Training in Ambala ! Batra Computer Centre
 
SQL Training in Ambala ! BATRA COMPUTER CENTRE
SQL Training in Ambala ! BATRA COMPUTER CENTRESQL Training in Ambala ! BATRA COMPUTER CENTRE
SQL Training in Ambala ! BATRA COMPUTER CENTRE
 
Networking ! BATRA COMPUTER CENTRE
Networking ! BATRA COMPUTER CENTRENetworking ! BATRA COMPUTER CENTRE
Networking ! BATRA COMPUTER CENTRE
 
Ms Office 2010 Training in Ambala ! BATRA COMPUTER CENTRE
Ms Office 2010 Training in Ambala ! BATRA COMPUTER CENTREMs Office 2010 Training in Ambala ! BATRA COMPUTER CENTRE
Ms Office 2010 Training in Ambala ! BATRA COMPUTER CENTRE
 
Basic Computer Training Centre in Ambala ! BATRA COMPUTER CENTRE
Basic Computer Training Centre in Ambala ! BATRA COMPUTER CENTREBasic Computer Training Centre in Ambala ! BATRA COMPUTER CENTRE
Basic Computer Training Centre in Ambala ! BATRA COMPUTER CENTRE
 
Corel Draw Training Institute in Ambala ! BATRA COMPUTER CENTRE
Corel Draw Training Institute in Ambala ! BATRA COMPUTER CENTRECorel Draw Training Institute in Ambala ! BATRA COMPUTER CENTRE
Corel Draw Training Institute in Ambala ! BATRA COMPUTER CENTRE
 
Basic Computer Training Institute ! BATRA COMPUTER CENTRE
Basic Computer Training Institute ! BATRA COMPUTER CENTREBasic Computer Training Institute ! BATRA COMPUTER CENTRE
Basic Computer Training Institute ! BATRA COMPUTER CENTRE
 
HTML Training Institute in Ambala ! Batra Computer Centre
HTML Training Institute in Ambala ! Batra Computer CentreHTML Training Institute in Ambala ! Batra Computer Centre
HTML Training Institute in Ambala ! Batra Computer Centre
 
Benefits of Web Browser ! Batra Computer Centre
Benefits of Web Browser ! Batra Computer CentreBenefits of Web Browser ! Batra Computer Centre
Benefits of Web Browser ! Batra Computer Centre
 
SEO Training in Ambala ! Batra Computer Centre
SEO Training in Ambala ! Batra Computer CentreSEO Training in Ambala ! Batra Computer Centre
SEO Training in Ambala ! Batra Computer Centre
 
Internet Training Centre in Ambala ! Batra Computer Centre
Internet Training Centre in Ambala ! Batra Computer CentreInternet Training Centre in Ambala ! Batra Computer Centre
Internet Training Centre in Ambala ! Batra Computer Centre
 
Web Designing Training in Ambala ! Batra Computer Centre
Web Designing Training in Ambala ! Batra Computer CentreWeb Designing Training in Ambala ! Batra Computer Centre
Web Designing Training in Ambala ! Batra Computer Centre
 

Recently uploaded

Advantages and Disadvantages of CMS from an SEO Perspective
Advantages and Disadvantages of CMS from an SEO PerspectiveAdvantages and Disadvantages of CMS from an SEO Perspective
Advantages and Disadvantages of CMS from an SEO Perspective
Krisztián Száraz
 
Group Presentation 2 Economics.Ariana Buscigliopptx
Group Presentation 2 Economics.Ariana BuscigliopptxGroup Presentation 2 Economics.Ariana Buscigliopptx
Group Presentation 2 Economics.Ariana Buscigliopptx
ArianaBusciglio
 
writing about opinions about Australia the movie
writing about opinions about Australia the moviewriting about opinions about Australia the movie
writing about opinions about Australia the movie
Nicholas Montgomery
 
Aficamten in HCM (SEQUOIA HCM TRIAL 2024)
Aficamten in HCM (SEQUOIA HCM TRIAL 2024)Aficamten in HCM (SEQUOIA HCM TRIAL 2024)
Aficamten in HCM (SEQUOIA HCM TRIAL 2024)
Ashish Kohli
 
clinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdfclinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdf
Priyankaranawat4
 
South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)
Academy of Science of South Africa
 
How to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRMHow to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRM
Celine George
 
Assignment_4_ArianaBusciglio Marvel(1).docx
Assignment_4_ArianaBusciglio Marvel(1).docxAssignment_4_ArianaBusciglio Marvel(1).docx
Assignment_4_ArianaBusciglio Marvel(1).docx
ArianaBusciglio
 
PIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf IslamabadPIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf Islamabad
AyyanKhan40
 
The History of Stoke Newington Street Names
The History of Stoke Newington Street NamesThe History of Stoke Newington Street Names
The History of Stoke Newington Street Names
History of Stoke Newington
 
The basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptxThe basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptx
heathfieldcps1
 
Pride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School DistrictPride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School District
David Douglas School District
 
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat  Leveraging AI for Diversity, Equity, and InclusionExecutive Directors Chat  Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
TechSoup
 
Liberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdfLiberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdf
WaniBasim
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
Jean Carlos Nunes Paixão
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
TechSoup
 
A Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptxA Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptx
thanhdowork
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
EverAndrsGuerraGuerr
 
Digital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments UnitDigital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments Unit
chanes7
 
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
IreneSebastianRueco1
 

Recently uploaded (20)

Advantages and Disadvantages of CMS from an SEO Perspective
Advantages and Disadvantages of CMS from an SEO PerspectiveAdvantages and Disadvantages of CMS from an SEO Perspective
Advantages and Disadvantages of CMS from an SEO Perspective
 
Group Presentation 2 Economics.Ariana Buscigliopptx
Group Presentation 2 Economics.Ariana BuscigliopptxGroup Presentation 2 Economics.Ariana Buscigliopptx
Group Presentation 2 Economics.Ariana Buscigliopptx
 
writing about opinions about Australia the movie
writing about opinions about Australia the moviewriting about opinions about Australia the movie
writing about opinions about Australia the movie
 
Aficamten in HCM (SEQUOIA HCM TRIAL 2024)
Aficamten in HCM (SEQUOIA HCM TRIAL 2024)Aficamten in HCM (SEQUOIA HCM TRIAL 2024)
Aficamten in HCM (SEQUOIA HCM TRIAL 2024)
 
clinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdfclinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdf
 
South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)
 
How to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRMHow to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRM
 
Assignment_4_ArianaBusciglio Marvel(1).docx
Assignment_4_ArianaBusciglio Marvel(1).docxAssignment_4_ArianaBusciglio Marvel(1).docx
Assignment_4_ArianaBusciglio Marvel(1).docx
 
PIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf IslamabadPIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf Islamabad
 
The History of Stoke Newington Street Names
The History of Stoke Newington Street NamesThe History of Stoke Newington Street Names
The History of Stoke Newington Street Names
 
The basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptxThe basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptx
 
Pride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School DistrictPride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School District
 
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat  Leveraging AI for Diversity, Equity, and InclusionExecutive Directors Chat  Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
 
Liberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdfLiberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdf
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
 
A Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptxA Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptx
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
 
Digital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments UnitDigital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments Unit
 
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
 

C Language Training in Ambala ! Batra Computer Centre

  • 1. Ph. No.: 8222066670, 4000670 Email: info.jatinbatra@gmail.com Website: www.batracomputercentre.com BATRA COMPUTER CENTRE ISO CERTIFIED 9001:2008
  • 2. • 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 Ph. No.: 8222066670, 4000670 Email: info.jatinbatra@gmail.com Website: www.batracomputercentre.com
  • 3. • 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 BCPLPh. No.: 8222066670, 4000670 Email: info.jatinbatra@gmail.com Website: www.batracomputercentre.com
  • 4. #include <stdio.h> void main() { printf(“Hello, world!n”); } Preprocessor used to share information among source files - Clumsy + Cheaply implemented + Very flexible Ph. No.: 8222066670, 4000670 Email: info.jatinbatra@gmail.com Website: www.batracomputercentre.com
  • 5. #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 Ph. No.: 8222066670, 4000670 Email: info.jatinbatra@gmail.com Website: www.batracomputercentre.com
  • 6. int gcd(int m, int n) { int r; while ( (r = m % n) != 0) { m = n; n = r; } 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 Ph. No.: 8222066670, 4000670 Email: info.jatinbatra@gmail.com Website: www.batracomputercentre.com
  • 7. 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 Ph. No.: 8222066670, 4000670 Email: info.jatinbatra@gmail.com Website: www.batracomputercentre.com
  • 8. 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 Ph. No.: 8222066670, 4000670 Email: info.jatinbatra@gmail.com Website: www.batracomputercentre.com
  • 9. int gcd(int m, int n) { int r; while ( (r = m % n) != 0) { m = n; n = r; } return n; } High-level control-flow statement. Ultimately becomes a conditional branch. Supports “structured programming” Each function returns a single value, usually an integer. Returned through a specific register by convention. Ph. No.: 8222066670, 4000670 Email: info.jatinbatra@gmail.com Website: www.batracomputercentre.com
  • 10. .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; } Ph. No.: 8222066670, 4000670 Email: info.jatinbatra@gmail.com Website: www.batracomputercentre.com
  • 11. .globl _gcd .text _gcd: jsr r5,rsave L2:mov 4(r5),r1 sxt r0 div 6(r5),r0 mov r1,-10(r5) jeq L3 mov 6(r5),4(r5) mov -10(r5),6(r5) jbr L2 L3:mov 6(r5),r0 jbr L1 L1:jmp rretrn Very natural mapping from C into PDP-11 instructions. Complex addressing modes make frame-pointer-relative accesses easy. Another idiosyncrasy: registers were memory-mapped, so taking address of a variable in a register is straightforward. Ph. No.: 8222066670, 4000670 Email: info.jatinbatra@gmail.com Website: www.batracomputercentre.com
  • 12. • 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 invokedPh. No.: 8222066670, 4000670 Email: info.jatinbatra@gmail.com Website: www.batracomputercentre.com
  • 13. • 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 backPh. No.: 8222066670, 4000670 Email: info.jatinbatra@gmail.com Website: www.batracomputercentre.com
  • 14. int i; int *j, k; unsigned char *ch; float f[10]; char nextChar(int, char*); int a[3][5][10]; int *func1(float); int (*func2)(void); Integer j: pointer to integer, int k ch: pointer to unsigned char Array of 10 floats 2-arg function Array of three arrays of five … function returning int * pointer to function returning int Ph. No.: 8222066670, 4000670 Email: info.jatinbatra@gmail.com Website: www.batracomputercentre.com
  • 15. • Type declarations recursive, complicated. • Name new types with typedef • Instead of int (*func2)(void) use typedef int afunc2t(void); func2t *func2; Ph. No.: 8222066670, 4000670 Email: info.jatinbatra@gmail.com Website: www.batracomputercentre.com
  • 16. • A 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; Ph. No.: 8222066670, 4000670 Email: info.jatinbatra@gmail.com Website: www.batracomputercentre.com
  • 17. • 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 shiftingPh. No.: 8222066670, 4000670 Email: info.jatinbatra@gmail.com Website: www.batracomputercentre.com
  • 18. • 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 Ph. No.: 8222066670, 4000670 Email: info.jatinbatra@gmail.com Website: www.batracomputercentre.com
  • 19. • Most processors require n-byte objects to be in memory at address n*k • Side effect of wide memory busses • E.g., a 32-bit memory bus • Read from address 3 requires two accesses, shifting 4 3 2 1 4 3 2 1 Ph. No.: 8222066670, 4000670 Email: info.jatinbatra@gmail.com Website: www.batracomputercentre.com
  • 20. • Compilers add “padding” to structs to ensure proper alignment, especially for arrays • Pad to ensure alignment of largest object (with biggest requirement) struct { char a; int b; char c; } a bbbb c a bbbb c Pad Ph. No.: 8222066670, 4000670 Email: info.jatinbatra@gmail.com Website: www.batracomputercentre.com
  • 21. #include <stdlib.h> int global_static; static int file_static; void foo(int auto_param) { static int func_static; int auto_i, auto_a[10]; double *auto_d = malloc(sizeof(double)*5); } Linker-visible. Allocated at fixed location Visible within file. Allocated at fixed location. Visible within func. Allocated at fixed location. Ph. No.: 8222066670, 4000670 Email: info.jatinbatra@gmail.com Website: www.batracomputercentre.com
  • 22. #include <stdlib.h> int global_static; static int file_static; void foo(int auto_param) { static int func_static; int auto_i, auto_a[10]; double *auto_d = malloc(sizeof(double)*5); } Space allocated on stack by function. Space allocated on stack by caller. Space allocated on heap by library routine. Ph. No.: 8222066670, 4000670 Email: info.jatinbatra@gmail.com Website: www.batracomputercentre.com
  • 23. • Array: sequence of identical objects in memory • int a[10]; means space for ten integers  By itself, a is the address of the first integer  *a and a[0] mean the same thing  The address of a is not stored in memory: the compiler inserts code to compute it when it appears  Ritchie calls this interpretation the biggest conceptual jump from BCPL to C Ph. No.: 8222066670, 4000670 Email: info.jatinbatra@gmail.com Website: www.batracomputercentre.com
  • 24. • Traditional mathematical expressions y = a*x*x + b*x + c; • Very rich set of expressions • Able to deal with arithmetic and bit manipulation Ph. No.: 8222066670, 4000670 Email: info.jatinbatra@gmail.com Website: www.batracomputercentre.com
  • 25. • arithmetic: + – * / % • comparison: == != < <= > >= • bitwise logical: & | ^ ~ • shifting: << >> • lazy logical: && || ! • conditional: ? : • assignment: = += -= • increment/decrement: ++ -- • sequencing: , • pointer: * -> & [] Ph. No.: 8222066670, 4000670 Email: info.jatinbatra@gmail.com Website: www.batracomputercentre.com
  • 26. • c = a < b ? a + 1 : b – 1; • Evaluate first expression. If true, evaluate second, otherwise evaluate third. • Puts almost statement-like behavior in expressions. • BCPL allowed code in an expression: a := 5 + valof{ int i, s = 0; for (i = 0 ; i < 10 ; i++) s += a[I]; return s; } Ph. No.: 8222066670, 4000670 Email: info.jatinbatra@gmail.com Website: www.batracomputercentre.com
  • 27. • From BCPL’s view of the world • Pointer arithmetic is natural: everything’s an integer int *p, *q; *(p+5) equivalent to p[5] • If p and q point into same array, p – q is number of elements between p and q. • Accessing fields of a pointed-to structure has a shorthand: p->field means (*p).field Ph. No.: 8222066670, 4000670 Email: info.jatinbatra@gmail.com Website: www.batracomputercentre.com
  • 28. • Expression • Conditional – if (expr) { … } else {…} – switch (expr) { case c1: case c2: … } • Iteration – while (expr) { … } zero or more iterations – do … while (expr) at least one iteration – for ( init ; valid ; next ) { … } • Jump – goto label – continue; go to start of loop – break; exit loop or switch – return expr; return from function Ph. No.: 8222066670, 4000670 Email: info.jatinbatra@gmail.com Website: www.batracomputercentre.com
  • 29. Ph. No.: 8222066670, 4000670 Email: info.jatinbatra@gmail.com Website: www.batracomputercentre.com
  • 30. ADDRESS: SCO -15, Dayal Bagh, Near Hanuman Mandir Ambala Cantt-13300, Haryana Ph. No.: 9729666670, 8222066670 &0171-4000670 Email ID: info.jatinbatra@gmail.com Website: www.batracomputercentre.com Ph. No.: 8222066670, 4000670 Email: info.jatinbatra@gmail.com Website: www.batracomputercentre.com
  • 31. Ph. No.: 8222066670, 4000670 Email: info.jatinbatra@gmail.com Website: www.batracomputercentre.com