Arrays (Chapter 5)‏ Definition Applications One-Dimensional –Declaration –Initialization –Use Multidimensional.

Slides:



Advertisements
Similar presentations
Macromolecules are large molecules formed by joining smaller organic molecules together.
Advertisements

Learning Objectives: To understand what is meant by the term, ‘relative molecular mass’
CHAPTER 4 CARBON AND THE MOLECULAR DIVERSITY OF LIFE Section A: The Importance of Carbon 1.Organic chemistry is the study of carbon compounds 2.Carbon.
Moving To Code 3 More on the Problem-Solving Process §The final step in the problem-solving process is to evaluate and modify (if necessary) the program.
Molar Mass & Percent Composition
PERCENT COMPOSITION. 2 3 Steps for Determining Chemical Formulas 1. Determine the percent composition of all elements. 2. Convert this information into.
Molecular Formula. FormaldehydeFormaldehyde Acetic Acid Glucose.
Macromolecules.
Percentage Composition Chemistry 11 Ms. McGrath. Percentage Composition Chemists use molar mass to find out important information about compounds. Chemists.
Matter and Molecules Review Chapter 3 Review. Vocabulary  In living things, carbohydrates are broken down into ______________ for fuel.  Simple Sugars.
A First Book of ANSI C Fourth Edition
M EASUREMENTS AND C ALCULATIONS IN CHEMISTRY - M OLECULAR FORMULAS Dr. Chin Chu Chemistry River Dell High School.
Organisms and the Environment Chapter Four: Physical Science Connections 4.1 Elements and Compounds 4.2 The Compounds of Life 4.3 Physical Variables.
Array Cs212: DataStructures Lab 2. Array Group of contiguous memory locations Each memory location has same name Each memory location has same type a.
Counting Atoms Chapter 9. MOLE?? Moles of Particles In one mole of a substance, there are 6 x particles.
Cells Chemistry of Life Chapter 2 Objectives: Know the functions of each group of organic compound/macromolecule.
1 Macromolecules Chapter Organic Compounds Compounds organicCompounds that contain _________ are called organic. Derived from _________________.
IB Building a protein © Oxford University Press 2011 Building a protein.
Carbon and the Molecular Diversity of Life Chapter 4.
A first program 1. #include 2. using namespace std; 3. int main() { 4. cout
Basic Biochemistry VERY BASIC. Matter Anything that has mass and takes up space. Anything that is not matter is energy.
Ch. 3 Chemistry of Life Test Review. 1. All matter is composed of: All matter is composed of:
The building blocks of life Organisms are made of carbon-based molecules.
Susie’s lecture notes are in the presenter’s notes, below the slides Disclaimer: Susie may have made errors in transcription or understanding. If there.
Arrays. The array data structure Array is a collection of elements, that have the same data type Integers (int) Floating point numbers (float, double)
Structuring Data: Arrays ANSI-C. Representing multiple homogenous data Problem: Input: Desired output:
PS.2b Compounds. Compounds are made of 2 or more kinds of atoms which combine in a specific ratio.
Chapter 8 Arrays. A First Book of ANSI C, Fourth Edition2 Introduction Atomic variable: variable whose value cannot be further subdivided into a built-in.
Computer Programming for Engineers
Organic Compounds A review of elements, molecules, and compounds.
PROTEINS Characteristics of Proteins Contain carbon, hydrogen, oxygen, nitrogen, and sulfur Serve as structural components of animals Serve as control.
Arrays (Chapter 5)‏ Definition Applications One-Dimensional –Declaration –Initialization –Use Multidimensional.
CHAPTER 6 ARRAYS IN C 1 st semester King Saud University College of Applied studies and Community Service Csc 1101 F. Alakeel.
The building blocks of life Organisms are made of carbon-based molecules.
These compounds are made up of _______________________ in a ratio of _____. carbon, hydrogen and oxygen 1:2:1 Look at the top picture. Count the number.
Chapter 1.  Element – a substance that cannot be broken down into simpler substances – smallest unit of an element is an atom  Compound – two or more.
Organic Compounds. Table of Contents Pages TEK 7.6A Title: Organic Compounds Date: 11/5/15.
(7 th ) Chapter 3-3 Cornell Notes Chemical Compounds in Cells.
Chapter 11 Structures, Unions and Typedef 11.1 Structures Structures allow us to group related data items of different types under a common name. The individual.
CARBON AND THE MOLECULAR DIVERSITY OF LIFE Chapter 4 I. The Importance of Carbon.
Arrays An array is a sequence of objects all of which have the same type. The objects are called the elements of the array and are numbered consecutively.
A FIRST BOOK OF C++ CHAPTER 7 ARRAYS. OBJECTIVES In this chapter, you will learn about: One-Dimensional Arrays Array Initialization Arrays as Arguments.
4.2 Carbon compounds and cells Life as we know it is carbon based. A carbon atom can form chemical bonds with other carbon atoms in long chains or rings.
Percent Composition. – Compounds are ALWAYS composed of elements in fixed ratios. This is often referred to as the Law of Definite Proportions. – This.
Percentage Composition
6.4 The Building Blocks of Life
What elements are found in a phospholipid?
4.2 Carbon compounds and cells
Chapter 6 Chemical Composition.
Carbon: The Building Block of Organic Compounds
Chapter 4 LOOPS © Bobby Hoggard, Department of Computer Science, East Carolina University / These slides may not be used or duplicated without permission.
Proteins Structure Elements: Carbon (C), Hydrogen (H), Oxygen (O), Nitrogen (P), & sometimes Sulfur (S) Monomer Amino Acid –Amino Group (NH2), Carboxyl.
Chemical Compounds in Cells
Atoms, Molecules, Elements, and Compounds
Chemical Compounds in Cells
Chapter 6: Chemistry in Biology
What are living creatures made of?
Characteristics and Classification of Life
Biological Molecules -Biological molecules consist primarily of carbon, oxygen, hydrogen, and nitrogen. -These elements share valence electrons to form.
Biomolecules Nutrient Sort Biology 12.
Organic Macromolecules
Chemical Compounds Chapter 3 Section 1 Notes.
Molecules of Life: Macromolecules
The molecules that form life
PROTEINS.
Percentage Composition
Organic Compounds (molecules that contain Carbon) AKA Carbon Macromolecules Chapter 2-3.
What are living creatures made of? Why do we have to eat?
Empirical and Molecular Formulas
Presentation transcript:

