Professional Documents
Culture Documents
Cientific Omputing: Dr. Johnson
Cientific Omputing: Dr. Johnson
The Basics
Understanding Data
Summary
S CIENTIFIC C OMPUTING
Dr. Johnson
School of Mathematics
Semester 1 2012
O UTLINE
1 C OURSE O BEJECTIVES
Structure of the course
Object-Orientated Programming
O UTLINE
1 C OURSE O BEJECTIVES
Structure of the course
Object-Orientated Programming
2 T HE BASICS
What is a computer?
Syntax
O UTLINE
1 C OURSE O BEJECTIVES
Structure of the course
Object-Orientated Programming
2 T HE BASICS
What is a computer?
Syntax
3 U NDERSTANDING DATA
Handling Data and Variables
Namespaces
Simple Input and Output
O UTLINE
1 C OURSE O BEJECTIVES
Structure of the course
Object-Orientated Programming
2 T HE BASICS
What is a computer?
Syntax
3 U NDERSTANDING DATA
Handling Data and Variables
Namespaces
Simple Input and Output
4 S UMMARY
O UTLINE
1 C OURSE O BEJECTIVES
Structure of the course
Object-Orientated Programming
2 T HE BASICS
What is a computer?
Syntax
3 U NDERSTANDING DATA
Handling Data and Variables
Namespaces
Simple Input and Output
4 S UMMARY
O UTLINE
1 C OURSE O BEJECTIVES
Structure of the course
Object-Orientated Programming
2 T HE BASICS
What is a computer?
Syntax
3 U NDERSTANDING DATA
Handling Data and Variables
Namespaces
Simple Input and Output
4 S UMMARY
W HY O BJECTS ?
W HY O BJECTS ?
W HY O BJECTS ?
U SING O BJECTS
1 Encapsulation:
functions and data inside an object have restricted access.
U SING O BJECTS
1 Encapsulation:
functions and data inside an object have restricted access.
2 Polymorphism:
represents the concept of “one interface, multiple method”.
The same interface can be used to do different things for
different objects: i.e. define + to add numbers, but perform
string concatenation on characters and strings, ‘a’ + ‘b’ =
‘ab’.
U SING O BJECTS
1 Encapsulation:
functions and data inside an object have restricted access.
2 Polymorphism:
represents the concept of “one interface, multiple method”.
The same interface can be used to do different things for
different objects: i.e. define + to add numbers, but perform
string concatenation on characters and strings, ‘a’ + ‘b’ =
‘ab’.
3 Inheritance:
allows one object to acquire the properties of another. An
example would be to define a generic object “car” that has
a steering wheel, four wheels and an engine. The new
object “sports car” inherits all these properties and adds a
sun roof, go-faster stripes and a huge stereo.
Dr. Johnson MATH49111
Course Obejectives
The Basics What is a computer?
Understanding Data Syntax
Summary
Topics:
Computers and Programs;
Syntax and Structure of a Program;
Data and Variables;
Aims:
Understand the idea of programming a computer;
Write a simple program to input and output data.
O UTLINE
1 C OURSE O BEJECTIVES
Structure of the course
Object-Orientated Programming
2 T HE BASICS
What is a computer?
Syntax
3 U NDERSTANDING DATA
Handling Data and Variables
Namespaces
Simple Input and Output
4 S UMMARY
A N I DEALIZED C OMPUTER
CPU - Central
Memory
Processing Unit
CPU and memory work
together
Input CPU Output
File Store
A N I DEALIZED C OMPUTER
CPU - Central
Memory
Processing Unit
CPU and memory work
together
Input CPU Output
Input may be from
keyboard, mouse or a
file
File Store
Output may be to screen
or a file
P ROGRAMMING
W HAT IS A PROGRAM ?
P ROGRAMMING
W HAT IS A PROGRAM ?
A program is sequence of instructions to enable a computer to
complete a task.
P ROGRAMMING
W HAT IS A PROGRAM ?
A program is sequence of instructions to enable a computer to
complete a task.
P ROGRAMMING
W HAT IS A PROGRAM ?
A program is sequence of instructions to enable a computer to
complete a task.
P ROGRAMMING
W HAT IS A PROGRAM ?
A program is sequence of instructions to enable a computer to
complete a task.
O UTLINE
1 C OURSE O BEJECTIVES
Structure of the course
Object-Orientated Programming
2 T HE BASICS
What is a computer?
Syntax
3 U NDERSTANDING DATA
Handling Data and Variables
Namespaces
Simple Input and Output
4 S UMMARY
W RITING C++
Input
Calculate
Output
main()
{
}
main()
{
}
L IBRARIES
#include <library_name>
D IVISION
main(){
int i,j;
cout « ’Input two integers’ « endl;
cin » i » j;
cout « ’ i/j = ’ « i/j « endl;
}
O UTLINE
1 C OURSE O BEJECTIVES
Structure of the course
Object-Orientated Programming
2 T HE BASICS
What is a computer?
Syntax
3 U NDERSTANDING DATA
Handling Data and Variables
Namespaces
Simple Input and Output
4 S UMMARY
D ECLARING VARIABLES
D ECLARING VARIABLES
int i=0;
cout « " i= " « i « endl;
{ int i=10;
cout « " i= " « i « endl; }
cout « " i= " « i « endl;
U SING VARIABLES
U SING VARIABLES
double a,b,c;
b = 5. ; c = 4.1;
a = 10. * b + c;
OTHER O PERATORS
O UTLINE
1 C OURSE O BEJECTIVES
Structure of the course
Object-Orientated Programming
2 T HE BASICS
What is a computer?
Syntax
3 U NDERSTANDING DATA
Handling Data and Variables
Namespaces
Simple Input and Output
4 S UMMARY
W HAT IS IN A NAME ?
O UTLINE
1 C OURSE O BEJECTIVES
Structure of the course
Object-Orientated Programming
2 T HE BASICS
What is a computer?
Syntax
3 U NDERSTANDING DATA
Handling Data and Variables
Namespaces
Simple Input and Output
4 S UMMARY
T ODAYS L ECTURE
Topics:
Computers and Programs;
Syntax of C++;
Data and Variables;
Input and Output.
Aims:
Understand the idea of programming a computer;
Write a simple program to input and output data.