22 Pages

208 Day 03 Assgn&Data types

Course: NSSA 4002 208, Spring 2009
School: RIT
Rating:
 
 
 
 
 

Word Count: 736

Document Preview

Intro. 4002-208 to Prog. [in C++] Day 03 Assignment Statement & Data Types Objectives Numeric data types Assignment Statement Type conversions 4002-208 Page 2 Data Types Integer (counting) char 1 byte short 2 bytes int 4 bytes -128 to +127 -32,768 to +32,767 +/- 2 x 109 Examples int age; int age, numEmp; int age = 0; //declare age with initial value of 0 Most commonly used types are in...

Register Now

Unformatted Document Excerpt

Coursehero >> New York >> RIT >> NSSA 4002 208

Course Hero has millions of student submitted documents similar to the one
below including study guides, practice problems, reference materials, practice exams, textbook help and tutor support.

Course Hero has millions of student submitted documents similar to the one below including study guides, practice problems, reference materials, practice exams, textbook help and tutor support.
Intro. 4002-208 to Prog. [in C++] Day 03 Assignment Statement & Data Types Objectives Numeric data types Assignment Statement Type conversions 4002-208 Page 2 Data Types Integer (counting) char 1 byte short 2 bytes int 4 bytes -128 to +127 -32,768 to +32,767 +/- 2 x 109 Examples int age; int age, numEmp; int age = 0; //declare age with initial value of 0 Most commonly used types are in bold. 4002-208 Page 3 Double Data Types Floating Point (calculator numbers) float 4 bytes double 8 bytes 7 digits and 10+/-38 15 digits and 10+/-308 Examples double weight = 3.4; double side1 = 0.0, side2 = 1.0, side3 = 2.3; 4002-208 Page 4 Numeric Literal A number such as 7 or 3.14159 used in an arithmetic expression. The literal must be stored in memory How is the data type determined? If a decimal point is present, then double otherwise int. int: 7 +7 -7 double: -7.2 7. 7.0 6.023e-23 4002-208 Page 5 Assignment Statement - Basics variable = expression; The symbol = is not algebraic equality. First, the value of the expression is calculated. Second, the value of the expression is assigned to the variable on the left of the assignment sign. 4002-208 Page 6 Arithmetic Operators Standard operators: + (addition) - (subtraction) * (multiplication) / (division) Valid for integer and floating point types 4002-208 Page 7 Modulus Operator for Integers If both operands are integers, the result of the operation is always an integer. The result of the division operator is the quotient. The result of the modulus (%) operator is the remainder. 74 / 12 has a result of 6 (quotient only) 74 % 12 has a result of 2 (remainder only) 4002-208 Page 8 Examples double dv1 = 2.4; double dv2 = 2.0; double dv3 = 3.5; double dv4, dv5, dv6, dv7; dv4 = dv1 + dv2 + dv3; dv5 = dv1 + dv2 dv3; dv6 = dv1 * dv2 dv3; dv7 = dv1 / dv2 * dv3; 4002-208 Page 9 Rules Precedence (order of evaluation) Unary +, unary - (highest) */ +(lowest) Operators of same precedence are done left to right. An expression inside parenthesis ( ) is done first. 4002-208 Page 10 More Examples double dv1 = 2.4; double dv2 = 2.0; double dv3 = 3.5; double dv8, dv9, dv10, dv11; dv8 = dv1 * dv2 + dv3; dv9 = dv1 * ( dv2 + dv3); dv10 = dv1 / dv2 dv3; dv11 = dv1 / (dv2 - dv3); 4002-208 Page 11 Number Representation Floating point numbers are represented using IEEE 754 standard Similar to scientific notation d.dddd x 10exp except in binary. steve.hollasch.net/cgindex/coding/ieeefloat.html Integer numbers are by represented a method known as 2s complement www.cs.cornell.edu/~tomf/notes/cps104/twoscomp.html 4002-208 Page 12 Mixed mode operation If the types of the two numeric operands are different, the value of the smaller type is converted to the larger type. Order: short (smallest) int long float double (largest) 4002-208 Page 13 Promotion The data in the smaller type is promoted to a larger type. No data is lost. Other examples float to double short to int int to double 4002-208 Page 14 Examples double dv1 = 2.4; double dv2 = 2.0; int iv1 = 4; int iv2 = 6; double dv12, dv13, dv14; dv12 = dv1 + iv1; dv13 = dv2 + iv1 * iv2; dv14 = dv2 / (iv1 / iv2); 4002-208 Page 15 Multiple Assignments The value of the expression may be assigned to several variables. length = width = side + 2.0; The value of side + 2.0 is calculated. This value is stored into width. The value stored in width is then stored into length. More on this careful wording later. 4002-208 Page 16 Multiple Assignments The value of the expression may be assigned to several variables. length = width = side + 2.0; The value of side + 2.0 is calculated. This value is stored into width. The value stored in width is then stored into length. More on this careful wording later. 4002-208 Page 17 Type Conversion When the type of the expression does not match the type of the variable. Examples: double dblVar; int intVar; dblVar = 7; //integer 7 assigned to double intVar = 7.3; //double 7.3 assigned to integer What happens? 4002-208 Page 18 Conversion (cont.) The value of the expression on the right must be converted to the type of the variable on the left of the =. dblVar = 7; //the integer 7 is converted to a double 7.0 - Promotion intVar = 7.3; //double value 7.3 is truncated to an integer 7 - Demotion 4002-208 Page 19 Types of Conversions Implicit The conversion happens automatically. Maybe be unexpected. Loss of accuracy as the larger value is truncated so that it can be stored in smaller location. Warning issued by most compilers. Explicit Conversion indicated by programmer. 4002-208 Page 20 Explicit Type Conversion When programmer uses a type cast to convert one data type to another. Example: int n; n = static_cast <int> (3.99); //C++ style - orn = (int) 3.99; //C style 4002-208 Page 21 Operator Precedence Highest to lowest precedence () function calls - ,+ unary operators (- called negation) *,/,% + , - (binary operators) Evaluate expression inside ( ) first. 4002-208 Page 22
Find millions of documents on Course Hero - Study Guides, Lecture Notes, Reference Materials, Practice Exams and more. Course Hero has millions of course specific materials providing students with the best way to expand their education.

