Chapter 1 Introduction to Programming

Slides:



Advertisements
Similar presentations
EC-111 Algorithms & Computing Lecture #1 Instructor: Jahan Zeb Department of Computer Engineering (DCE) College of E&ME NUST.
Advertisements

CHAPTER 2 GC101 Program’s algorithm 1. COMMUNICATING WITH A COMPUTER  Programming languages bridge the gap between human thought processes and computer.
Copyright © 2002 W. A. Tucker1 Chapter 1 Lecture Notes Bill Tucker Austin Community College COSC 1315.
Programming Types of Testing.
Chapter 2- Visual Basic Schneider1 Chapter 2 Problem Solving.
Three types of computer languages
1 Lecture 1  Getting ready to program  Hardware Model  Software Model  Programming Languages  The C Language  Software Engineering  Programming.
Computers: Tools for an Information Age
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Chapter 1 – Introduction to Computers and C++ Programming.
COBOL for the 21 st Century Stern, Stern, Ley Chapter 1 INTRODUCTION TO STRUCTURED PROGRAM DESIGN IN COBOL.
Chapter 2- Visual Basic Schneider1 Chapter 2 Problem Solving.
 2000 Prentice Hall, Inc. All rights reserved. 1 Introduction to Computers and C Programming Outline Introduction What Is a Computer? Computer Organization.
Computer Programming-1 CSC 111 Chapter 1 : Introduction.
Chapter 1: Introduction to Visual Basic.NET: Background and Perspective Visual Basic.NET Programming: From Problem Analysis to Program Design.
 2008 Pearson Education, Inc. All rights reserved Introduction to Computers, the Internet and World Wide Web.
© Janice Regan, CMPT 128, Jan CMPT 128 Introduction to Computing Science for Engineering Students Creating a program.
Structured COBOL Programming, Stern & Stern, 9th edition
Lecture 1 Programming and Programs Bjarne Stroustrup modified by Hugh Murrell.
Spring 2005, Gülcihan Özdemir Dağ BIL104E: Introduction to Scientific and Engineering Computing, Spring Outline 1.1Introduction 1.2What Is a Computer?
CSC141 Introduction to Computer Programming
Programming Lifecycle
TMF1013 : Introduction To Computing Lecture 1 : Fundamental of Computer ComputerFoudamentals.
C++ Programming Language Lecture 1 Introduction By Ghada Al-Mashaqbeh The Hashemite University Computer Engineering Department.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved Computer Organization Six logical units in every.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Introduction to Computers Outline 1.1Introduction.
Introduction to Programming Lecture No. 1. Books  Deitel & Deitel :– C++ How to Program  Kernighan and Ritchie:- The C Programming Language.
Evolution and History of Programming Languages. Machine languages Assembly languages Higher-level languages To build programs, people use languages that.
Evolution and History of Programming Languages. Software Programming Language.
1 CISC181 Introduction to Computer Science Dr. McCoy Lecture 1 February 8, 2005.
C++ Programming Language Lecture 2 Problem Analysis and Solution Representation By Ghada Al-Mashaqbeh The Hashemite University Computer Engineering Department.
Chapter 1 Introduction Chapter 1 Introduction 1 st Semester 2015 CSC 1101 Computer Programming-1.
Introduction to Computer Application (IC) MH Room 517 Time : 7:00-9:30pm.
1 Programming Fundamentals How to Program in C++ How to Program in C++
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 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.
Programming Fundamentals Lecture No. 2. Course Objectives Objectives of this course are three fold 1. To appreciate the need for a programming language.
How Are Computers Programmed? CPS120: Introduction to Computer Science Lecture 5.
The Hashemite University Computer Engineering Department
CHAPTER 1.1 INTRODUCTION TO COMPUTERS AND C++ Dr. Shady Yehia Elmashad.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Chapter 1 – Introduction to C.
Introduction to C Programming Language. History of C  C was evolved by Dennis Ritchie at AT&T Bell Laboratories in early of 1970s  Successor of: ALGOL.
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 Concepts M. Uyguroğlu R. Uyguroğlu.
برمجه حاسبات 2 أ. بيان غزلان الفصل الدراسي هـ.
Evolution and History of Programming Languages
Chapter 1 Introduction 2nd Semester H
Programming Languages
Chapter 1: Introduction to computers and C++ Programming
CSC201: Computer Programming
Unit 3: ALGORITHMS AND FLOWCHARTS
CSCI-235 Micro-Computer Applications
Computer Programming.
Lecture 1: Introduction to JAVA
Computer Programming (CS-161)
Chapter 1 – Introduction to Computers and C++ Programming
Intro to Programming Week # 1 Hardware / Software Lecture # 2
Introduction CSC 111.
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)
CMP 131 Introduction to Computer Programming
Programming Fundamentals Lecture #3 Overview of Computer Programming
Chapter 1 – Introduction to Computers and C++ Programming
King Saud University College Of Applied Studies and Community Services CSC 1101 Computer Programming-1 Done By: Asmal Alosaimi Edited By: Fatimah Alakeel.
Introduction to Computer Programming
Chapter 1 – Introduction to Computers and C++ Programming
Introduction to C Programming
Chapter 1 – Introduction to Computers and C++ Programming
Presentation transcript:

