Presentation on theme: "Objective: Dealing with data in C++ Agenda: Notes Essay Help."— Presentation transcript:
Objective: Dealing with data in C++ Agenda: Notes Essay Help
DataTypes Boolean data Keyword: bool True or False Gender type: male or female
Data Types Character data type Keyward: char Individual Numbers (0-9), alphabet, symbols, tab, backspace, enter key Use apostrophe before and after characters: ‘z’
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
Data types String Collection of text “Hello World”
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;
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;
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
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;
More initializations int num1, num2 = 5; REMEMBER: any information put into a textbox is text. A number is still considered a string “20”
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
Another TryParse Example double temperature; double::TryParse(textbox1->Text, temperature);
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!!
Activities: Partner to get others to complete the Hello World assignment. Prrogramming is a collaborative effort!!
Activities Complete Hello World Programming Activities and Worksheet questions Complete Activity Worksheet #2
Your consent to our cookies if you continue to use this website.