1 / 8

CSC 200

CSC 200. Lecture 3 1/27/06 Matt Kayala. Numerical Computation. Maple example of Computer Algebra system Symbolic Computation We could build a system like this with C++ At the level we are at, there are facilities for Numerical Computation Library that must be included #include<cmath>.

gita
Télécharger la présentation

CSC 200

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CSC 200 Lecture 3 1/27/06 Matt Kayala

  2. Numerical Computation • Maple example of Computer Algebra system • Symbolic Computation • We could build a system like this with C++ • At the level we are at, there are facilities for Numerical Computation • Library that must be included #include<cmath>

  3. Functions in cmath (p. 100)

  4. More functions

  5. Strings • char data type holds a single character • Data type to hold more than one char (ie. a “string”) would be useful. • Built into a standard library. • Add this to your code: #include <string>

  6. Strings 2 • Now string is a data type, just like int, double, char, bool. • Can assign vals, use in cin/cout stmts • Ex: string myName = “Matt Kayala”, yourName; cout << “My name is “ << myName << endl; cout << “What is your name? “; cin >> yourName;

  7. Input with Strings • cin with strings inputs up to whitespace • Ex. On this line: cin >> yourName; (I type:)Matt[space]Kayala[enter] Then only up to the first space would be “inserted” into the var yourName. • Is there a way to get around this?

  8. getline() • To get a whole line from the user (not just up to the first whitespace character) we must use “getline” • Syntax: getline(cin, str_var_name); • What it does: extracts up to the newline character (ie. user presses enter) • Ex: string yourName; getline(cin, yourName);

More Related