{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

08 Fundamental Data types

08 Fundamental Data types - z and then uses it when the...

Info icon This preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Fundamental Data Types Numbers: Integers (int): cannot have a decimal point & double: a floating point number (can have a decimal point) -integers are used to make your intensions clear (eg a certain number should not have a decimal) and because an integer takes up less space and memory. Declare and assign: int a; (declare) a=3; (assign) int a=3; (initialize) Variable Names: -1st character has to be a letter or an underscore -following must be letters, numbers, or underscore -all are case sensitive Convention: -Variable names start with lower case -use underscore or camel case foe multiple words example: interest_rate or interestRate (camel case) Cin and Cout: Cout is used to put words on the screen exactly as typed or to put out a variable cout<<"write this on the screen"; cout<<interest_rate; cout<<"The interest rate is " <<interest_rate <<"\n"; Cin is used to take input from the user. In the example it asked the user for the value of
Image of page 1

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

View Full Document Right Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: z and then uses it when the user enters it. int z; cin>> z; Two inputs: int z; int a; cin>>z>>a;-Multiple inputs are seperated by white space (space, tab, or return) Comments: Used to keep track of what you are doing when codes begin to get longer. When using comments you can write comments in the code that the compiler will ignore. \\ (will ignore this line) /* (will ignore everything between the two slashes and stars) *\ Mathematical Stuff: addition, subtraction, and multiplication Depending on whether or not you use a double or an int it will just add(+) subtract(-) and multiply(*) when you tell it to double total = 0.01 + 0.24; cout<<"Total =" << total << "\n"; This would display: Total=.25 Devision: Inter division: 7/4=1 % will give you the remainder of integer division 7%4=3 Floating Point division: 7.0/4=1.75 (one of the numbers has to be a double)...
View Full Document

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern