Hw 5 Hints.

Slides:



Advertisements
Similar presentations
A C++ Crash Course Part II UW Association for Computing Machinery Questions & Feedback.
Advertisements

Q1 Review. Other News US News top CS Universities global-universities/computer- science?int=994b08.
Introduction to Programming Lecture 39. Copy Constructor.
 2006 Pearson Education, Inc. All rights reserved Operator Overloading.
Chapter 4 - Control Structures: Part 1 Outline 4.4Control Structures 4.5The if Selection Structure 4.6The if/else Selection Structure 4.7The while Repetition.
IT253: Computer Organization Lecture 3: Memory and Bit Operations Tonga Institute of Higher Education.
Numbering System Base Conversion. Number systems Decimal – 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 Binary – 0, 1 Octal – 0, 1, 2, 3, 4, 5, 6, 7 Hexadecimal system.
CSC 1051 – Data Structures and Algorithms I Dr. Mary-Angela Papalaskari Department of Computing Sciences Villanova University Course website:
STEPS FOR MULTIPLYING A 2-DIGIT NUMBER BY ANOTHER 2-DIGIT NUMBER With Partial Products.
ENUMERATED DATATYPES. USER DEFINED DATA TYPES  Data Type Defined By Programmer  Allows Use Of More Complex Data  Typically Defined Globally So Variables.
Number Representation Lecture Topics How are numeric data items actually stored in computer memory? How much space (memory locations) is.
CMPSC 121- Spring 2015 Lecture 6 January 23, 2015.
Complex Numbers. Solve the Following 1. 2x 2 = 8 2. x = 0.
Data Representation COE 308 Computer Architecture
Computer Organization and Design Pointers, Arrays and Strings in C
4. Java language basics: Function
Data Representation ICS 233
Multiplication
Strings CSCI 112: Programming in C.
Data Representation.
Type Checking Generalizes the concept of operands and operators to include subprograms and assignments Type checking is the activity of ensuring that the.
Solving Systems of Equations
Multiplying 2 and 3 Digit Do you remember….?.
Solving Systems of Equations
Solving Systems of Equations
5. Function (2) and Exercises
Multiply 2-digit numbers using partial products
Dynamic Array Multidimensional Array Matric Operation with Array
Multiple variables can be created in one declaration
Objectives In this lesson, you will learn to: Define stacks
Area Model Multiplication
Multiplication
Stack Data Structure, Reverse Polish Notation, Homework 7
Prof. Neary Adapted from slides by Dr. Katherine Gibson
Data Representation COE 301 Computer Organization
Advanced Programming in Java
Object Oriented Programming COP3330 / CGS5409
Multiplication and integers
ARRAYS MIT-AITI Copyright 2001.
Operator Overloading; String and Array Objects
Data Types.
Operator Overloading; String and Array Objects
Two Ways to Find a Common Denominator
Adding and Subtracting Fractions
Arrays.
1.3 Equations with variables on both sides
The Standard Template Library
What's wrong with Easter jokes? They crack you up
CISC/CMPE320 - Prof. McLeod
Solving Systems of Equations
Solving Systems of Equations
Homework Reading Programming Assignments Finish K&R Chapter 1
Data Representation ICS 233
LONG MULTIPLICATION is just multiplying two numbers.
Solving Systems of Equations
Multiplying fraction and whole number
Operator Overloading; String and Array Objects
Project 1 Sequence CS 211 – Fall 2017.
Multiplication LI: To be able to write number sentences to describe an array.
9.5 Scientific Notation Objective: students will learn about scientific notation. They will also be able to perform many operations with them.
Multiplication Using Arrays.
Multiplication Using Arrays.
Multiplication and Division of Integers
Presented by : Aman Gupta PGT CS KV No.1, Narimedu, Madurai
Assignment 5 … Data Next pointer Data Next pointer Data Next pointer
Data Representation COE 308 Computer Architecture
Subtracting integers without number line 3 digit.
Adding integers without number line 2 digit.
Presentation transcript:

Hw 5 Hints

Managing Complexity Many different ways to solve this problem Write and test one function at a time Try to use a statically allocated array with say, 100 char Convert to a dynamically allocated array later Creating little helper functions Reverse string Multiply up to 10 Max, min

Debugging Remember to check operands of different lengths Use a global debugging counter to track memory allocation Update the counter whenever new and delete are called

The Least Significant Digit First Integer to string Addition

Integer to String 123 -> “123” 123 % 10 = 3, ‘3’ = 3 + ‘0’ 123 / 10 = 12 12 % 10 = 2, ‘2’ = 2 + ‘0’ 12 / 10 = 1 1 % 10 = 1, ‘1’ = 1 + ‘0’ 1 / 10 = 0 // terminate

Addition 999 + 99 ------------ 8 98 999 + 99 ------------ 098 1098

The Most Significant Digit First Multiplication Comparison of two numbers of the same length

Multiplication 1111 X 111 ------------ + 1111 ------------- 12321

Same as… 1111 X 111 ------------ + 1111 ------------- 12321

Same as… 1111 x 111 = ((1 x 1111) x 10 + 1 x 1111) x 10 + 1 x 1111

Comparison If two numbers have the same length The most significant digit decides which number is bigger If they are the same, compare the next digit

Some Possible Ways to Store 123 “123” Easier to print and extract input Easier to write the string conversion constructor Easier to multiply Easier to compare numbers “321” Easier to write the integer conversion constructor Easier to add two numbers Lowest significant digit first