Warmup Write a function to add two integer parameters and return the result.

14
Warmup Write a function to add two integer parameters and return the result

Transcript of Warmup Write a function to add two integer parameters and return the result.

Page 1: Warmup Write a function to add two integer parameters and return the result.

Warmup

Write a function to add two integer parameters and return the result

Page 2: Warmup Write a function to add two integer parameters and return the result.

CMSC 202

Lesson 1

Introduction

Page 3: Warmup Write a function to add two integer parameters and return the result.

Welcome!

Who am I?– Dana Wortman, Instructor

What is this class?– CMSC 202: Computer Science 2– Design and Development of Software– C++ by Torture (…I mean…no, that’s what I mean)

Why should you care?– The “Gateway”

Page 4: Warmup Write a function to add two integer parameters and return the result.

Tips for Success

1. Attend Class2. Keep your Text handy3. Read Carefully4. Memorize the Coding Standard5. Start EARLY (>= 15 hours per project!)6. Learn a Linux editor7. Ditch Visual C++8. Review the Resources page9. Read the Blackboard discussion10. Ask Questions

Page 5: Warmup Write a function to add two integer parameters and return the result.

MOST IMPORTANT

Save Early, Save Often Modular Composition

– Write no more than 5 lines– Save– Compile– Test (optional)– Repeat

Page 6: Warmup Write a function to add two integer parameters and return the result.

Submitting Work

Use GL machines Log into:

– linux.gl.umbc.edu

Project 0 will:– Ensure the submit system is setup for you– Help you learn the submit system

Page 7: Warmup Write a function to add two integer parameters and return the result.

Need Help?

Teaching Assistants:– 2.5 Graduate

Instructor– Me!

Help Center– Open M-F 10-4 (ish?)

TBA

Page 8: Warmup Write a function to add two integer parameters and return the result.

What is Computer Science?

The systematic study of computing systems and computation.

The body of knowledge resulting from this discipline contains

– theories for understanding computing systems and methods;

– design methodology, algorithms, and tools; – methods for the testing of concepts; – methods of analysis and verification; and– knowledge representation and implementation.

Page 9: Warmup Write a function to add two integer parameters and return the result.

Where does this class fit?

CMSC 202 is primarily focused on:– Design methodology– Algorithms– Tools

Why C++?– C++ is a superset of C– Objects: greater organization & easier

maintenance– More than 50% of jobs in CS request C++

Page 10: Warmup Write a function to add two integer parameters and return the result.

Debugging

What is a bug?– Application does the unexpected– May not cause a failure (core dump, crash, etc.)

Three primary types:– Syntax – caught by compiler– Modular – caught by the linker– Logic – caught by….uh oh…the developer!!!

Page 11: Warmup Write a function to add two integer parameters and return the result.

Logic Bugs – Where’s the Bug?

int a = 7; int b = 6; int c = 2; float d = a + b + c / 3.0;

Page 12: Warmup Write a function to add two integer parameters and return the result.

Debugging

Two basic strategies– Print each variable during run…

quick for some bugs, but tedious

– Use a debugging tool Preferred method!

– GDB– Visual C++ Debugger– Eclipse CDT

and other opensource C++ IDE/Debuggers

Page 13: Warmup Write a function to add two integer parameters and return the result.

Essential Debugger Features

Line by line code execution Stacktrace of previously called functions View variable values at any line View POINTER values at any line Stop the code at a certain point (breakpoint) Show line where program core-dumps

Page 14: Warmup Write a function to add two integer parameters and return the result.

Challenge

For next class:– Write a function that sorts an array that is passed

as a parameter (your function can also accept the size of the array)

– Use the FEWEST lines of code Can you do it in less than 10? Less than 5?