Subject: Programming in C++ 1. LEARNING OUTCOME  At the end of this slide, student able to:  Know the brief history of C++.  Explore Microsoft Visual.

Slides:



Advertisements
Similar presentations
Lecture Computer Science I - Martin Hardwick Strings #include using namespace std; int main () { string word; cout
Advertisements

C++ Introduction.
C++ Language Fundamentals. 2 Contents 1. Introduction to C++ 2. Basic syntax rules 3. Declaring and using variables.
Introduction to C++ Programming. Brief Facts About C++ Evolved from C Designed and implemented by Bjarne Stroustrup at the Bell Labs in the early 1980s.
CS 6301 Lecture 2: First Program1. CS Topics of this lecture Introduce first program  Explore inputs and outputs of a program Arithmetic using.
Introduction to C++ Programming. A Simple Program: Print a Line of Text // My First C++ Program #include int main( ) { cout
 2003 Prentice Hall, Inc. All rights reserved. 1 Introduction to C++ Programming Outline History of C and C++ C++ Standard Library Object Technology Basics.
True or false A variable of type char can hold the value 301. ( F )
Computer Science 1620 Loops.
Your First C++ Program Aug 27, /27/08 CS 150 Introduction to Computer Science I C++  Based on the C programming language  One of today’s most.
3. The Nuts and Bolts of C++ Computer Programming 3. The Nuts and Bolts of C++ 1 Learning the C++ language 3. The Nuts and Bolts of C++ (4) 10 September.
Computer Science 1620 Accumulators. Recall the solution to our financial program: #include using namespace std; int main() { double balance = ;
Three types of computer languages
Computer Science 117 Intro to C++ 08/26/13. Today Discuss Syllabus Brief History of C++ How to Execute a C++ program. Reading assignment.
1 September 6, 2005CS150 Introduction to Computer Science I What Actions Do We Have Part 1 CS150 Introduction to Computer Science I.
Liang, Introduction to C++ Programming, (c) 2007 Pearson Education, Inc. All rights reserved X 1 Chapter 1 Introduction to Computers, Programs,
1 9/25/06CS150 Introduction to Computer Science 1 Nested Ifs, Logical Operators, exit() Page 194.
 2003 Prentice Hall, Inc. All rights reserved. 1 Machine Languages, Assembly Languages, and High-level Languages Three types of computer languages 1.Machine.
1 8/30/06CS150 Introduction to Computer Science 1 Your First C++ Program.
Liang, Introduction to Programming with C++, Second Edition, (c) 2010 Pearson Education, Inc. All rights reserved Chapter 1 Introduction.
1 CIS Jan Overview Evolution of C++ Programming Style Syntax & Semantics Comments & White Space Data Types Variables & Declarations cout.
Copyright 2003 Scott/Jones Publishing Brief Version of Starting Out with C++, 4th Edition Chapter 1 Introduction to Computers and Programming.
COMPUTER PROGRAMMING. Introduction to C++ History Merges notions from Smalltalk and notions from C The class concept was borrowed from Simular67 Developed.
Computer Programming and Basic Software Engineering 4. Basic Software Engineering 1 Writing a Good Program 4. Basic Software Engineering.
VARIABLES, TYPES, INPUT/OUTPUT, ASSIGNMENT OPERATION Shieu-Hong Lin MATH/CS Department Chapel.
COMPUTER SCIENCE I C++ INTRODUCTION
Getting Started with C++ Yingcai Xiao 09/03/08. Outline What (is C++) Who (created C++) How (to write a C++ program)
© Copyright 2013 by Pearson Education, Inc. All Rights Reserved. 1 Chapter 1 Introduction to Computers, Programs, and C++
 2003 Prentice Hall, Inc. All rights reserved. 1 Introduction to C++ Programming Outline Introduction to C++ Programming A Simple Program: Printing a.
