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.

Slides:



Advertisements
Similar presentations
C++ Introduction.
Advertisements

Chapter 1: An Overview of Computers and Programming Languages
Programming Types of Testing.
INTRODUCTION T.Najah Al_Subaie Kingdom of Saudi Arabia Prince Norah bint Abdul Rahman University College of Computer Since and Information System CS240.
COSC 120 Computer Programming
Engineering Problem Solving With C++ An Object Based Approach Fundamental Concepts Chapter 1 Engineering Problem Solving.
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.
If You Missed Last Week Go to Click on Syllabus, review lecture 01 notes, course schedule Contact your TA ( on website) Schedule.
1 Key Concepts:  Why C?  Life Cycle Of a C program,  What is a computer program?  A program statement?  Basic parts of a C program,  Printf() function?
Chapter 1: An Overview of Computers and Programming Languages
C++ Programming: From Problem Analysis to Program Design, Third Edition Chapter 1: An Overview of Computers and Programming Languages C++ Programming:
Starting Out with C++: Early Objects 5/e © 2006 Pearson Education. All Rights Reserved Starting Out with C++: Early Objects 5 th Edition Chapter 1 Introduction.
Introduction to C. A Brief History Created by Dennis Ritchie at AT&T Labs in 1972 Originally created to design and support the Unix operating system.
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.
CHAPTER 1: INTORDUCTION TO C LANGUAGE
C++ Programming: From Problem Analysis to Program Design, Fifth Edition Chapter 1: An Overview of Computers and Programming Languages Updated by: Dr\Ali-Alnajjar.
C++ Crash Course Class 1 What is programming?. What’s this course about? Goal: Be able to design, write and run simple programs in C++ on a UNIX machine.
Copyright 2003 Scott/Jones Publishing Brief Version of Starting Out with C++, 4th Edition Chapter 1 Introduction to Computers and Programming.
Chapter Introduction to Computers and Programming 1.
CHAPTER 4: INTRODUCTION TO COMPUTER ORGANIZATION AND PROGRAMMING DESIGN Lec. Ghader Kurdi.
Introduction 01_intro.ppt
CSC 125 Introduction to C++ Programming Chapter 1 Introduction to Computers and Programming.
Introduction to C Programming. A Brief History u Created by Dennis Ritchie at AT&T Labs in 1972 u Originally created to design and support the Unix operating.
© 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.
Hello World 2 What does all that mean?.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 1: Introduction to Computers and Programming.
Instructor: Tina Tian. About me Office: RLC 203A Office Hours: Wednesday 1:30 - 4:30 PM or .
Chapter 3: Completing the Problem- Solving Process and Getting Started with C++ Introduction to Programming with C++ Fourth Edition.
History of C and C++ C++ evolved from C ANSI C C++ “spruces up” C
Program Development Life Cycle (PDLC)
Creating your first C++ program
Introduction to C++ Programming Language
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Slide 1- 1 October 20, October 20, 2015October 20, 2015October 20,
1 Problem Solving with C++ The Object of Programming Walter Savitch Chapter 1 Introduction to Computers and C++ Programming Slides by David B. Teague,
Lecture 1 Introduction Figures from Lewis, “C# Software Solutions”, Addison Wesley Richard Gesick.
Programming Fundamentals. Today’s Lecture Why do we need Object Oriented Language C++ and C Basics of a typical C++ Environment Basic Program Construction.
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.
C++ Programming: From Problem Analysis to Program Design, Third Edition Chapter 1: An Overview of Computers and Programming Languages.
Chapter 1 Introduction Chapter 1 Introduction 1 st Semester 2015 CSC 1101 Computer Programming-1.
CS CS CS IA: Procedural Programming CS IB: Object-Oriented Programming.
CS Computer Science I. BCPL was developed in 1967 as a language for writing operating systems and software compilers In 1970, the creators of the.
Copyright 2003 Scott/Jones Publishing Standard Version of Starting Out with C++, 4th Edition Chapter 1 Introduction to Computers and Programming.
Brief Version of Starting Out with C++ Chapter 1 Introduction to Computers and Programming.
Chapter 11  Getting ready to program  Hardware Model  Software Model  Programming Languages  Facts about C++  Program Development Process  The Hello-world.
Principles of Programming CSEB134 : BS/ CHAPTER Fundamentals of the C Programming Language.
Copyright © 2014 Pearson Addison-Wesley. All rights reserved. Chapter 2 C++ Basics.
CSCI 161 Lecture 3 Martin van Bommel. Operating System Program that acts as interface to other software and the underlying hardware Operating System Utilities.
Introduction to Computer Programming using Fortran 77.
Evolution of C and C++ n C was developed by Dennis Ritchie at Bell Labs (early 1970s) as a systems programming language n C later evolved into a general-purpose.
1 8/30/06CS150 Introduction to Computer Science 1 Your First C++ Program.
INTRODUCTION TO COMPUTER PROGRAMMING(IT-303) Basics.
C++ Programming: From Problem Analysis to Program Design, Fifth Edition Chapter 1: An Overview of Computers and Programming Languages.
Chapter 1: Introduction to Computers and Programming.
L071 Introduction to C Topics Compilation Using the gcc Compiler The Anatomy of a C Program Reading Sections
Intro. to Computer Programming Eng. Nehal A. Mohamed Spring Semester-2016.
Introduction to Computer Programming Concepts M. Uyguroğlu R. Uyguroğlu.
Software Engineering Algorithms, Compilers, & Lifecycle.
Chapter 1: An Overview of Computers and Programming Languages
Introduction to programming
Chapter 1: An Overview of Computers and Programming Languages
Chapter 1: An Overview of Computers and Programming Languages
C++ Programming: From Problem Analysis to Program Design
Computer science By/ Midhat Mohiey. Introduction to Programming using C ++ 2.
Hello World 2 What does all that mean?.
Chapter 1: An Overview of Computers and Programming Languages
Creating your first C program
Chapter 1: An Overview of Computers and Programming Languages
CS IA: Procedural Programming CS IB: Object-Oriented Programming
PROGRAMMING FUNDAMENTALS Lecture # 03. Programming Language A Programming language used to write computer programs. Its mean of communication between.
Presentation transcript:

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 in C © 2011/2012 | PN NORHASLIZA BT MUHAMAD NOR

