Class Notes (1,000,028)
US (390,049)
Santa Clara (847)
CSCI (23)
CSCI 10 (18)
Bannister (16)
Lecture 13

CSCI 10 Lecture 13: CSCI 10 – Day 13
Premium

2 Pages
35 Views
Fall 2016

Department
Computer Science
Course Code
CSCI 10
Professor
Bannister
Lecture
13

This preview shows half of the first page. Sign up to view the full 2 pages of the document.
CSCI 10 Day 13
ARRAYS!
Announcements
-HW 4 due Friday
LECTURE
Example 22
-Array basics: creating, reading, writing, priting, copying
-An array doesn’t know its size…it doesn’t know how many entries it is
responsible for.
-The old standard should be a constant variable that holds the array size
-Now we can ask the user to input to the size variable to specify size of the
array
-Array size cannot be changed once initialized in C++ (by only replacing
the array can you change the content of the array)
int main () {
const int sz = 10; //size variable
int A[sz];
for (int i = 0; i < 10; i++) A[i] = 0;
B = A; // invalid array assignment
return 0;
}
// find min in array
int smallest = nums[0];
for (int i = 1; i < N; i++) {
if (nums[i] < smallest) {
smallest = nums[i];
}
}
cout << smallest << endl;
How to sort an array:
Find the biggest, and swap it with the very last entry in the array, repeat
the process with the rest of the array (except arr[-1])
-The
-Any function that takes an array must also take a size parameter
find more resources at oneclass.com
find more resources at oneclass.com

Loved by over 2.2 million students

Over 90% improved by at least one letter grade.

Leah — University of Toronto

OneClass has been such a huge help in my studies at UofT especially since I am a transfer student. OneClass is the study buddy I never had before and definitely gives me the extra push to get from a B to an A!

Leah — University of Toronto
Saarim — University of Michigan

Balancing social life With academics can be difficult, that is why I'm so glad that OneClass is out there where I can find the top notes for all of my classes. Now I can be the all-star student I want to be.

Saarim — University of Michigan
Jenna — University of Wisconsin

As a college student living on a college budget, I love how easy it is to earn gift cards just by submitting my notes.

Jenna — University of Wisconsin
Anne — University of California

OneClass has allowed me to catch up with my most difficult course! #lifesaver

Anne — University of California
Description
find more resources at oneclass.com CSCI 10 – Day 13 ARRAYS! Announcements -HW 4 due Friday LECTURE  Example 22 -Array basics: creating, reading, writing, priting, copying -An array doesn’t know its size…it doesn’t know how many entries it is responsible for. -The old standard should be a constant variable that holds the array size -Now we can ask the user to input to the size variable to specify size of the array -Array size cannot be changed once initialized in C++ (by only replacing the array can you change the content of the array) int main () { const int sz = 10; //size variable int A[sz]; for (int i = 0; i < 10; i++) A[i] = 0; B = A; // invalid array assignment return 0; } // find min in array int smallest = nums[0]; for (int i = 1; i < N; i++) { if (nums[i] < smallest) { smallest = nums[i];
More Less
Unlock Document

Only half of the first page are available for preview. Some parts have been intentionally blurred.

Unlock Document
You're Reading a Preview

Unlock to view full version

Unlock Document

You've reached the limit of 4 previews this month

Create an account for unlimited previews.

Already have an account?

Log In


OR

Don't have an account?

Join OneClass

Access over 10 million pages of study
documents for 1.3 million courses.

Sign up

Join to view


OR

By registering, I agree to the Terms and Privacy Policies
Already have an account?
Just a few more details

So we can recommend you notes for your school.

Reset Password

Please enter below the email address you registered with and we will send you a link to reset your password.

Add your courses

Get notes from the top students in your class.


Submit