unit02mp - Course Philosophy Dr. Pryor FAQ's ME205 TA Page...

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

View Full Document Right Arrow Icon
Course Philosophy Dr. Pryor FAQ's ME205 TA Page Office Hours Other Resources Syllabus Tutorials Countdown to the due date: 70 days, 4 hours, 46 minutes Home » 02 bam2734 My account Log out Test Center
Background image of page 1

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

View Full DocumentRight Arrow Icon
Units and Reviews 00 01 02 Unit 02 It's a Big World. Unit Objectives Learn the fundamental data types used to store data. Learn how to collect data from user. Perform some more complicated math operations on our data. Understand how to ask the most important question in C++? Hint: it begins with if. .. Understand Enumeration: A simple way to make your own data types. Introduction Congratulations! You have finished your first Readiness Test with no errors. You should be proud that you have actually written and compiled a simple stand alone application. I know it did not do a whole lot. ....yet. And now it is time to move past simple greetings and a glorified calculator. So what kind of functionality do we need? We will need our program to store data. We will need to ask users for input. And we will need to it check this input to make sure they didn't do anything silly that might confuse our program. Once we have these three basic elements in place, we are going to quickly review enumeration which will hint at the power of C++. Finally we will take a quick look under the hood so you can understand just a little about how the compiler gets the computer to follow your instructions.
Background image of page 2
Task 1 - Storing your data. Back in high school when you studied algebra, you were always looking for the value of the mysterious x . As you learned then, x was a variable and took on different values in different problems. Well, programs have variables too. These variables are placeholders for values that can change during the course of a program. In C++, there are 5 fundamental data types we can use when creating variables. 1. booleans (called bool: true or false) 2. characters (called char) 3. integers (called int) 4. floating point numbers (called float) 5. double precision floating point numbers (called double) Each time you want to create a new instance of a data type, you must give it a name so the compiler can tell it apart from all the other data types. These are called variables which can be declared in C++ rather simply. bool myBool = false; char myChar = 'a'; char anotherChar = 'T'; int a = 3; float radius = 5.67; double lightspeed = 299792458; When you first declare a variable, you don't have to give it a value. But it is strongly recommended that you do. When you don't assign a value, the compiler doesn't either, not even a common sense value like 0. So if don't assign values, the assumed values are essentially random. I have seen this confuse a lot of beginning programmers. Depending on the data type you choose, the C++ compiler will do different things, it will treat your data in
Background image of page 3

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

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

Page1 / 11

unit02mp - Course Philosophy Dr. Pryor FAQ's ME205 TA Page...

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

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