Arithmetic Expressions With Integers
result is always an integer
You can strin
Other Types Of Data
Variables of type short use half a word (16 bits) to represent
Variables of type float use one word (32 bits) to represent a
value instead of the two used by
using namespace std;
int main () cfw_
cout < "Enter a word" < endl;
String is a type defined in string.h
String is an object
There are many methods that work
on string objects
One of them is =
How do Calculators Computer Square Roots?
When you enter 29 into your calculator and push the square root button,
how does the calculator compute
Consider the function x2 29 = 0.
A one-dimensional array is a list of variables, all of the same type.
Odds And Ends Switch Statement
It is often necessary in programs to set up a set of cases, where at
most one of the cases is executed.
There is a special statement in C+ that makes is easier to set up
Streams In C+
A stream is a sequence that you either read from or write to.
Streams are also used in C+ to represent files.
Functions That Return Values
We will use functions
Quadratic Equation Program
Remember the quadratic equation program that from several weeks
x = -B
We want to convert this pr
10 11 12
1 and 2
Add corresponding elements of Matrix 1 and Matrix 2
to produce the Sum matrix.
To add two matrices, they must have the same
# This is the first part of Computer Organization HW3. #
# Team members' names: Yipeng Zhang, Bijia Zhao #
# Team members' lab section: Section 03 #
.asciiz "Please enter a positive integer: "
.asciiz "\n# of 0s i
The Programming Process
Use an editor to create a program
file (source file).
Use a compiler to convert the
source file into a machine code file
What is Computer Science 1
We learn how to program a computer using a mixture of C and C+
Understand the issues that matter to Co
Making our programs more flexible
So far we have largely programmed using
There is an issue with this style of programming
What is an Object?
Many of the newer programming languages such as C+ are
object-oriented languages that allow a programmer to design
a program as a set of objects.
An object is a physical or conceptual thing that you want
to model in a program.
Example converting a struct to an object
We want to convert this struct to an object
An object has data and methods
An object has public and private sections
Good practice puts the data in the private
struct acct cfw_
Bank Simulation (banking.h)
This class simulates a bank by
processing transactions for bank
A vector is used to hold the
Here is a search algorithm for the
It works for a list in any order.
A recursive function must have at least two parts
Here is a simple recursive function
int factorial (int val) cfw_
cout < Entering
Merge Sort Algorithm
Merge sort has two phases.
Consider the following data set.
Searching and sorting
Reasons for not using the most efficient algorithm include:
SIDDHARTHA CH 10: SON
-Kamalas burial after cremation on the same hill
Vasudeva's wife was buried.
-Siddhartha loves his boy want him to live with him in the
hut next to the river
-boy does not adjust very well to these new living
conditions; he w