1 CIS 230 18-Jan-06. 2 Overview Evolution of C++ Programming Style Syntax & Semantics Comments & White Space Data Types Variables & Declarations cout.

Slides:



Advertisements
Similar presentations
1 Demo Reading Assignments Important terms & concepts Fundamental Data Types Identifier Naming Arithmetic Operations Sample Programs CSE Lecture.
Advertisements

True or false A variable of type char can hold the value 301. ( F )
Announcements Quiz 1 Next Week. int : Integer Range of Typically -32,768 to 32,767 (machine and compiler dependent) float : Real Number (i.e., integer.
1 September 6, 2005CS150 Introduction to Computer Science I What Actions Do We Have Part 1 CS150 Introduction to Computer Science I.
1 9/08/06CS150 Introduction to Computer Science 1 Arithmetic Operators.
1 CS 105 Lecture 3 Constants & Expressions Wed, Jan 26, 2011, 4:15 pm.
1 Midterm Review COMP 102. Tips l Eat a light meal before the exam l NO electronic devices (including calculators, dictionaries, phones, pagers, etc.)
1 Expressions, Operators Expressions Operators and Precedence Reading for this class: L&L, 2.4.
Introduction To C++ Programming 1.0 Basic C++ Program Structure 2.0 Program Control 3.0 Array And Structures 4.0 Function 5.0 Pointer 6.0 Secure Programming.
Basic Elements of C++ Chapter 2.
C++ Operators CS242 COMPUTER PROGRAMMING T.Banan Al-Hadlaq.
1 Chapter Two Using Data. 2 Objectives Learn about variable types and how to declare variables Learn how to display variable values Learn about the integral.
VARIABLES, TYPES, INPUT/OUTPUT, ASSIGNMENT OPERATION Shieu-Hong Lin MATH/CS Department Chapel.
CHAPTER 6: PROBLEM SOLVING CONCEPTS FOR THE COMPUTER PROGRAMMING Lec. Ghader R. Kurdi.
Copyright 2006 Addison-Wesley Brief Version of Starting Out with C++ Chapter 2 Introduction to C++
DEPARTMENT OF COMPUTER SCIENCE & TECHNOLOGY FACULTY OF SCIENCE & TECHNOLOGY UNIVERSITY OF UWA WELLASSA 1 CST 221 OBJECT ORIENTED PROGRAMMING(OOP) ( 2 CREDITS.
2440: 211 Interactive Web Programming Expressions & Operators.
M. Taimoor Khan #include void main() { //This is my first C++ Program /* This program will display a string message on.
Simple Data Types and Statements. Namespaces namespace MyNamespace { // …. { MyNamespace::func1() using namespace OtherNamespace; Comments: // /* xxxx.
Operations Making Things Happen. Our Scuba Program #include // cin, cout, > using namespace std; int main() { const double FEET_PER_ATM = 33.0, LBS_PER_SQ_IN_PER_ATM.
CH2 – Using Data. Constant Something which cannot be changed Data Type Format and size of a data item Intrinsic Data Types Pg. 47 – Table 2-1 Basic ones.
CS31: Introduction to Computer Science I Discussion 1A 4/9/2010 Sungwon Yang
CSE1222: Lecture 3The Ohio State University1. Assignment Operations  The C++ assignment operator is: =  Examples: x = 3 * 5; y = x – 7; y = y + 4; Do.
1 CS 1430: Programming in C++. 2 IF Statement if (cond) statement //Next statement if (cond) { statement1 statement2 … } //Next statement.
Arithmetic Operations. Review function statement input/output comment #include data type variable identifier constant declaration.
C++ Programming: Basic Elements of C++.
CIS-165 C++ Programming I CIS-165 C++ Programming I Bergen Community College Prof. Faisal Aljamal.
1 st Semester Module2 Basic C# Concept อภิรักษ์ จันทร์สร้าง Aphirak Jansang Computer Engineering.
CPS120: Introduction to Computer Science Operations Lecture 9.
CSE 332: C++ execution control statements Overview of C++ Execution Control Expressions vs. statements Arithmetic operators and expressions * / % + - Relational.
Programming Fundamental Slides1 Data Types, Identifiers, and Expressions Topics to cover here: Data types Variables and Identifiers Arithmetic and Logical.
C# Basic Concept Thanachat Thanomkulabut. Naming Rules  Letters, digits and underscores(_)  First character  letter or _  Up to 63 characters long.
Prof. Amr Goneid, AUC1 CSCE 110 PROGRAMMING FUNDAMENTALS WITH C++ Prof. Amr Goneid AUC Part 2. Overview of C++
THE BASICS OF A C++ PROGRAM EDP 4 / MATH 23 TTH 5:45 – 7:15.
Computer Science 1620 boolean. Types so far: Integer char, short, int, long Floating Point float, double, long double String sequence of chars.
Computer Engineering 1 st Semester Dr. Rabie A. Ramadan 3.
Lecture #6 OPERATORS AND ITS TYPES By Shahid Naseem (Lecturer)
C++ Lecture 1 Friday, 4 July History of C++ l Built on top of C l C was developed in early 70s from B and BCPL l Object oriented programming paradigm.
1 C++ Data Types structured array struct union class address pointer reference simple integral enum char short int long bool floating float double long.
Data Types Declarations Expressions Data storage C++ Basics.
CHAPTER 2 C++ SYNTAX & SEMANTICS #include using namespace std; int main() { cout
Cosc175/operators1 Algorithms computer as the tool process – algorithm –Arithmetic: addition,subtraction,multiplication,division –Save information for.
PROGRAM ESSENTIALS. TOKENS  SMALLEST UNITS OF A PROGRAM LANGUAGE  Special Symbols  Mathematical Operators  Punctuation  Word Symbols  Key Words.
Recap……Last Time [Variables, Data Types and Constants]
OPERATORS Chapter2:part2. Operators Operators are special symbols used for: mathematical functions assignment statements logical comparisons Examples.
Literals A literal (sometimes called a constant) is a symbol which evaluates to itself, i.e., it is what it appears to be. Examples: 5 int literal
Programming Fundamentals. Summary of Previous Lectures Phases of C++ Environment Data Types cin and cout.
1 st Semester Module2 Basic C# Concept อภิรักษ์ จันทร์สร้าง Aphirak Jansang Computer Engineering.
LESSON 2 Basic of C++.
From Algorithms to Programs Both are sets of instructions on how to do a task Algorithm: –talking to humans, easy to understand –in plain (English) language.
Operations Making Things Happen.
CSE 220 – C Programming Expressions.
Chapter Topics The Basics of a C++ Program Data Types
Computing Fundamentals
Basic Elements of C++.
Chapter 2 Assignment and Interactive Input
Data Types, Identifiers, and Expressions
Introduction to C++ October 2, 2017.
Introduction to C Programming Language
Basic Elements of C++ Chapter 2.
Basic Notions Review what is a variable? value? address? memory location? what is an identifier? variable name? keyword? what is legal identifier? what.
Character Set The character set of C represents alphabet, digit or any symbol used to represent information. Types Character Set Uppercase Alphabets A,
C++ fundamentals Lecture 1, Chapter 2 – pp /22/2018 Y K Choi.
Summary Two basic concepts: variables and assignments Basic types:
Algorithms computer as the tool process – algorithm
Engineering Problem Solving with C++ An Object Based Approach
Engineering Problem Solving with C++ An Object Based Approach
Review of C++ Language Basics
C++ Programming Basics
Presentation transcript:

1 CIS Jan-06

2 Overview Evolution of C++ Programming Style Syntax & Semantics Comments & White Space Data Types Variables & Declarations cout Operators –Arithmetic –Relational –Logical cin Constants

3 Evolution of C++ BCLP (Basic Cambridge Programming Language) –Early 1960s; Martin Richards B –1970; Ken Thompson C –Early 1970s; Dennis Ritchie C++ –1979; Bjarne Stroustrup

4 Programming Style Names Comments Modularity

5 Syntax & Semantics Syntax Ex. “Sue kicked the ball” Semantics + - = [ ] ( )

6 Comments & White Space Comments //One line comment /*Starts comment Block comments – may be several lines long */Ends comment White Space –Space, tab, Statement

7 Data Types Integers ex Floating Point Numbers ex Characters ex.‘a’‘4’‘&’‘A’ Booleans

8 Variables & Declarations Variable Names Declaration Assignment

9 cout #include using namespace std; << “string” \n

10 cout, continued Cout << “Here is\na sample\noutput;” Result: Here is a sample output

11 cout, continued cout << “The answer is” << result; cout << x << y << z;

12 cout, continued a = 23; b = 34; x = 3.945; cout << a << ‘\n’ << b << ‘\n’ << x << ‘\n’; cout << a << b << x; Results:

13 Operators Arithmetic Operators * / % + - Increment & Decrement Relational & Logical Operators > >= < <= != == && ||

14 Arithmetic Operators */%+-*/%+- (Left to Right Precedence)

15 Integer Division 9 / 2 = 4;9 % 2 = 1; 17 / 5 = 3;17 % 3 = 2; 15 / 2 = 7;14 % 2 = 0;

16 Examples a1 = * 6 / 2 -1; a2 = 2 % * 2 -2 / 2; a3 = ( 3 * 9 * ( 3 + (9 * 3 / 3 ) ) );

17 Increment & Decrement Prefix Postfix

18 Increment & Decrement a = 7; b = ++a; b = 8 AND a = 8 a = 7; b = a++; b = 7 and a = 8 a = 7; --a;a--; a = 6

19 Relational Operators Goal: Compare conditions Relational Expression: operand operator operand Operators: greater than = greater than or equal to == equal to!= not equal to

20 Logical Operators Goal: Create more complex conditions Relational Expression: operand operator operand Operators: &&and ||or !not

21 Evaluating Logical Operators Value:10 Interpreted As:TrueFalse Example: ABA && BA || B

22 Relational & Logical Operators Goal: Create more complex comparisons Examples: ( age > 40 ) && ( height > 70 ) ( age > 40 ) || ( height > 70 ) || ( weight > 150 ) ! ( ( age > 40 ) && ( height > 70 ) )

23 Order of Operations () ++-- */% +- <> = ==!= && || =

24 Examples x < y – 3 a = b != c (a = b) != c while (x 5)

25 cin #include using namespace std; >> Examples: cin >> x; cin >> x >> y >> z;Input: xyzxyz 13264

26 Cin, continued char ch1, ch2, ch3; cin >> ch1 << ch2 << ch3;Input: a bc ch1ch2ch3 abcabc

27 cin, continued int a; float x, y; cin >> x >> a >> y; Input: xay

28 Constants Cannot change UPPERCASE Type Form:const type NAME = value;

29 Constants, continued const float PI = ; const int STUDENTS = 31; const char INITIAL = ‘x’; //later in program: answer = PI * radius * radius; totalTests = 3 * STUDENTS;