2

Explain the history of c++ 1 C++ program structure 2 C++ programming development process 3 Develop C++ program 4 3 © 2011/2012 | PN NORHASLIZA BT MUHAMAD NOR

C++ Programming language was derived from a C language. C++ combines traditional C programming with OOP capability. A C++ was developed by BJARNE STROUSTRUP at Bell Labs in the early 1980s. In C++, ++ is an operator that increments a variable by 1, therefore, the C language is incremented to its next level with C++. 4 © 2011/2012 | PN NORHASLIZA BT MUHAMAD NOR

// my first program in C++ #include using namespace std; int main () { cout << "Hello World!"; return 0; } comment Preprocessor Directives Main function braces output Return statement Header file 5 © 2011/2012 | PN NORHASLIZA BT MUHAMAD NOR

1) Design 2) Writing Code 3) Compiling 4) Linking 5) Debugging 6 © 2011/2012 | PN NORHASLIZA BT MUHAMAD NOR

1) Design Decide what you need the program to do. Try to break the problem down into functional blocks; pieces that you can turn into functions or classes in a programming language. First there is a basic investigation process, where you try to figure out what needs to be done and how, in theory, it could be done. Secondly you determine the functional blocks of the system and define their interfaces. Thirdly you design the details for each functional block. 7 © 2011/2012 | PN NORHASLIZA BT MUHAMAD NOR

2) Writing Code Write source code which contains text in the programming language you are using. 8 © 2011/2012 | PN NORHASLIZA BT MUHAMAD NOR

