Chapter 1 Introduction Chapter 1 Introduction 1 st Semester 2015 CSC 1101 Computer Programming-1.

Slides:



Advertisements
Similar presentations
CHAPTER 2 GC101 Program’s algorithm 1. COMMUNICATING WITH A COMPUTER  Programming languages bridge the gap between human thought processes and computer.
Advertisements

Copyright © 2002 W. A. Tucker1 Chapter 1 Lecture Notes Bill Tucker Austin Community College COSC 1315.
Chapter 1: An Overview of Computers and Programming Languages
Programming Types of Testing.
Chapter 1 - An Introduction to Computers and Problem Solving
Chapter 2- Visual Basic Schneider1 Chapter 2 Problem Solving.
Chapter 1 Pseudocode & Flowcharts
Three types of computer languages
1 Lecture 1  Getting ready to program  Hardware Model  Software Model  Programming Languages  The C Language  Software Engineering  Programming.
Program Flow Charting How to tackle the beginning stage a program design.
Chapter 1 Introduction to C Programming. 1.1 INTRODUCTION This book is about problem solving with the use of computers and the C programming language.
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:
Programming Logic and Design, Introductory, Fourth Edition1 Understanding Computer Components and Operations (continued) A program must be free of syntax.
Chapter 2- Visual Basic Schneider1 Chapter 2 Problem Solving.
Chapter 1: Introduction To Computer | SCP1103 Programming Technique C | Jumail, FSKSM, UTM, 2005 | Last Updated: July 2005 Slide 1 Introduction To Computers.
Chapter 1 Pseudocode & Flowcharts
C++ Programming: From Problem Analysis to Program Design, Fifth Edition Chapter 1: An Overview of Computers and Programming Languages Updated by: Dr\Ali-Alnajjar.
Computer Programming-1 CSC 111 Chapter 1 : Introduction.
CCSA 221 Programming in C CHAPTER 2 SOME FUNDAMENTALS 1 ALHANOUF ALAMR.
Introduction to Programming Lecture Number:. What is Programming Programming is to instruct the computer on what it has to do in a language that the computer.
© Janice Regan, CMPT 128, Jan CMPT 128 Introduction to Computing Science for Engineering Students Creating a program.
CSC141 Introduction to Computer Programming
C++ Programming Language Lecture 1 Introduction By Ghada Al-Mashaqbeh The Hashemite University Computer Engineering Department.
King Saud University College of applied studies and community services CSC 1101 Computer Programming I Lecture 2.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Slide 1- 1 October 20, October 20, 2015October 20, 2015October 20,
Software Life Cycle What Requirements Gathering, Problem definition
IXA 1234 : C++ PROGRAMMING CHAPTER 1. PROGRAMMING LANGUAGE Programming language is a computer program that can solve certain problem / task Keyword: Computer.
Introduction to Computer Application (IC) MH Room 517 Time : 7:00-9:30pm.
CHAPTER 1 INTRODUCTION 1 st Semester H King Saud University College Of Applied Studies and Community Services CSC 1101 Computer Programming-1.
CHAPTER 1 INTRODUCTION 1 st semester H King Saud University College Of Applied Studies and Community Services CSC 1101 Computer Programming-1.
Chapter 1 Pseudocode & Flowcharts
1 Program Planning and Design Important stages before actual program is written.
CHAPTER 1 INTRODUCTION 2 nd Semester H King Saud University College Of Applied Studies and Community Services CSC 1101 Computer Programming-1.
CHAPTER 1 INTRODUCTION 2 nd Semester H King Saud University College Of Applied Studies and Community Services CSC 1101 Computer Programming-1.
CS2301:Computer Programming 2
LESSON 1 Introduction to Programming Language. Computer  Comprised of various devices that are referred to as HARDWARE.  The computer programs that.
Chapter 11  Getting ready to program  Hardware Model  Software Model  Programming Languages  Facts about C++  Program Development Process  The Hello-world.
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 Types of Programming Language (1) Three types of programming languages 1.Machine languages Strings of numbers giving machine specific instructions Example:
INTRODUCTION TO COMPUTER PROGRAMMING(IT-303) Basics.
Introduction to Computer Programming Concepts M. Uyguroğlu R. Uyguroğlu.
Software Engineering Algorithms, Compilers, & Lifecycle.
Programming Logic and Design Seventh Edition Chapter 1 An Overview of Computers and Programming.
CHAPTER 2 GC101 Program’s algorithm 1. COMMUNICATING WITH A COMPUTER  Programming languages bridge the gap between human thought processes and computer.
Chapter 1 Introduction 2nd Semester H
Chapter 1: An Overview of Computers and Programming Languages
CSCI-235 Micro-Computer Applications
Computer Programming.
Lecture 1: Introduction to JAVA
CSE101-Lec#2 Programming Methodologies
Chapter 1: An Overview of Computers and Programming Languages
C++ Programming: From Problem Analysis to Program Design
Chapter 1 Pseudocode & Flowcharts
(Course Introduction)
Pseudocode & Flowcharts
Chapter 1: An Overview of Computers and Programming Languages
Introduction CSC 111.
Chapter 1 Pseudocode & Flowcharts
King Saud University College Of Applied Studies and Community Services CSC 1101 Computer Programming-1 Done By: Asmal Alosaimi Edited By: Fatimah Alakeel.
Chapter 1 Introduction(1.1)
Chapter 2- Visual Basic Schneider
Chapter 1: An Overview of Computers and Programming Languages
King Saud University College Of Applied Studies and Community Services CSC 1101 Computer Programming-1 Done By: Asmal Alosaimi Edited By: Fatimah Alakeel.
Basic Concepts of Algorithm
Computer Programming-1 CSC 111
Chapter 1 Introduction to Programming
Chapter 1 Pseudocode & Flowcharts
ICS103 Programming in C 1: Overview of Computers And Programming
Programming Logic and Design Eighth Edition
Presentation transcript:

