lec02-cpp_basics_part1

lec02-cpp_basics_part1 - CSC 1111 Introduction to Computing...

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

View Full Document Right Arrow Icon
1 CSC 1111 Introduction to Computing using C++ C++ Basics (Part 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
2 Outlines Syntax Data Types Constants / Literals Variables Assignment Operator Identifiers, Reserved Words, Predefined Identifiers
Background image of page 2
3 Language Syntax Like grammar and spellings in English Each language has its own syntax (defined by a set of rules) These rules are very strict and must be obeyed. A program can only be compiled successfully if it is free of syntax errors.
Background image of page 3

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

View Full DocumentRight Arrow Icon
4 #include <iostream> using namespace std; int main() { Cout << "Good morning!" ; Cout << "\n" ; return 0; } Can you spot the error(s)? 1 2 3 4 5 6 7 8 9 Some Basic Rules C++ is case sensitive Space , newline , and tab characters are all considered as whitespace characters. Multiple whitespace characters are treated as one whitespace character.
Background image of page 4
5 Data Data are represented as 0's and 1's by the computer. Suppose the following data is stored at certain memory location: 00001111 Can you tell what it represents?
Background image of page 5

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

View Full DocumentRight Arrow Icon
6 Data Type A datum has a value and type The data type tells us What the value represents How we can manipulate the datum (or how the computers process the datum) Value Type 0.14 Real number 'A' Letter 26098400 Integer 26098400 Phone number
Background image of page 6
7 C++ Common Data Types int – integers (whole numbers) double – real or floating point numbers char – characters string – strings (sequence of characters) bool – Boolean ( true or false )
Background image of page 7

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

View Full DocumentRight Arrow Icon
Numerical Constants How we can represent numerical values in C++ code. Integers Numbers without decimal points 0 , -100 , 2048 , 203139 1,000,000 (Wrong! Cannot use comma) Real or floating point numbers Numbers which can have decimal points 0.0 , -100.230 , 3.1416 , .244 , -.9101 , 1. A decimal point makes a big difference! 10
Background image of page 8
Image of page 9
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 26

lec02-cpp_basics_part1 - CSC 1111 Introduction to Computing...

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

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