Presentation is loading. Please wait.

Presentation is loading. Please wait.

Objective: Dealing with data in C++ Agenda: Notes Essay Help.

Similar presentations


Presentation on theme: "Objective: Dealing with data in C++ Agenda: Notes Essay Help."— Presentation transcript:

1 Objective: Dealing with data in C++ Agenda: Notes Essay Help

2 DataTypes Boolean data Keyword: bool True or False Gender type: male or female

3 Data Types Character data type Keyward: char Individual Numbers (0-9), alphabet, symbols, tab, backspace, enter key Use apostrophe before and after characters: ‘z’

4 Data Types Integer data ( 0, + and - whole numbers Short, int or long We will usually use int 3.25 (decimal number) is a real number Float are 3.4 X 10 -38 to 3.4 X 10 38 Double are from 1.7 x 10 --308 to 1.7 x 10 308

5 Data types String Collection of text “Hello World”

6 Variables Variables store information for the program To create a variable you declare it Usually the first thing done in an event-handler to store input etc. A variable declaration includes data type and mae of variable: int length; int height; int width;

7 Declaring variables If variables are of the same data type, you can declare them on one line: int height, width, length; More examples: bool female; char middle-initial; int age; float average; double gpa;

8 Variable Name Rules Must begin with a letter or underscore (_) Can only use letters, digits, or underscore Are case-sensitive DO NOT use a space Each variable name in a program must be unique Can’t use C++ keywords

9 Initializing Variables Put data into the variable for the first time after it is declared. All numeric variables are initialized to 0 by default Other types must be initialized Can declare and initialize bool female – false; char middle_initial = ‘S”; float average = 98.6; double gpa = 3.42;

10 More initializations int num1, num2 = 5; REMEMBER: any information put into a textbox is text. A number is still considered a string “20”

11 Converting text to numbers TryParse() Method int age; Int 32::TryParse(textbox1->Text, age); Int 32 is the type of data ::Scope resolution operator TryParse() Method to try to see is a string can be a number

12 Another TryParse Example double temperature; double::TryParse(textbox1->Text, temperature);

13 Essay Directions Please use google chrome to print. The browser has the print functionality built right in without having to save. Chrome is already installed on our machines. Peer edit Make changes and turn in!!

14 Activities: Partner to get others to complete the Hello World assignment. Prrogramming is a collaborative effort!!

15 Activities Complete Hello World Programming Activities and Worksheet questions Complete Activity Worksheet #2

16


Download ppt "Objective: Dealing with data in C++ Agenda: Notes Essay Help."

Similar presentations


Ads by Google