ICS Lecture 3
ICS Lecture 3
Example in base 10
What if we had a world in which ...
base
Binary
1710 = 1 * 24 + 0 * 23 + 0 * 22 + 0 * 21 + 1 * 20 = 100012
Base = 2
Binary Number System
* They would use a number system with
base 2.
Number in decimal Number in binary
5 101
100 1100100
500 111110100
1024 10000000000
MSB and LSB
* Hexadecimal numbers
* Base 16 numbers – 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F
* Start with 0x
* Octal Numbers
* Base 8 numbers – 0,1,2,3,4,5,6,7
* Start with 0
Examples
Decimal Binary Octal Hexadecimal
9 1001 0 11 0x 9
12 1100 0 14 0x C
17 10001 0 21 0x 11
28 11100 0 34 0x 1C
Byte 08 or
bits1
Word 40bytes
or 1
kiloByte 1024
0 or 1bytes
megaByte 1006 or
bytes
1
What is a programming language?
• Algorithm • Comment
• Debugging
• Variable
• IDE: Integrated Development
• Data Type
Environment
• Function
• Operator
• Control Flow • Statement
• Syntax • Libraries
Programming – Why?
• Computers are used for many different purposes in many
different situations.
• But, how can they be so versatile?
• Answer: They can be programmed
• The ability for a computer to be programmed allows it to do
whatever their programs tell them what to do.
• A program is a set of instructions that tell a computer what
to do.
• A computer cannot do anything unless it has a program to tell
it what to do
Programming – What?
• Programs are used to operate the components of a computer,
solve problems or satisfy a want/need.
• How long will it take me to get home if I drive x miles per hour?
• I want to be able to tell my friends what I am doing right now.
• Computer Programming is both an Art and a Science
• Every aspect of a program must be carefully designed
• As an art, programming takes creativity and problem solving.
• There is often no one correct way to solve a problem.
• As a science, there are formal and proven methods to go
about creating a programming.
• In this course, you will learn both the art and science of
programming.
Introduction to C
#include <stdio.h>
{ Library function,
printf (“Hello world”); uses write system call
Statement terminator
}
Formatted output
More printing … (code and see)
#include <stdio.h>
void main()
{
printf ("Hello, World! ") ;
printf ("Hello \n World! \n") ;
}
\n character
Some more printing
#include <stdio.h>
void main()
{
printf ("Hello, World! \n") ;
printf ("Hello \n World! \n") ;
printf ("Hell\no \t World! \n") ;
}
\t character