lect02_Basics

lect02_Basics - Data types and Expressions Data types and...

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

View Full Document Right Arrow Icon
ata types and Expressions Data types and Expressions SIS1117 Computer Programming CS S Co pute og a g 1
Background image of page 1

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

View Full DocumentRight Arrow Icon
ontents Contents troduction to ariables Introduction to variables Simple data types Declaration statements Assignment statements Arithmetic expressions ype compatibility Type compatibility Usage of String c1117 lecture 2 2
Background image of page 2
ariables Variables programs, we define ariables ore ata. In programs, we define variables to store data. You can store a particular value, and the value can be used within the program later. In reality, a variable corresponds to some location(s) in the main memory . The name of a variable , or an identifier , is a series of characters, following some rules. Characters include: Letters: a to z , A to Z Digits: 0 to 9 Underscore: _ thers: g “ ” “ ” “ ” “ ” c1117 lecture 2 3 Others: e.g. ! , @ , + , { ,
Background image of page 3

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

View Full DocumentRight Arrow Icon
alid entifiers Valid identifiers alid entifier A valid identifier It must start with a letter or an underscore , and The remaining characters must be letters , digits , or underscores . C++ is case-sensitive , so radius , RADIUS , Radius , etc, are different. It cannot be a keyword of C++ What are the keywords in C++ ? c1117 lecture 2 4
Background image of page 4
eywords in C++ Keywords in C++ They are reserved as part of the C++ language and cannot be used as identifiers There are about 70 keywords in C++. e.g. int , return , if , else , double , break , for , … All keywords are listed in the last slide of this lecture notes. They have special meanings to the compiler , and cannot be changed by the programmer. c1117 lecture 2 5
Background image of page 5

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

View Full DocumentRight Arrow Icon
alid C++ entifiers Valid C++ identifiers ? 00612345 rogram cc a_man 200612345 __oOOo__ program.cc year1-student const change%2 an integer ABC123x7 Days_of_Week string rytoavo id sing ose pretty standard names with well cout delete Try to avoid using those pretty standard names with well- known meaning, as variables, although they are not keywords. E.g. cout , cin , string , sqrt , std c1117 lecture 2 6
Background image of page 6
imple data types Simple data types ach ariable associated with a type which Each variable is associated with a type, which specifies the type of data to be stored in the ariable variable.
Background image of page 7

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

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

This document was uploaded on 05/04/2011.

Page1 / 23

lect02_Basics - Data types and Expressions Data types and...

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

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