Screen output // Definition and use of variables

Slides:



Advertisements
Similar presentations
Write a program step by step. Step 1: Problem definition. Given the coordinate of two points in 2-D space, compute and print their straight distance.
Advertisements

CSE202: Lecture 1The Ohio State University1 Introduction to C++
Prof. amr Goneid, AUC1 CSCE 110 PROGRAMMING FUNDAMENTALS WITH C++ Prof. Amr Goneid AUC Part 5. Functions.
1 Lecture-4 Chapter 2 C++ Syntax and Semantics, and the Program Development Process Dale/Weems/Headington.
Computer Science 1620 Function Scope & Global Variables.
Computer Science 1620 Reference Parameters. Parameters – Pass by Value recall that the parameter of a function is assigned the value of its corresponding.
Basic Elements of C++ Chapter 2.
Programming is instructing a computer to perform a task for you with the help of a programming language.
Call-by-Value vs. Call-by-Reference Call-by-value parameters are used for passing information from the calling function to the called function (input parameters).
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.
1 EMT 101 – Engineering Programming Dr. Farzad Ismail School of Aerospace Engineering Universiti Sains Malaysia Nibong Tebal Pulau Pinang Week 4.
1 Programs Composed of Several Functions Syntax Templates Legal C++ Identifiers Assigning Values to Variables Declaring Named Constants String Concatenation.
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.
Chapter 2. C++ Program Structure C++ program is a collection of subprograms Subprograms in C++ are called FUNCTIONS Each function performs a specific.
C++ Programming: Basic Elements of C++.
File I/O ifstreams and ofstreams Sections 11.1 &
1 Simple Functions Writing Reuseable Formulas. In Math Suppose f (x) = 2 x 2 +5Suppose f (x) = 2 x 2 +5 f(5)=?f(5)=? f(5) = 2* =55f(5) = 2*
File I/O 1 ifstreams and ofstreams Sections 11.1 & 11.2.
1 Original Source : and Problem and Problem Solving.ppt.
1 A simple C++ program // ======================================================= // File:helloworld.cpp // Author:Vana Doufexi // Date:1/4/2006 // Description:Displays.
1 Chapter 2 C++ Syntax and Semantics, and the Program Development Process.
Chapter 2: Introduction to C++. Language Elements Keywords Programmer-defined symbols (identifiers) Operators Punctuation Syntax Lines and Statements.
1 8/31/05CS150 Introduction to Computer Science 1 Hello World!
1 More Operator Overloading Chapter Objectives You will be able to: Define and use an overloaded operator to output objects of your own classes.
Simple Functions Writing Reuseable Formulas. Problem Using OCD, design and implement a program that computes the area and circumference of an Australian.
Function 2. User-Defined Functions C++ programs usually have the following form: // include statements // function prototypes // main() function // function.
1 What is a Named Constant? A named constant is a location in memory that we can refer to by an identifier, and in which a data value that cannot be changed.
Introduction to C++.  Computers: CPU, Memory & Input / Output (IO)  Program: Sequence of instructions for the computer.  Operating system: Program.
COMPUTER PROGRAMMING. Array C++ provides a data structure, the array, which stores a fixed-size sequential collection of elements of the same type. An.
1 Structure of Simple C++ Program Chapter 1 09/09/13.
Current Assignments Project 3 has been posted, due next Tuesday. Write a contact manager. Homework 6 will be posted this afternoon and will be due Friday.
Bill Tucker Austin Community College COSC 1315
C++ Lesson 1.
Chapter 1.2 Introduction to C++ Programming
Chapter Topics The Basics of a C++ Program Data Types
Chapter 1.2 Introduction to C++ Programming
Chapter 1.2 Introduction to C++ Programming
Topic Pre-processor cout To output a message.
Chapter 1.2 Introduction to C++ Programming
ANNOUNCEMENT The missed lecture will be made up this Monday evening in the Tech PC classroom (MG51). A tentative time interval is 6:30-8:00. The exact.
LESSON 2 Basic of C++.
Basic Elements of C++.
Introduction to C++ October 2, 2017.
Writing Reuseable Formulas
Global & Local Identifiers
Basic Elements of C++ Chapter 2.
Pointer Data Type and Pointer Variables
Function Basics.
Lab 1 Introduction to C++.
Variables with Memory Diagram
Chapter 2 – Getting Started
Chapter 2 Elementary Programming
אבני היסוד של תוכנית ב- C++
אבני היסוד של תוכנית ב- C++
הרצאה 03 אבני היסוד של תוכנית ב- C
Starting Out with C++: From Control Structures through Objects
Pointers & Functions.
Code::Block vs Visual C++
CSC 270 – Survey of Programming Languages
C++ Compilation Model C++ is a compiled language
Engineering Problem Solving with C++ An Object Based Approach
Engineering Problem Solving with C++ An Object Based Approach
What Actions Do We Have Part 1
Pointers & Functions.
Pointer Data Type and Pointer Variables
Pointer Data Type and Pointer Variables
CS31 Discussion 1D Winter19: week 4
Chapter 1 c++ structure C++ Input / Output
Reading from and Writing to Files Part 2
Presentation transcript:

Screen output // Definition and use of variables #include <iostream> using namespace std; int gVar1; // Global variables, int gVar2 = 2; // explicit initialization int main() { char ch('A'); // Local variable being initialized // or: char ch = 'A'; cout << "Value of gVar1: " << gVar1 << endl; cout << "Value of gVar2: " << gVar2 << endl; cout << "Character in ch: " << ch << endl; int sum, number = 3; // Local variables with // and without initialization sum = number + 5; cout << "Value of sum: " << sum << endl; return 0; } Screen output Value of gVar1: 0 Value of gVar2: 2 Character in ch: A Value of sum: 8

// Circumference and area of a circle with radius 2.5 #include <iostream> using namespace std; const double pi = 3.141593; int main() { double area, circuit, radius = 1.5; area = pi * radius * radius; circuit = 2 * pi * radius; cout << "\nTo Evaluate a Circle\n" << endl; cout << "Radius: " << radius << endl << "Circumference: " << circuit << endl << "Area: " << area << endl; return 0; } Screen output To Evaluate a Circle Radius: 1.5 Circumference: 9.42478 Area: 7.06858

The C++ Compilation Model & IDE

Everything is Done Using an IDE Using Integrated Editor Everything is Done Using an IDE

Fill-in-the-Blank Questions 1. Compilers detect ________ errors. 2. Usually the most difficult errors to correct are the ________ errors, since they are not detected in the compilation process. 3. Attaching other pre-written routines to your program is done by the _________ process. 4. _______code is the machine code consisting of ones and zeroes that is read by the computer. 5. Dividing by zero is an example of a _________ error.