Numerical Conversions Intro to Strings in C/C++
Numerical
Conversions
Intro
to
Strings
in
C/C++
CS
16:
Solving
Problems
with
Computers
I
Lecture
#8
Ziad
Matni
Dept.
of
Computer
Science,
UCSB
Announcements
? We
are
grading
your
midterms
this
week!
? Grades
will
be
available
by
Tuesday
next
week
? Next
lab
is
a
required
pair
programming
assignment
? You
are
required
to
work
with
a
partner
for
Lab
5
(next
week)
? Read
the
descripOon
for
Lab
5
when
it
comes
out
over
the
weekend
carefully
for
the
details
10/26/17
Matni,
CS16,
Fa17
2
Note:
FuncOons
Calling
FuncOons
? A function body may contain a
void
order
(int&,
int&);
void
swap_values
(int&,
int&);
call to another function
int
main
()
{
...
? The called function declaration must still appear before it is called
...
order
(a,
b);
...
...
return
0;
}
? Functions cannot be defined in the body of another function
void
order(int&
n1,
int&
n2)
{
if
(n1
>
n2)
? Including inside the main( ) function!
swap_values(n1,
n2);
}
void
swap_values(int&
n1,
int&
n2)
{
int
temp
=
n2;
n2
=
n1;
n1
=
temp;
}
10/26/17
Matni,
CS16,
Fa17
3
PosiOonal
NotaOon
in
Binary
11011 in base 2 positional notation is:
1 x 24 + 1 x 23 + 0 x 22 + 1 x 21 + 1 x 20
= 1 x 16 = 16 = 1x8 =8 = 1x4 =0 = 1x2 =2 = 1x1 =1
So, 11011 in base 2 is 16 + 8 + 0 + 2 + 1 = 27 in base 10
10/26/17
Matni,
CS16,
Fa17
4
ConverOng
Binary
to
Octal
and
Hexadecimal
(or
any
base
that's
a
power
of
2)
? Binary
is
1
bit
? Octal
is
3
bits
(23
=
8)
octal
is
base
8
? Hexadecimal
is
4
bits
(24
=
16)
hex
is
base
16
? Use
the
"group
the
bits"
technique
? Always
start
from
the
least
significant
digit
? Group
every
3
bits
together
for
bin
?
oct
? Group
every
4
bits
together
for
bin
?
hex
10/26/17
Matni,
CS16,
Fa17
5
................
................
In order to avoid copyright disputes, this page is only a partial summary.
To fulfill the demand for quickly locating and searching documents.
It is intelligent file search solution for home and business.
Related download
- harvard applied math 225 eder medina
- cs221 assembly language fundamentals irvine chapter 3
- csci 123 introduction to programming concepts in c lecture 1
- supplement v f c strings for introduction to c
- evaluation of a data type in a manufacturing execution system
- compiling separate c files strings vectors
- applied c and c programming
- formatting numbers with c output streams
- cs106l stanford university
- numerical conversions intro to strings in c c
Related searches
- count strings in list python
- array of strings in powershell
- weight conversions kg to lb
- baking conversions cups to grams
- strings in java javatpoint
- input strings in python
- replace strings in python
- joining two strings in python
- combine strings in list python
- join strings in list python
- formatted strings in python
- strings in java