SlideShare a Scribd company logo
1 of 31
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 Programming Language Basics

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 Centrejatin 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 Centrejatin 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 Centrejatin 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 Centrejatin 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 Centrejatin batra
 
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 Ambalajatin batra
 
Learn c++ Programming Language
Learn c++ Programming LanguageLearn c++ Programming Language
Learn c++ Programming LanguageSteve Johnson
 
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 gamesAndrey Karpov
 
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 OtherBlue 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 Centrejatin 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 SparkArtem Chebotko
 
C++ process new
C++ process newC++ process new
C++ process new敬倫 林
 
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.0Cloudera, Inc.
 
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 2014Julien Le Dem
 

Similar to C Programming Language Basics (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 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
 
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
 

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 Ambalajatin batra
 
Best HTML Training &Coaching in Ambala
Best HTML Training &Coaching in AmbalaBest HTML Training &Coaching in Ambala
Best HTML Training &Coaching in Ambalajatin batra
 
Best SEO Training & Coaching in Ambala
Best SEO Training & Coaching in AmbalaBest SEO Training & Coaching in Ambala
Best SEO Training & Coaching in Ambalajatin batra
 
Best Photoshop Training in Ambala
 Best Photoshop Training  in Ambala Best Photoshop Training  in Ambala
Best Photoshop Training in Ambalajatin 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 Ambalajatin 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 CANTTjatin batra
 
Web Browser ! Batra Computer Centre
Web Browser ! Batra Computer CentreWeb Browser ! Batra Computer Centre
Web Browser ! Batra Computer Centrejatin 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 Centrejatin 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 Centrejatin 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 CENTREjatin batra
 
Networking ! BATRA COMPUTER CENTRE
Networking ! BATRA COMPUTER CENTRENetworking ! BATRA COMPUTER CENTRE
Networking ! BATRA COMPUTER CENTREjatin 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 CENTREjatin 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 CENTREjatin 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 CENTREjatin 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 CENTREjatin 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 Centrejatin 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 Centrejatin 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 Centrejatin 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 Centrejatin 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 Centrejatin 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

Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...RKavithamani
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application ) Sakshi Ghasle
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxRoyAbrique
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991RKavithamani
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpinRaunakKeshri1
 

Recently uploaded (20)

Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application )
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpin
 

C Programming Language Basics

  • 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