Search for notes by fellow students, in your own course and all over the country.

Browse our notes for titles which look like what you need, you can preview any of the notes via a sample of the contents. After you're happy these are the notes you're after simply pop them into your shopping cart.

My Basket

You have nothing in your shopping cart yet.

Title: C language tutorial( basic ) note ( chapter 2) Instructions & Operators
Description: C language tutorial( basic ) note ( chapter 2) Instructions & Operators

Document Preview

Extracts from the notes are below, to see the PDF you'll receive please use the links above


Instructions
These are statements in a Program
Types
Type Declaration
Instructions Arithmetic
Instructions

Control
Instructions

Instructions
Type Declaration Instructions
VALID

INVALID

int a = 22;
int b = a;
int c = b + 1;
int d = 1, e;

int a = 22;
int b = a;
int c = b + 2;
int d = 2, e;

int a,b,c;
a = b = c = 1;

int a,b,c = 1;

Declare var before using it

Arithmetic Instructions

a+b
Operand 1

Operand 2

Operator

NOTE - single variable on the LHS

Arithmetic Instructions
VALID
a=b+c

INVALID
b+c=a

a=b*c

a = bc

a=b/c

a = b^c

NOTE - pow(x,y) for x to the power y

Arithmetic Instructions
Modular Operator %
Returns remainder for int

3%2=1
-3 % 2 = -1

Arithmetic Instructions
Type Conversion
int

op

int

int

op

float

float

float op

float

float

int

Arithmetic Instructions
Operator Precedence
*, /, %

x = 4 + 9 * 10

+, =

x=4*3/6*2

Arithmetic Instructions
Associativity (for same precedence)
Left to Right

x=4*3/6*2

Instructions
Control Instructions
Used to determine flow of program
a
...
Decision Control
c
...
Case Control

Operators
a
...
Relational Operators
c
...
Bitwise Operators
e
...
Ternary Operator

Operators
Relational Operators
==
>, >=
<, <=
!=

Operators
Logical Operators
&& AND
||

OR

!

NOT

Operator Precendence
Priority

Operator

1

!

2

*, /, %

3

+, -

4

<, <=, >, >=

5

==, !=

6

&&

7

||

8

=

Operators
Assignment Operators
=
+=
-=
*=
/=
%=


Title: C language tutorial( basic ) note ( chapter 2) Instructions & Operators
Description: C language tutorial( basic ) note ( chapter 2) Instructions & Operators