Chapter 1 Introduction to Programming CSC 1101 2/7/18 Chapter 1 Introduction to Programming CSC 1101- Computer Programming -1- Dr. Nouf Aljaffan naljaffan@ksu.edu.sa (C) 2017 Nouf Aljaffan

Outline The course objectives Advises to success The computer programs CSC 1101 2/7/18 Outline The course objectives Advises to success The computer programs The C programming language Stages in Program Development Process (C) 2017 Nouf Aljaffan

To introduce computational thinking and problem solving skills to beginner students. To develop an understanding of the nature of programming To familiarize student with the basic of C programming language Aims

Learning Outcomes You will be able to Write small C programs (Structured programming) and proper programming techniques Read and understand much larger programs Learn the basics of new programming languages by yourself

The Means 01 02 03 04 05 06 Read a chapter ahead Attend lectures Study the given chapter 03 Ask questions and get feedback 04 Get hands dirty (trial and Error) 05 Form study groups 06

Except for the work you hand in as individual contributions, we strongly encourage you to collaborate and help each other Cooperate on Learning

GET HELP and SUPPORT If in doubt if a collaboration is legitimate: ask! Don’t claim to have written code that you copied from others Don’t give anyone else your code (to hand in for a grade) When you rely on the work of others, explicitly list all of your sources – i.e. give credit to those who did the work Don’t study alone when you don’t have to Do help each other (without plagiarizing) Go to my office hours or/and send me an email Go prepared with questions The only stupid questions are the ones you wanted to ask but did not

What a computer program is?

CSC 1101 2/7/18 Computer program is a set of instructions which are given to a computer to be able to perform specific tasks. A specific task can be, for example, “printing a student grade”. (C) 2017 Nouf Aljaffan

Layers of Programming High-level language Assembly language CSC 1101 2/7/18 Layers of Programming High-level language Similar to human language Use mathematical notations (translated via compilers) Assembly language English-like abbreviations representing elementary computer operations (translated via assemblers) Machine language Strings of numbers giving machine specific instructions Machine dependent Easier to use High-level Compiler Assembler More Powerful Low-level (C) 2017 Nouf Aljaffan

Why C programming?

Why C ? You can’t learn to program without a programming language Evolved by Ritchie from two previous programming languages, BCPL and B Hardware independent (portable) Programming concepts that you learn using C can be used fairly directly in other languages Including C++, Java, C#, and (less directly) Fortran

Where is C Used? Used to develop UNIX Used to write modern operating systems Just about everywhere Mars rovers, animation, graphics, Photoshop, GUI, OS, compilers, slides, chip design, chip manufacturing, semiconductor tools, etc.

The C Standard Library C programs consist of pieces/modules called functions A programmer can create his own functions Advantage: the programmer knows exactly how it works Disadvantage: time consuming Programmers will often use the C library functions Use these as building blocks Avoid re-inventing the wheel If a premade function exists, generally best to use it rather than write your own Library functions carefully written, efficient, and portable

Stages in Program Development Process CSC 1101 2/7/18 1- Analysis of a problem 2- Create the algorithm 3- Compile the program 4- Execute the program 5- Testing and Debugging the Program Stages in Program Development Process (C) 2017 Nouf Aljaffan