Arrays (Chapter 5)‏ Definition Applications One-Dimensional –Declaration –Initialization –Use Multidimensional

Declaration #define SIZE 10 int main(void)‏ { float sample[SIZE];

Initialization #define SIZE 10 int main(void)‏ { float sample[SIZE] = {5.0, 1.2, -4.6, -7.5, 8.9, -1.0, 12.7, 0.0, 6.6, 4.2};

Gotchas First element of array is [0] Last element of array is [n-1] (major source of bugs!)‏ No bounds check (MAJOR source of impossible-to- find bugs!)‏

Amino Acids I like this problem, but I don't especially like the way the book does it. The book isn't careful enough about range errors. We can use a table-driven approach to looking up the atomic weights of the elements. This takes more space (bad), less time (good) than the way the book looks up the weights. Also less opportunity for bugs (very, very good).

Background Amino Acid: Organic molecule composed of carbon, hydrogen, nitrogen, oxygen, sulfur. Building blocks of proteins. Amino acids are what DNA codes for. Weight is sum of weights of component atoms

Syntax One amino acid formula on a single line Amino acid formula consists of sequence of atom counts Atom count is a letter specifying the atom, maybe followed by a number specifying how many of them. O2C3NH7\n

Semantics O2C3NH7\n –Two Oxygen (2.0 * = )‏

Semantics O2C3NH7\n –Two Oxygen (2.0 * = )‏ –Three Carbon (3.0 * = )‏

Semantics O2C3NH7\n –Two Oxygen (2.0 * = )‏ –Three Carbon (3.0 * = )‏ –One Nitrogen ( )‏

Semantics O2C3NH7\n –Two Oxygen (2.0 * = )‏ –Three Carbon (3.0 * = )‏ –One Nitrogen ( )‏ –Seven Hydrogen (7.0 * = )‏

Semantics O2C3NH7\n –Two Oxygen (2.0 * = )‏ –Three Carbon (3.0 * = )‏ –One Nitrogen ( )‏ –Seven Hydrogen (7.0 * = )‏ Total: =

Parsing O2C3NH7\n Find new atoms (letters)‏

Parsing O2C3NH7\n Find new atoms (letters)‏ –Look up atomic weight of atom (12.011)‏

Parsing O2C3NH7\n Find new atoms (letters)‏ –Look up atomic weight of atom (12.011)‏ Count how many we've got (numbers)‏

Parsing O2C3NH7\n Find new atoms (letters)‏ –Look up atomic weight of atom (12.011)‏ Count how many we've got (numbers)‏ –3

Parsing O2C3NH7\n Find new atoms (letters)‏ –Look up atomic weight of atom (12.011)‏ Count how many we've got (numbers)‏ –3 When we reach next atom, add previous to atomic weight of molecule

Parsing O2C3NH7\n Find new atoms (letters)‏ –Look up atomic weight of atom (12.011)‏ Count how many we've got (numbers)‏ –3 When we reach next atom, add previous to atomic weight of molecule –3* =

Look Up Atomic Weight

Counting numatoms = numatoms * newdigit;

Counting numatoms = numatoms * newdigit; 123

Counting numatoms = numatoms * newdigit; 123 0* = 1

Counting numatoms = numatoms * newdigit; 123 1* = 12

Counting numatoms = numatoms * newdigit; * = 123

Special Cases First letter: make sure we don't put gibberish in molecular weight End of string: make sure we account for last atom If user didn't enter number for an atom, it means '1'

Writing the code Write initialization, input, core loop, output Handle special cases Error checking