Lecture 3 - Looping and Counting

Lecture 3 Looping - LoopingandCounting Lecture3 HartmutKaiser [email protected] http/www.cct.lsu.edu/hkaiser/fall_2011/csc1254.html 2 Abstract

Info iconThis preview shows pages 1–8. Sign up to view the full content.

View Full Document Right Arrow Icon
Looping and Counting Lecture 3 Hartmut Kaiser [email protected] http://www.cct.lsu.edu/˜ hkaiser /fall_2011/csc1254.html  
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Abstract First we’ll discuss types and type safety. Then we will modify the program we developed  last time (Framing a Name) to make it more  flexible. We will touch on arithmetic expressions,  looping constructs and conditions. In addition we  will talk about loop invariants and counting. 8/30/2 011,  Lecture  3 CSC 1254,  Fall 2011,  Looping  and  Counting 2
Background image of page 2
Types  C++ provides a set of types E.g. bool, char, int, double Called “built-in types” C++ programmers can define new types Called “user-defined types” We'll get to that eventually The C++ standard library provides a set of types E.g. string, vector, complex 8/30/2 011,  Lecture  3 CSC 1254,  Fall 2011,  Looping  and  Counting 3
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Types and Literals Built-in types Boolean type bool Character types char Integer types int and short and long Boolean literals true, false Character literals 'a', 'x', '4', '\n', '$' Integer literals 0, 1, 123, -6, 0x34,  0xa3 8/30/2 011,  Lecture  3 CSC 1254,  Fall 2011,  Looping  and  Counting 4
Background image of page 4
Types and Value Ranges int short long double float char string 4 bytes: -231…+231-1 2 bytes: -215…+215-1 8 bytes: -263…+263-1 8 bytes: -1.8e+308 …  1.8e+308, 15 digits 4 bytes: -3.4e+38 …  3.4e+38, 6 digits 1 byte: -27…+27-1 8/30/2 011,  Lecture  3 CSC 1254,  Fall 2011,  Looping  and  Counting 5
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Definition and Initialization int a = 7; int b = 9; char c = 'a'; double x = 1.2; std::string s1 = "Hello"; 8/30/2 011,  Lecture  3 CSC 1254,  Fall 2011,  Looping  and  Counting 6 7 9 'a' 1.2 5 | "Hello" 3 | "1.2" a: b: c: x: s1: s2:
Background image of page 6
Objects An object is some memory that can hold a value  (instance) of a given type A variable is a named object A declaration names an object 8/30/2 011,  Lecture  3 CSC 1254,  Fall 2011,  Looping  and  Counting 7 int a = 7; char c = 'x'; complex<double> z(1.0,2.0); string s = "qwerty"; 7 a: "qwerty" 6 s: 'x' c: 1.0 2.0 z:
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 8
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 12/29/2011 for the course CSC 1254 taught by Professor Blanks,l during the Fall '08 term at LSU.

Page1 / 31

Lecture 3 Looping - LoopingandCounting Lecture3 HartmutKaiser [email protected] http/www.cct.lsu.edu/hkaiser/fall_2011/csc1254.html 2 Abstract

This preview shows document pages 1 - 8. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online