Instructor: Tina Tian. About me Office: RLC 203A Office Hours: Wednesday 1:30 - 4:30 PM or .
ECE 264 Object-Oriented Software Development Instructor: Dr. Honggang Wang Fall 2012 Lecture 4: Continuing with C++ I/O Basics.
C++ Basics Structure of a Program. C++ Source Code Plain text file Typical file extension .CPP Must compile the C++ source code without errors before.
Liang, Introduction to Programming with C++, Second Edition, (c) 2010 Pearson Education, Inc. All rights reserved Chapter 1 Introduction.
 2008 Pearson Education, Inc. All rights reserved. 1 CISC 1600 – Computer Science I Fall 2010 Introduction to C++ Programming Chapters 1 and 2 (Deitel.
1 C++ Programming Basics Chapter 2 Lecture CSIS 10A.
Data & Data Types & Simple Math Operation 1 Data and Data Type Standard I/O Simple Math operation.
Current Assignments Homework 3 is due tonight. Iteration and basic functions. Exam 1 on Monday.
CSE1222: Lecture 3The Ohio State University1. Assignment Operations  The C++ assignment operator is: =  Examples: x = 3 * 5; y = x – 7; y = y + 4; Do.
3. The Nuts and Bolts of C++ Computer Programming 3. The Nuts and Bolts of C++ 1 Learning the C++ language 3. The Nuts and Bolts of C++
First steps Jordi Cortadella Department of Computer Science.
Liang, Introduction to C++ Programming, (c) Chapter 1 Introduction to Computers, Programs, and C++
N from what language did C++ originate? n what’s input, output device? n what’s main memory, memory location, memory address? n what’s a program, data?
1 C++ Programming Basics Chapter 1 Lecture CSIS 10A.
11 Introduction to Object Oriented Programming (Continued) Cats.
1 CISC181 Introduction to Computer Science Dr. McCoy Lecture 2 September 3, 2009.
Copyright © 2014 Pearson Addison-Wesley. All rights reserved. Chapter 2 C++ Basics.
 2003 Prentice Hall, Inc. All rights reserved Basics of a Typical C++ Environment C++ systems –Program-development environment –Language –C++
1 8/30/06CS150 Introduction to Computer Science 1 Your First C++ Program.
A Sample Program #include using namespace std; int main(void) { cout
1 09/10/04CS150 Introduction to Computer Science 1 What Actions Do We Have Part 2.
Computer Terms Review from what language did C++ originate?
What Actions Do We Have Part 1
Computing Fundamentals
Chapter 2 Assignment and Interactive Input
Beginning C++ Programming
Chapter 2 Elementary Programming
Lab 1 Introduction to C++.
Chapter 1 Introduction to Computers, Programs, and C++
CS150 Introduction to Computer Science 1
Chapter 1 – Introduction to Computers and C++ Programming
Programs written in C and C++ can run on many different computers
Engineering Problem Solving with C++ An Object Based Approach
Engineering Problem Solving with C++ An Object Based Approach
Life is Full of Alternatives
What Actions Do We Have Part 1
Life is Full of Alternatives
Capitolo 1 – Introduction C++ Programming
Computer Terms Review from what language did C++ originate?
COMS 261 Computer Science I
Presentation transcript:

Subject: Programming in C++ 1

LEARNING OUTCOME  At the end of this slide, student able to:  Know the brief history of C++.  Explore Microsoft Visual C++  Create applications using Variables, Data Types and Arithmetic expressions. 2

History & fundemental of C++ 3 C, C++, Java, and C# are very similar. C++ evolved from C. Java was modeled after C++. C# is a subset of C++ with some features similar to Java. If you know one of these languages, it is easy to learn the others. C evolved from the B language and the B language evolved from the BCPL language. BCPL was developed by Martin Richards in the mid-1960s for writing operating systems and compilers. C++ is an extension of C, developed by Bjarne Stroustrup at Bell Labs during C++ added a number of features that improved the C language. An international standard for C++ was created by American National Standards Institute (ANSI) in 1998.

Microsoft Visual C++ 4

Example 1 5 Let us begin with a simple C++ program that displays the message “Welcome to C++!” on the console. #include using namespace std; int main() { // Display Welcome to C++ to the console cout << "Welcome to C++!" << endl; System(“pause”); // this is needed within visual studio return 0; } STAR T Step1: Display show: “Welcome to C++ FINIS H

Example 2 6 #include using namespace std; int main() { cout << "Programming is fun!" << endl; cout << "Fundamentals First"; // what happens when no “endl”? cout << "Problem Driven" << endl; System(“pause”); return 0; } STAR T Step 4: Display show: “Problem Driven” Step 2: Display show: “Fundamental First” Step1: Display show: “Programming is fun!” FINIS H

Example 3 7 #include using namespace std; int main() { string name, age; cout << “Type your name" << endl; cin>> name>>; cout<< “Type your age” << endl; cin>>age>>; cout << “My name is”<<name<<endl; cout << “My age is”<<age<<endl; System(“pause”); return 0; } STAR T Display show: “My age is” Step 2: Computer ask to key in your name Step1: Display show: “Type your name” Step 3: Display show: “My name is” FINIS H

Example 4 8 #include using namespace std; int main() { int first, second; cout << “Welcome to math " << endl; cout<< “Type for first number” << endl; cin>>first>>; cout << “Type for second number”<<second<<endl; cin>> second>>; cout << “The total is”<<first + second <<endl; System(“pause”); return 0; } STAR T Step 4: Display show: “The total is” Step 2: Computer ask to key in first number Step1: Display show: “Welcome to math” & “Type for first number” Step 3: Display show: “Type for second number” FINIS H

Trace a Program Execution #include using namespace std; int main() { double radius; double area; // Step 1: Read in radius radius = 20; // Step 2: Compute area area = radius * radius * ; // Step 3: Display the area cout << "The area is "; cout << area << endl; } 9 no value radius allocate memory for radius animation

Trace a Program Execution 10 no value radius memory animation #include using namespace std; int main() { double radius; double area; // Step 1: Read in radius radius = 20; // Step 2: Compute area area = radius * radius * ; // Step 3: Display the area cout << "The area is "; cout << area << std::endl; } no value area allocate memory for area

Trace a Program Execution radius no value area assign 20 to radius animation #include using namespace std; int main() { double radius; double area; // Step 1: Read in radius radius = 20; // Step 2: Compute area area = radius * radius * ; // Step 3: Display the area cout << "The area is "; cout << area << std::endl; } Note: “=“ is not “equals” but an “assignment” i.e., “take the value of the expression on the right and stick it in the memory location on the left.” Think <=

Trace a Program Execution radius memory area compute area and assign it to variable area animation #include using namespace std; int main() { double radius; double area; // Step 1: Read in radius radius = 20; // Step 2: Compute area area = radius * radius * ; // Step 3: Display the area cout << "The area is "; cout << area << std::endl; }

Trace a Program Execution radius memory area print a message to the console animation #include using namespace std; int main() { double radius; double area; // Step 1: Read in radius radius = 20; // Step 2: Compute area area = radius * radius * ; // Step 3: Display the area cout << "The area is "; cout << area << std::endl; }

EXERCISE IN CLASS By given flowchat, create a C++ programming that can calculate BMI (Body Mass Index), (BMI=weight/height) START Step 4: Computer ask to key in your birth year Step 2: Computer ask to key in your name Step1: Display show: “What is your name?” Step 3: Display show: “what is your birth year?” FINISH Step 5: Display show: “what is your weight?” Step 6: Computer ask to key in your weight Step 7: Display show: “what is your height?” Step 8: Computer ask to key in your height Step 9: Display show: “the BMI of is and age is