SlideServe
Menu
Préférences
© SlideServe · v2026

Engineering 1020

katen avatar
9 diapositives · 330 Views · Oct 05, 2014

Engineering 1020. Introduction to Programming Peter King peter.king@mun.ca www.engr.mun.ca/~peter Winter 2010. ENGI 1020: Examples. Lecture example from last class *. ENGI 1020: Examples. IDE Integrated Development Environment Eclipse Teaching Machine

Engineering 1020 - slide 1
01 / 9Engineering 1020
1 / 17

Télécharger la présentation

Engineering 1020
Une image / un lien ci-dessous est fourni (tel quel) pour télécharger la présentation

Politique de téléchargement : le contenu du site vous est fourni TEL QUEL pour votre information et votre usage personnel ; il ne peut être vendu, concédé sous licence ni partagé sur d’autres sites sans l’accord de son auteur.Le contenu vous est fourni TEL QUEL, pour votre information et votre usage personnel uniquement. Téléchargez la présentation en cliquant sur ce lien. Lors du téléchargement, si vous ne parvenez pas à télécharger une présentation, l’éditeur a peut-être supprimé le fichier de son serveur.Pendant le téléchargement, si vous ne parvenez pas à obtenir une présentation, le fichier a peut-être été supprimé par l’éditeur.

F I N

Plus de contenu associé

Transcription de la présentation
  1. Engineering 1020 Introduction to Programming Peter King peter.king@mun.ca www.engr.mun.ca/~peter Winter 2010

  2. ENGI 1020: Examples • Lecture example from last class *

  3. ENGI 1020: Examples • IDE • Integrated Development Environment • Eclipse • Teaching Machine • Editing, compiling and debugging all under one roof • Multiple source files open at once

  4. ENGI 1020: Examples • Debugging • After you hit 'build', the real fun starts • Start at the top • 1 error tends to lead to another • Think logically • What's missing? • Typing error? • Wrong type? • Fresh eyes

  5. ENGI 1020: Examples • Ex #1 • In pre-calculus physics the distance an object travels is given by the formula: • s = ut + 1/2at2 • where u is the initial speed, a is a constant acceleration and t is the time. • Create a function to compute s plus a main function to that tests it by calling it with some values.

  6. ENGI 1020: Examples • #1 • What's the contract? • What data are we agreeing to return? • #returns • What data do we require? • #params • @pre • What should we call the function?

  7. ENGI 1020: Examples • #2 • Create a function to compute the area of a circle given its radius (note that a value for PI is not built in to C++ so use 3.14159) plus a main function to that tests it by calling it with some values.

  8. ENGI 1020: Examples • #2 • What's the contract? • What data are we agreeing to return? • #returns • What data do we require? • #param • @pre • What should we call the function?

  9. ENGI 1020: Examples • #3 • Lets do a simple example, but with more utilization of variables. • Write a function that returns the square of a number. • Write a main function that calls our function once, and then again with the result of the first call • The output would look like: • The square of 2 is 4 • The square of the square of 2 is 16