1 Original Source : and Problem and Problem Solving.ppt.

Slides:



Advertisements
Similar presentations
Exercise 2.
Advertisements

Chapter 3: Editing and Debugging SAS Programs. Some useful tips of using Program Editor Add line number: In the Command Box, type num, enter. Save SAS.
Chapter 1: An Overview of Computers and Programming Languages
LECTURE 1 CMSC 201. Overview Goal: Problem solving and algorithm development. Learn to program in Python. Algorithm - a set of unambiguous and ordered.
CSCI-1411 F UNDAMENTALS O F C OMPUTING L AB Shane Transue Summer
Conditional Operator (?:) Conditional operator (?:) takes three arguments (ternary) Syntax for using the conditional operator:
Computer Science 1620 Other Data Types. Quick Review: checklist for performing user input: 1) Be sure variable is declared 2) Prompt the user for input.
1 9/08/06CS150 Introduction to Computer Science 1 Arithmetic Operators.
Computer Science 1620 Programming & Problem Solving.
Algorithms and Problem Solving
Chapter 7. 2 Objectives You should be able to describe: The string Class Character Manipulation Methods Exception Handling Input Data Validation Namespaces.
C++ Programming: From Problem Analysis to Program Design, Fifth Edition Chapter 1: An Overview of Computers and Programming Languages Updated by: Dr\Ali-Alnajjar.
Programming is instructing a computer to perform a task for you with the help of a programming language.
Software Engineering 1 (Chap. 1) Object-Centered Design.
Copyright 2003 Scott/Jones Publishing Brief Version of Starting Out with C++, 4th Edition Chapter 1 Introduction to Computers and Programming.
PRINCIPLES OF PROGRAMMING Revision. A Computer  A useful tool for solving a great variety of problems.  To make a computer do anything (i.e. solve.
Computer Programming and Basic Software Engineering 4. Basic Software Engineering 1 Writing a Good Program 4. Basic Software Engineering.
Chapter 2: Developing a Program Prelude to Programming Concepts and Design Copyright © 2001 Scott/Jones, Inc.. All rights reserved. 1 Chapter 2 Developing.
© Janice Regan, CMPT 128, Jan CMPT 128 Introduction to Computing Science for Engineering Students Creating a program.
UNIT 3 TEMPLATE AND EXCEPTION HANDLING. Introduction  Program errors are also referred to as program bugs.  A C program may have one or more of four.
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.
Selection Statements in C++ If Statement in C++ Semantics: These statements have the same meaning as in the algorithmic language. 2- Two way selection:
Input, Output, and Processing
1 C++ Programming Basics Chapter 2 Lecture CSIS 10A.
How to start Visual Studio 2008 or 2010 (command-line program)
Perimeter = 2*(length+width)
Beginning C++ Through Game Programming, Second Edition
COMPUTER PROGRAMMING. A Typical C++ Environment Phases of C++ Programs: 1- Edit 2- Preprocess 3- Compile 4- Link 5- Load 6- Execute Loader Primary Memory.
Liang, Introduction to Programming with C++, Second Edition, (c) 2010 Pearson Education, Inc. All rights reserved Chapter 3 Selections.
Value and Reference Parameters. CSCE 1062 Outline  Summary of value parameters  Summary of reference parameters  Argument/Parameter list correspondence.
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 Chapter-01 Introduction to Software Engineering.
Control Structures (B) Topics to cover here: Sequencing in C++ language.
A first program 1. #include 2. using namespace std; 3. int main() { 4. cout
Lesson - 2. Introduction When we make a program we must follow some steps, called Programming Development Life Cycle (PDLC). Programming steps are five:
1 More Operator Overloading Chapter Objectives You will be able to: Define and use an overloaded operator to output objects of your own classes.
How to Program? -- Part 1 Part 1: Problem Solving –Analyze a problem –Decide what steps need to be taken to solve it. –Take into consideration any special.
Exceptions in C++. Exceptions  Exceptions provide a way to handle the errors generated by our programs by transferring control to functions called handlers.
CS1201: PROGRAMMING LANGUAGE 2 FUNCTIONS. OVERVIEW What is a Function? Function Prototype Vs Decleration Highlight Some Errors in Function Code Parameters.
Modular Programming – User Defined Functions. CSCE 1062 Outline  Modular programming – user defined functions  Value returning functions  return statement.
Chapter 9: Completing the Basics. In this chapter, you will learn about: – Exception handling – Exceptions and file checking – The string class – Character.
Variables, Types, Expressions Intro2CS – week 1b 1.
Lecture 5: Expressions and Interactivity Professor: Dr. Miguel Alonso Jr. Fall 2008 CGS2423/COP1220.
5.01 Understand Different Types of Programming Errors
Introduction to C++.  Computers: CPU, Memory & Input / Output (IO)  Program: Sequence of instructions for the computer.  Operating system: Program.
Exercise 1 #include int main() { printf(“Hello C Programming!\n”); return 0; } 1.Run your Visual Studio 2008 or Create a new “project” and add.
Chpater 3. Outline The definition of Syntax The Definition of Semantic Most Common Methods of Describing Syntax.
Think First, Code Second Understand the problem Work out step by step procedure for solving the problem (algorithm) top down design and stepwise refinement.
1 Chapter-01 Introduction to Software Engineering.
A FIRST BOOK OF C++ CHAPTER 14 THE STRING CLASS AND EXCEPTION HANDLING.
Copyright © 2014 Pearson Addison-Wesley. All rights reserved. Chapter 2 C++ Basics.
COMPUTER PROGRAMMING I SUMMER Understand Different Types of Programming Errors.
C++ Programming: From Problem Analysis to Program Design, Fifth Edition Chapter 1: An Overview of Computers and Programming Languages.
Intro. to Computer Programming Eng. Nehal A. Mohamed Spring Semester-2016.
Software Engineering Algorithms, Compilers, & Lifecycle.
TK1913 C++ Programming Basic Elements of C++.
Introduction to Computers and C++ Programming
5.01 Understand Different Types of Programming Errors
Chapter 1: An Overview of Computers and Programming Languages
Chapter 1: An Overview of Computers and Programming Languages
Chapter 2 Assignment and Interactive Input
5.01 Understand Different Types of Programming Errors
Chapter 2 Elementary Programming
Programming Funamental slides
Chapter 1: An Overview of Computers and Programming Languages
الوحدة الرابعة البرمجة وصياغة حل المسائل البرمجة وأهميتها أهداف الدرس الأول مفهوم البرمجة. الفرق بين المبرمج ومستخدم البرنامج. الحاجة إلى البرامج.
Lab 1 Introduction to C++.
Chapter 1: An Overview of Computers and Programming Languages
Presentation transcript:

1 Original Source : and Problem and Problem Solving.ppt

 Syntax errors are errors in the source code which are related to the syntax of the language.  Syntax errors are detected by the compiler. An executable file will be generated by the compiler only if the source code it compiles has no syntax errors.  Syntax errors are reported by the compiler in the form of error messages. 2

3 #include using namespace std; int main() { cout << "This program has errors return; } Error messages displayed by the compiler

 Logical errors are errors which are related to program logic.  Normally, logical errors are not detectable by the compiler.  Logical errors are usually detected during program runtime. For example, a program producing unexpected results is an indication that it has logical errors.  It is important to remember that if the compiler does not produce any error messages, it does not mean that your program is free of logical errors. 4

 Possible to remove all syntax errors in a program and still not have it run  Even if it runs, it may still not do what you meant it to do  For example, * 5 and (2 + 3) * 5 are both syntactically correct expressions, but have different meanings 5

#include using namespace std; int main() { float radius, length, width; cout << "Enter radius, length and width: "; cin >> radius >> length >> width; cout << "Area of blue region: " << length * width *radius*radius; return 0; }  Write a program to calculate the area of the region in blue. 6

Suppose we test the program with these inputs: radius: 7 length: 2 width: 3 Area of circle = 3.14 * 7 * 7 = Area of rectangle = 2 * 3 = 6 This means that the rectangle is enclosed by the circle. The area of the region should not be negative. 7

 The following output is generated when the program is executed with those inputs.  The program should be checked for logical errors. 8

#include using namespace std; int main() { float radius, length, width; cout << "Enter radius, length and width: "; cin >> radius >> length >> width; cout << "Area of blue region: " << length*width *radius*radius; return 0; } The formula should be 3.14*radius*radius – length*width 9