Chapter 1 Introduction Chapter 1 Introduction 1 st Semester 2015 CSC 1101 Computer Programming-1

what is programming is a process that leads from an original formulation of a computing problem to executable programs. It involves activities such as analysis, understanding, solving such problems, implementation (coding) and testing Asma Alosaimi -- Edit by Nouf Almunyif

What a computer program is? For a computer to be able to perform specific tasks (i.e. print what grade a student got on an exam), it must be given instructions to do the task. The set of instructions that tells the computer to perform specific tasks is known as a computer program Asma Alosaimi -- Edit by Nouf Almunyif

language types (level) Asma Alosaimi -- Edit by Nouf Almunyif  Machine language  (The lowest-level language)  “Natural language” of computer component  the only languages understood by Computers almost impossible for humans to use because they consist entirely of numbers Example :

language types  Assembly language ◦contains the same instructions as a machine language, but the instructions and variables have names instead of being just numbers. ◦English-like abbreviations represent computer operations ◦ translated into machine language by a program called an assembler. Example : MOV AX,A MOV A, AX ADD AX, A Asma Alosaimi -- Edit by Nouf Almunyif

language types  High-level language  Allows for writing more “English-like” instructions combines algebraic expressions with symbols taken from English translated into assembly language or machine language by a compiler. Example : A=A+4 *c Asma Alosaimi -- Edit by Nouf Almunyif

The Programmer’s Algorithm An algorithm is a finite sequence of instructions that produces a solution to a problem. The programmer’s algorithm: ◦Define the problem. ◦Plan the problem solution. ◦Code the program. ◦Compile the program. ◦Run the program. ◦Test and debug the program. Asma Alosaimi -- Edit by Nouf Almunyif

1-Defining the Problem The problem must be defined in terms of: ◦Input: Data to be processed. ◦Output: The expected result.  Look for nouns in the problem statement that suggest output and input. ◦and processing: The statements to achieve.  Look for verbs to suggest processing steps. KeyboardScreen Processing input data output data Asma Alosaimi -- Edit by Nouf Almunyif

Input and Output Inputs ◦Can come from many sources, such as users, files, and other programs ◦Can take on many forms, such as text, graphics, and sound Outputs ◦Can also take on many forms, such as numbers, text, graphics, sounds, or commands to other programs Asma Alosaimi -- Edit by Nouf Almunyif