Below is a small sample set of documents:

RIT - NSSA - 4002 208
4002-208 Intro. to Prog. [in C+]Day 04 Assignment Statement &amp; Data TypesObjectives Non-numeric data types Input statement Input Buffer Formatting output4002-208Page 2Boolean Data Type bool 1 byte that encodes true or false The value 0
RIT - NSSA - 4002 208
4002-208 Intro. to Prog. [in C+] Day 05 SelectionObjectives Basic if statement Relational conditions Nested if statements Logical conditions4002-2082Uses of if Statement Algorithm Used in algorithm to compute correct values. Data vali
RIT - NSSA - 4002 208
4002-208 Intro. to Prog. [in C+] Day 06 More on SelectionExpanded Conditions The condition of an if statement can contain the Boolean operators And Or Not &amp; | !4002-2082Truth Table for And OperatorGiven a condition b1 &amp; b2 where b1 and b
RIT - NSSA - 4002 208
4002-208 Intro. to Prog. [in C+] Day 07 RepetitionObjectives Basics of a loop Overview of 3 loops in C+ Mechanics of a while loop Use of while loop for data validation Writing code to validate input4002-2082Basics Group of statements wi
RIT - NSSA - 4002 208
4002-208 Intro. to Prog. [in C+] Day 09 More on RepetitionObjectives Review while loop for loop Auto increment operator Accumulator Compound operator4002-2082Review of while loopwhile (loop condition) { loop body } Loop condition is a
RIT - NSSA - 4002 208
4002-208 Intro. to Prog. [in C+] Day 10 Yet more on RepetitionObjectives Basics of the do-while statement Using do-while for a &quot;Yes/No&quot; loop Writing a do-while for data validation Writing a while loop to act as a for loop4002-2082Review o
RIT - NSSA - 4002 208
4002-208 Intro. to Prog. [in C+] Day 11 Introduction to FunctionsObjectives Why use functions? How to write a function Function prototype Random numbers4002-2082Why Functions To avoid writing the same code more than once write once, use
RIT - NSSA - 4002 208
4002-208 Intro. to Prog. [in C+] Day 12 More on FunctionsObjectives Models of function uses Documentation4002-2082Model of a function 0 or more parametersNamed block of code0 or 1 return value4002-2083Output Functions 1 or more
RIT - NSSA - 4002 208
4002-208 Intro. to Prog. [in C+] Day 13 Yet More on FunctionsObjectives Review of Functions Storage classes Scope Rules Separate Compilation using projects4002-2082Writing a function Function headerReturn type or void if no return type
RIT - NSSA - 4002 208
4002-208Practice Exam 1 Sample Problem for Part 2You are to write an entire C+ program to compute the cost of buying a number of movie tickets. The price for a ticket varies depending on the buyers age. If the buyer is 62 or older, the buyer is a
RIT - NSSA - 4002 208
Rochester Institute of Technology Golisano College of Computing and Information Sciences Department of Information TechnologyName: _ 4002-208 Lab 7: More FunctionsExercise 1 Calculating weekly wage (3 points)This exercise must be completed durin
RIT - NSSA - 4002 208
Name: _ 4002-208 Lab 03: Extended Stock Purchase ProgramExercise 1 Data Validation (3 points)The exercise must be completed during the lab period. You are to extend the program from Lab 02. Download the zip file from your lab day module within the
RIT - NSSA - 4002 208
Rochester Institute of Technology Golisano College of Computing and Information Sciences Department of Information TechnologyName: _ 4002-208 Lab 4: switch statement and sentinel loopsExercise 1 switch statement (2 points)This exercise must be c
RIT - NSSA - 4002 208
Rochester Institute of Technology Golisano College of Computing and Information Sciences Department of Information Technology 4002-208 Introduction to Programming in [C+] Updated Project 2 [changes in yellow]Purpose Project 2 extends Project 1 by al
RIT - NSSA - 4002 208
Rochester Institute of Technology Golisano College of Computing and Information Sciences Department of Information Technology 4002-208 Introduction to Programming in [C+] Project 3Purpose I know that youve probably had your fill of transmission time
RIT - NSSA - 4002 208
Rochester Institute of Technology Golisano College of Computing and Information Sciences Department of Information Technology 4002-208 Introduction to Programming [in C+] Project 5 A Taxing AssignmentProblem Statement You are to write a program to p
RIT - 0501 - CrimJust
11 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 VS. DOES 1-4, VS.UNITED STATES DISTRICT COURT FOR THE DISTRICT OF MASSACHUSETTS -CAPITAL RECORDS, INC., ET AL., PLAINTIFFS ) ) ) ) ) ) ) ) ) PLAINTIFFS ) ) ) DEFENDANTS --MOTION H
RIT - 0501 - CrimJust
RIT - 0501 - CrimJust
U.S. Department of Justice Office of the Inspector GeneralA Review of the FBIs Use of National Security Letters: Assessment of Corrective Actions and Examination of NSL Usage in 2006Office of the Inspector General March 2008UNCLASSIFIEDA-1A
RIT - 0501 - CrimJust
UNITED STATES DISTRICT COURT SOUTHERN DISTRICT OF NEW YORK -x THE ASSOCIATED PRESS, Plaintiff, -against08 Civ. 323 (PKC) MEMORANDUM AND ORDERALL HEADLINE NEWS CORP., AHN MEDIA CORP., W. JEFFREY BROWN and DANIELLE GEORGE, Defendants. -x P. KEVIN CAS
RIT - 0501 - CrimJust
Case 1:03-cv-11661-NGDocument 761Filed 02/27/2009Page 1 of 1
RIT - 0501 - CrimJust
RIT - 0501 - CrimJust
Case 7:06-cv-11520-SCR-PEDDocument 89Filed 02/26/2009Page 1 of 1
RIT - 0501 - CrimJust
IntheMatterof ) ) Google,Inc.and ) CloudComputingServices) _) ComplaintandRequestforInjunction,Request forInvestigationandforOtherRelief SUMMARYOFCOMPLAINT 1. Thiscomplaintconcernsprivacyandsecurityrisksassociatedwiththe provisionofCloudCom
RIT - 0501 - CrimJust
soulxtcScoffs at RIAA's demands that he disclose details of the &quot;homemade music CD&quot; collection of Joel Tenenbaum, an accused file-sharer, he's representing in court.
RIT - 0501 - CrimJust
Case 3:09-cv-00540-JMMDocument 16Filed 03/30/2009Page 1 of 29IN THE UNITED STATES DISTRICT COURT FOR THE MIDDLE DISTRICT OF PENNSYLVANIA MARYJO MIILLER, individually and on behalf of her minor daughter, Marissa Miller, JAMI DAY, individually
RIT - 0501 - CrimJust
Case 2:06-cv-02620-ABC-FMODocument 19Filed 02/02/2007Page 1 of 5Case 2:06-cv-02620-ABC-FMODocument 19Filed 02/02/2007Page 2 of 5Case 2:06-cv-02620-ABC-FMODocument 19Filed 02/02/2007Page 3 of 5Case 2:06-cv-02620-ABC-FMODocume
RIT - 0501 - CrimJust
F:\M11\NADLER\NADLER_010.XML[110H3189]. (Original Signature of Member)111TH CONGRESS 1ST SESSIONH. R. llTo establish reasonable procedural protections for the use of national security letters, and for other purposes.IN THE HOUSE OF REPRES
RIT - 0501 - CrimJust
AO 91 Rev. 11/97CRIMINAL COMPLAINT CENTRAL DISTRICT O F CA LIFORNIADOCKET NO.UNITED STATES DISTRICT COURT UNITED STATES OF AMERICA v. PAUL G. ASHLEY, JONATHAN DAVID HALL, JOSHUA JAMES SCHICHTEL, RICHARD ROBY and LEE GRAHAM WALKERMAGISTRATE'S C
RIT - 0501 - CrimJust
RIT - 0501 - CrimJust
U.S. Customs and Border Protection Policy Regarding Border Search of Information July 16,2008This policy provides guidance to U.S Customs and Border Protection (CBP) Officers, Border Patrol Agents, Air and Marine Agents, Internal Affairs Agents, an
RIT - 0501 - CrimJust
IN THE UNITED STATES DISTRICT COURT FOR THE EASTERN DISTRICT OF NORTH CAROLINA Civil Action No. 5:08-CV-00131-D SONY BMG MUSIC ENTERTAINMENT, Inc., UMG RECORDINGS Inc., ELECTRA ENTERTAINMENT GROUP, Inc., BMG MUSIC, and MOTOWN RECORD COMPANY, L.P., Pl
RIT - 0501 - CrimJust
UNITED STATES DISTRICT COURT FOR THE EASTERN DISTRICT OF NORTH CAROLINA WESTERN DIVISION No.: 5:08-cv-00131-D SONY BMG MUSIC ENTERTAINMENT, UMG RECORDINGS INC., ELECTRA ENTERTAINMENT GROUP, INC., BMG MUSIC, AND MOTOWN RECORD COMPANY, L.P., Plaintiffs
RIT - 0501 - CrimJust
United States Court of Appeals for the Federal Circuit2008-1352 TRIANTAFYLLOS TAFAS, Plaintiff-Appellee, and SMITHKLINE BEECHAM CORPORATION (doing business as GlaxoSmithKline), SMITHKLINE BEECHAM PLC, and GLAXO GROUP LIMITED (doing business as Glaxo
RIT - 0501 - CrimJust
Case 1:03-cv-11661-NGDocument 760Filed 02/24/2009Page 1 of 3IN THE UNITED STATES DISTRICT COURT FOR THE DISTRICT OF MASSACHUSETTS ) ) ) Plaintiffs, ) ) v. ) ) NOOR ALAUJUN, ) ) Defendant. ) _) CAPITOL RECORDS, INC., et al.Civil Action No. 0
RIT - 0501 - CrimJust
Case 1:03-cv-11661-NGDocument 763Filed 02/27/2009Page 1 of 3Case 1:03-cv-11661-NGDocument 763Filed 02/27/2009Page 2 of 3Case 1:03-cv-11661-NGDocument 763Filed 02/27/2009Page 3 of 3
RIT - 0501 - CrimJust
Case 1:03-cv-11661-NGDocument 763-2Filed 02/27/2009Page 1 of 5Case 1:03-cv-11661-NGDocument 763-2Filed 02/27/2009Page 2 of 5Case 1:03-cv-11661-NGDocument 763-2Filed 02/27/2009Page 3 of 5Case 1:03-cv-11661-NGDocument 763-2F
RIT - 0501 - CrimJust
Case 1:03-cv-11661-NGDocument 793Filed 03/22/2009Page 1 of 39IN THE UNITED STATES DISTRICT COURT FOR THE DISTRICT OF MASSACHUSETTS ) CAPITOL RECORDS, INC., et al. ) ) Plaintiffs, ) ) v. ) ) NOOR ALAUJUN, ) ) Defendant. ) __)Civil Action No.
RIT - 0501 - CrimJust
circular 92Copyright Law of the United Statesand Related Laws Contained in Ttle 17 of the United States Codeoctober 2007The Constitutional Provision Respecting CopyrightThe Congress shall have Power To promote the Progress of Science and u
RIT - 0501 - CrimJust
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 / WLH:wlh The Grand Jury charges: [18 U.S.C. 1030(a)(5)(A)(i), (B)(i)] Introductory Allegations At all times relevant to this Indictment: 1. Pacific Energy Resources, Ltd. (P
RIT - 0501 - CrimJust
Case 1:07-cv-02103-LLSDocument 117Filed 07/02/2008Page 1 of 25UNITED STATES DISTRICT COURT SOUTHERN DISTRICT OF NEW YORK -x VIACOM INTERNATIONAL INC., et al., Plaintiffs, v. YOUTUBE INC., YOUTUBE LLC, and GOOGLE INC., Defendants. -x THE FOOTB
RIT - 0501 - CrimJust
Capitol v. Thomas Expert witness report by Dr. Yongdae Kim, Ph.D.March 3, 20091OverviewThis report addresses the overall problem of identifying computers remotely through the Internet, the nature and extent of material errors in the expert wit
RIT - 0501 - CrimJust
Eastern District of New York - Live Database Version ESR 3.2.2https:/ecf.nyed.uscourts.gov/cgi-bin/DktRpt.pl?982452137387822-L_80.U.S. District Court Eastern District of New York (Brooklyn) CIVIL DOCKET FOR CASE #: 1:07-cv-00414-DGT-RMLVirgin R
UC Davis - EXB - 101
Study Questions: Lecture 17-19 Exercise Metabolism What hormone is responsible for regulating glucose uptake at rest and following a meal? Insulin What accounts for the increase in glucose uptake with exercise? Glucose needs to be utilized as another
UC Davis - EXB - 101
ReviewQuestions,EXB101,Fall,2008,Lectures3338LECTURE34:PrinciplesofEnvironmentalPhysiologyandTemperatureRegulation FACTS 1. Howmuchofaneffectdoesambienttemperaturehaveonperformance? Itaffectswhetherornotheatisabletobelostduringexercise.Betterperform
UC Davis - EXB - 101
LECTURES22,23,24,and25:CardiovascularStructureandFunction FACTS 1. DescribeVO2usingtheFickprincipleandidentifytheequationsforbothpulmonary(tothelungsandback) &amp;cvsystems. VO2=Qcx(arterial[O2]venous[O2]) Ingeneral:oxygenconsumption=totalbloodflow(cardi
Berkeley - MSE - 104
UNIVERSITY OF CALIFORNIA College of Engineering Department of Materials Science &amp; Engineering Professor R. GronskyMSE 104Solution 2-14Problem 2-14 Pole A, whose coordinates are 20N, 50E, is to be rotated about the axes described below. In each
Academy of Design Chicago - HISTORY - 0009
&quot;The knowledge that we value the most is the knowledge for which we can provide the strongest justifications.&quot; To what extent would you agree with this claim? The defining and pursuit of knowledge have been paramount to human intellectual growth. The
Academy of Design Chicago - HISTORY - 0009
To what extent was the partition of India due to Great Britains Involvement in World War Two? A. Plan of InvestigationTo what extent was the partition of India due to Great Britains Involvement in World War Two? On August 14, 1947, the Dominion of
Academy of Design Chicago - HISTORY - 0009
Hendley 1 Johanna Hendley AP/IB Literature and Composition Mrs. Griffo 6 January 2009 Words: 1,349 The Death of Ivan Ilyich Key Passage The chosen passage is from chapter six of Leo Tolstoys The Death of Ivan Ilyich. In the passage, Tolstoy uses pers
Academy of Design Chicago - HISTORY - 0009
Crows beaks are not strong enough to break some nuts open. In order to open these nuts, they will repeatedly drop the nut on a hard surface until it opens. This investigation will explore the relationship between the height of the drop, and the numbe
Academy of Design Chicago - HISTORY - 0009
Language/Thinking/Intelligence Psychology Terms Thinking Cognition - conscious process of knowing or being aware of thoughts or perceptions,including understanding and reasoning Concept - an abstract or general idea inferred or derived from specific
Academy of Design Chicago - HISTORY - 0009
IntroductionThe aim of this study is to replicate Herman Ebbinghaus initial experiment in order to discover the amount of time required to recall different sets of nonsense syllables. When Ebbinghaus first designed this experiment, he used nonsense
Academy of Design Chicago - HISTORY - 0009
According to Hume, knowledge consists of information that can be gained from the inspection of two or more ideas. Discovering causation is different. This sort of information does not merely depend upon looking at two or more ideas. If we examine a s
Academy of Design Chicago - HISTORY - 0009
&quot;The Second Coming&quot;Summary The speaker describes a nightmarish scene: the falcon, turning in a widening &quot;gyre&quot; (spiral), cannot hear the falconer; &quot;Things fall apart; the center cannot hold&quot;; anarchy is loosed upon the world; &quot;The blood-dimmed tide
Colorado - EMUS - 1832
Time is changed to 8:30100 point exam like midterm, 8 listening identifying era or country, 8-10 more for from listening, roughly 30% of test is listening. Final Review Sheet MUEL 1832-002 Fall 2008 Terms/Concepts (multiple choice/matching/true-fals
Colorado - EMUS - 1832
MUEL 1832 Mid-term Review Sheet (Preliminary-additions may appear) Terms Ballad opera- colonial period in 18th century, comedy, included spoken word, emphasis on plot, short songs, Oratorio- genre of choral music with sacred words, quite long, clear
Colorado - HIST - 2616
Charles Ryan Sundling HIST 2616 Failure without Native American Women La Nouvelle France, Espaa dos, or even United Native American Tribes could have been names for what we now know as the United States of America, if it were not for the help of the
Colorado - HIST - 2616
Final Exam Possible Prompts and Structure HIST 2616 YOU WILL NEED TO BRING A BLANK BLUE BOOK TO THE EXAM. DO NOT WRITE YOUR NAME ON IT BEFOREHAND. You might be kind and bring an extra or two since I will not read any exam that is not written in a blu
Colorado - HIST - 2616
Charles Ryan Sundling HIST 2616 Ball Gender and Sarah Rosetta Wakeman The Civil War has been called the war of brother against brother but what about the sisters? Not all women sat at home and acted lady like; some took their rifles in hand and fough