Chapter 3 - 3 Chapter C6374 40569 3:53 PM Page 83 3 Data...

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

View Full Document Right Arrow Icon
Data Types and Expressions 3 In this chapter, you will: ° Declare memory locations for data ° Explore the relationship between classes, objects, and types ° Use predefined data types ° Use integral data types ° Use floating-point types ° Learn about the decimal data type ° Declare Boolean variables ° Declare and manipulate strings ° Work with constants ° Write assignment statements using arithmetic operators ° Learn about the order of operations ° Learn special formatting rules for currency ° Work through a programming example that illustrates the chapter’s concepts 3 Chapter C6374 40569 3/26/07 3:53 PM Page 83
Background image of page 1

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

View Full Document Right Arrow Icon
84 Chapter 3 Data Types and Expressions Chapter 2 introduced you to the basic elements of a C# program. You discovered the requirements for developing, compiling, and executing console applications.The applications you created were restricted to displaying text output, and although these are interesting applications, they are quite limited.This chapter focuses on data. Data is the raw facts—the basic numbers and characters that are manipulated to produce useful information. In this chapter, you begin to see the power of programming when you write applications to per- form calculations.You learn how to declare variables that hold different types of data in memory and see how arithmetic operators react given different kinds of data. M EMORY L OCATIONS FOR D ATA Programs manipulate data, and data can take the form of a number, single character, or com- bination of characters.The following are all examples of data: 18,“Brenda”,‘A’, 3.25, –7, 36724, and 47.23 By themselves, these data items have no value.The number 18 could be an age, temperature, number of students in a class, number of hours you are enrolled in this term, or could represent something totally different.Without identifying and labeling 18, it is a meaningless number. When working with data, the Frst task is to use an identiFer to name the data item. Identifers Identifers are names of elements that appear in a program, such as data items. Some identi- Fers are predeFned; others are user deFned.You have already seen some .NET identiFers when you wrote your Frst program in Chapter 2.These were not reserved keywords, but simply names selected and used by the developers of the .NET platform and the C# lan- guage.The program in Example 2-1 contained the following predeFned identiFers: System , Main , Console , and WriteLine . The namespace identiFer of ProgrammingI and the class identiFer of HelloWorld are user-deFned identiFers selected by the author of the textbook during the creation of the Frst project. Here are the rules for creating an identiFer in C#: 1. A combination of alphabetic characters (a–z and A–Z), numeric digits (0–9), and the underscores (_) can be used. IdentiFers can be long; however, many systems consider the Frst 31 characters unique.
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

Page1 / 52

Chapter 3 - 3 Chapter C6374 40569 3:53 PM Page 83 3 Data...

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

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