Example 1  Problem:  Problem: Calculate Area and Perimeter of a rectangle Input ◦Length ◦Width Output ◦Area ◦Perimeter Processing ◦Area = length*width ◦Perimeter = 2*( length + width) Asma Alosaimi -- Edit by Nouf Almunyif

Example 2  Problem : Sum and Average of 5 numbers Input ◦five number x1, x2, x3, x4, x5 Output ◦Sum ◦Average Processing ◦Sum = x1+x2+x3+x4+x5 ◦Average = Sum/5 Asma Alosaimi -- Edit by Nouf Almunyif

Example 3 Inut ◦Radius Output ◦Area ◦Perimeter Processing ◦Area = PI * Radius * Radius ◦Perimeter = 2 * PI * Radius Asma Alosaimi -- Edit by Nouf Almunyif Problem: Area and Perimeter of a circle

2-Planning the Solution  When planning, algorithms are used to outline the solution steps using English like statements, called pseudocode. A flowchart is useful for the graphical representation of an algorithm. They are drawn using rectangles, diamonds, ovals, and small circles. Asma Alosaimi -- Edit by Nouf Almunyif

Write a Program to Print the Sum of two integer Numbers 1. Start the program 2. Read the first number and save in the variable ( N1 ) 3. Read the second number and save in the variable ( N2 ) 4. Sum the both numbers and save the result in the variable ( Sum )  Sum = N1 + N2 5. Print the variable ( Sum ) 6. End the program Asma Alosaimi -- Edit by Nouf Almunyif start Read N1 Read N2 Sum = N1 + N2 Print Sum End

3-Coding the Program Coding is writing the program in a formal language called Programming Language.  Programming Language : A set of rules, symbols and special words used to write statements. The program is written by translating the algorithm steps into a programming language statements. The written program is called Source code and it is saved in a file with “.cpp” extension. Asma Alosaimi -- Edit by Nouf Almunyif Program Coding AlgorithmPseudocode Source Code (The “.cpp”) Translating

Why Coding in Programming Languages We write computer programs (i.e. a set of instructions) in programming languages such as C, C++, and Java. We use these programming languages because they are easily understood by humans But then how does the computer understand the instructions that we write? Asma Alosaimi -- Edit by Nouf Almunyif

4-Compiling Computer Programs  Computers do not understand programs written in programming languages such as C, C++ and Java  Programs must first be converted into machine code that the computer can run  A Software that translates a programming language statements into machine code is called a compiler Asma Alosaimi -- Edit by Nouf Almunyif

Programming Language Compiler A compiler is a software that: ◦Checks the correctness of the source code according to the language rules.  Syntax errors  Syntax errors are raised if some rules were violated. ◦Translates the source code into a machine code if no errors were found. Asma Alosaimi -- Edit by Nouf Almunyif

syntax vs. semantics Syntax refers to grammatical structure Ex: adding two numbers c=a#b semantics refers to the meaning. Ex: c=a/0 Asma Alosaimi -- Edit by Nouf Almunyif

5-Running The Program  Before running..  links the object code with the code for the missing functions to produce an executable image (with no missing pieces), this is called link phase.  If the program compiles and links correctly, a file called a.out is produced.  Before a program can be executed, the program must first be placed in memory this called load phase.  the computer, under the control of its CPU, executes the program one instruction at a time Asma Alosaimi -- Edit by Nouf Almunyif

6-Testing and Debugging the Program  Testing  Be sure that the output of the program conforms with the input.  There are two types of errors: Logical Errors: The program run but provides wrong output. Runtime errors: The program stop running suddenly when asking the OS executing a non accepted statement (divide by zero, etc).  Debugging  Find, Understand and correct the error Asma Alosaimi -- Edit by Nouf Almunyif

Basics of a Typical C++ Environment Basics of a Typical C++ Environment Phases of C++ Programs: 1.Edit 2.Preprocess 3.Compile 4.Link 5.Load 6.Execute Loader Primary Memory Program is created in the editor and stored on disk. Preprocessor program processes the code. Loader puts program in memory. CPU takes each instruction and executes it, possibly storing new data values as the program executes. Compiler Compiler creates object code and stores it on disk. Linker links the object code with the libraries, creates a.out and stores it on disk Editor Preprocessor Linker CPU Primary Memory Disk Asma Alosaimi -- Edit by Nouf Almunyif