3) Compiling Take the source code and compile it into object code. Object code is a translation of the instructions you wrote in the programming language into the native language of the computer (basically lots of numbers, also called machine language). Each source file is translated into one object file. 9 © 2011/2012 | PN NORHASLIZA BT MUHAMAD NOR

4) Linking Link all the object code files for the program together to create an executable. An executable is a file in the native language of the computer arranged so that it can be read from a disk into the computer's memory and executed (or run) from start to finish. If you are using libraries you may have to include those libraries, which are sets of object files archived together for easy access. 10 © 2011/2012 | PN NORHASLIZA BT MUHAMAD NOR

5) Debugging Almost no programs run perfectly, or even well, the first time they are run. You will have to find out what is wrong with a program and probably go back to the source code to fix the problem. This process is called debugging, and for some programs it never seems to end. Debugging should include testing, which means component testing (each functional block alone), integration testing (combinations of functional blocks and their interfaces) and system testing (the whole system). After all that the program is finished. Except, of course, that you will always find some new feature you want to implement, or piece of code you want to tweak. At that point you go back to step one and design your modifications, and start into the cycle again. 11 © 2011/2012 | PN NORHASLIZA BT MUHAMAD NOR

12

Describe the compiling process of a program 1 Explain the types of error 2 13 © 2010/2011 | PN NORHASLIZA BT MUHAMAD NOR

1.Syntax Checking: ▫ Once the code is updated based on the preprocessing, the code can be checked for valid syntax. This includes things like checking for semi-colons, matching braces, every "begin" has an "end", etc. This doesn't mean the code is correct, but it does determine whether the code can be turned into machine code as written. 2.Converting To Assembly: ▫ This step doesn't exist for all languages/compilers. Java, obviously, doesn't use this step. Some compilers may go straight to machine code. 14 © 2011/2012 | PN NORHASLIZA BT MUHAMAD NOR

3.Converting to Machine Code: ▫ What counts as machine code varies somewhat. Java goes to byte code (.class files). GCC creates object files. This step creates a file that is PART of the final program. 4.Linking Machine Code Into An Executable: ▫ Frequently, functions that are used by a program are defined in separate files. Delphi uses components that are in a variety of different files (especially commercially sold components). C/C++ use a variety of libraries. Java often merges.class files into a.jar file. At this step, many linkers will do final checks to make sure all the required pieces, functions, components, etc have been accounted for. 15 © 2011/2012 | PN NORHASLIZA BT MUHAMAD NOR

ERRORS Syntax /Compile Time Run TimeLogical 16 © 2011/2012 | PN NORHASLIZA BT MUHAMAD NOR

a. Syntax / Compile Time Error Compilation error refers to a state when a compiler fails to compile a piece of computer program source code, either due to errors from the compiler itself, or syntax errors in the code. A compilation error message often helps programmers debugging the source code for possible syntax errors. 17 © 2011/2012 | PN NORHASLIZA BT MUHAMAD NOR

Syntax errors - Errors in spelling and grammar. ▫ You can use the compiler or interpreter to uncover syntax errors. ▫ You must have a good working knowledge of error messages to discover the cause of the error. 18 © 2011/2012 | PN NORHASLIZA BT MUHAMAD NOR

b. Run Time Error Run time error - refers to the period while a computer program is actually executed ("run") in a computer, from beginning to termination. It may also mean the program's running time, the duration of that period. Run time errors can be caused by attempting to do impossible arithmetic operations such as calculate with non-numeric data or divide by zero. Run time errors can be caused by attempting to do impossible arithmetic operations such as calculate with non-numeric data or divide by zero. 19 © 2011/2012 | PN NORHASLIZA BT MUHAMAD NOR

c. Logical Error Logical errors - Errors that indicate the logic used when coding the program failed to solve the problem. ▫ You do not get error messages with logic errors. ▫ Your only clue to the existence of logic errors is the production of wrong solutions. 20 © 2011/2012 | PN NORHASLIZA BT MUHAMAD NOR