(1) Analysis of a problem Human thoughts where it should be given a solution.

A- Defining the Problem Read the problem statement carefully Indicate the requirements Indicate the inputs (look for nouns) Indicate the output (look for nouns) Indicate the instructions(look for verbs)

Calculate the Sum and Average of 5 numbers? CSC 1101 2/7/18 Input five numbers (x1, x2, x3, x4, x5) Instruction Sum = x1+x2+x3+x4+x5 Average = Sum/5 Output Sum Average Example 1 Calculate the Sum and Average of 5 numbers? (C) 2017 Nouf Aljaffan

Example 3 Read a word and capitalize the second letter word CSC 1101 2/7/18 Example 3 Read a word and capitalize the second letter word Input Processing Output (C) 2017 Nouf Aljaffan

(2) Create the algorithm Plan for solution and use basic statements and expression to develop the algorithm

Programming algorithm CSC 1101 2/7/18 Programming algorithm You can think the programming algorithm as a a recipe that describes the exact steps needed for computer to solve a problem or reach a goal. You can think the programming algorithm as a recipe that describes the exact steps needed for computer to solve a problem or reach a goal (C) 2017 Nouf Aljaffan

Programming algorithm Ingredients Inputs Word for a recipe Procedure Output Results

Programming algorithm has a start and an end Programming algorithm is NOT a Computer CODE Programming algorithm has a start and an end Programming algorithm leads to a solution

B-Planning the Solution CSC 1101 2/7/18 Pseudocode is a semi-programming language used to describe the steps in an algorithm. Flowchart is a graphical representation of an algorithm. B-Planning the Solution (C) 2017 Nouf Aljaffan

Example: Write a Program to Print the Sum of two integer Numbers CSC 1101 2/7/18 Example: Write a Program to Print the Sum of two integer Numbers Start the program Read the first number and save in the variable ( N1 ) Read the second number and save in the variable ( N2 ) Sum the both numbers and save the result in the variable ( Sum )  Sum = N1 + N2 Print the variable ( Sum ) End the program start Read N1 Read N2 Sum = N1 + N2 Print Sum End (C) 2017 Nouf Aljaffan

(3) Compile the program Generate the source code using any programming languages. Then, compile the program.

CSC 1101 2/7/18 A-Coding the Program .C (C) 2017 Nouf Aljaffan

What is a Compiler It is a software that checks the correctness of the source code according to the language rules. If the code is free of errors: The source code will be translated into machine code. Create of an “object ” file Else: Syntax errors are raised if some rules were violated.

CSC 1101 2/7/18 Preprocessor In C , a preprocessor program executes automatically before the compiler translation phase begin. Preprocessor indicate that certain manipulations are to be performed on the program before compilation. (C) 2017 Nouf Aljaffan

(4) Execute the program If the code is error free, the program can be executed to create the output

4-Running The Program Linking Phase CSC 1101 2/7/18 4-Running The Program Linking Phase Occurring before running the code Linking the object code with the code for the missing functions to produce an executable image (with no missing pieces). If the program compiles and links correctly, a file called a.out is produced. Load Phase: Before a program can be executed, the program must first be placed in memory. The computer, under the control of its CPU, executes the program one instruction at a time (C) 2017 Nouf Aljaffan

Basics of a Typical C Program Development Environment   Basics of a Typical C Program Development Environment 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 creates object code and stores it on disk. Linker links the object code with the libraries Loader Primary Memory Compiler Editor Preprocessor Linker   . Disk CPU Phases of C++ Programs: Edit Preprocess Compile Link Load Execute

(5) Testing and Debugging the Program To ensure there is no errors

5-Testing and Debugging the Program CSC 1101 2/7/18 5-Testing and Debugging the Program Testing Be sure that the output of the program conforms with the input. There are three types of errors: Syntax Errors (Compiler Error): occurs when the compiler cannot recognize a statement because it violates the rules of the language. 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 (C) 2017 Nouf Aljaffan

Conclusion The course objectives The computer programs CSC 1101 2/7/18 Conclusion The course objectives The computer programs The C programming language Stages in Program Development Process (C) 2017 Nouf Aljaffan

Any Questions