Fundamentals of Programming (C)

Similar documents
Fundamentals of Programming. Lecture 1: Introduction to C Programming

Chapter 1 Introduction to Computers and C++ Programming

0 Introduction: Computer systems and program development

Introduction to Basis and Practice in Programming

by Pearson Education, Inc. All Rights Reserved.

Chapter 1: An Overview of Computers and Programming Languages. Objectives. Objectives (cont d.) Introduction

CHAPTER 1: INTRODUCTION TO COMPUTERS AND PROGRAMMING. 1 Muhalim Mohamed Amin Faculty of

Basic Computer Programming for ISNE. Santi Phithakkitnukoon ผศ.ดร.ส นต พ ท กษ ก จน ก ร

Chapter 1 Introduction to Computers and C++ Programming

SCSP Programming Technique C

BITG 1113: Introduction To Computers And Programming Language LECTURE 1 LECTURE 1 1

C++ Programming Language Lecture 1 Introduction

Fundamentals of Programming (Python) Basic Concepts. Ali Taheri Sharif University of Technology Spring 2018

Introduction to Computers and Visual Basic.Net Pearson Education, Inc. All rights reserved.

CS 113: Introduction to

Fundamentals of Programming Session 1

Computer Principles and Components 1

Administration Computers Software Algorithms Programming Languages

Lecture 1: CS2400 Introduction to Computer Science

Chapter 1 & 2 Introduction to C Language

Week 1 Introduction to Computer and Algorithm (Part1) UniMAP Sem II 11/12 DKT121: Basic Computer Programming 1

Chapter 1: Introduction to Computers and Programming

Problem Solving and Program Design - Chapter 1. Cory L. Strope

Fundamentals of Programming Session 1

Introduction to Programming

BIL 104E Introduction to Scientific and Engineering Computing. Lecture 1

Programming 1. Lecture 1 COP 3014 Fall August 28, 2017

Introduction to Computers, the Internet and the Web Pearson Education, Inc. All rights reserved.

Chapter 1: Why Program? Main Hardware Component Categories 8/23/2014. Main Hardware Component Categories: Why Program?

CSCE150A. Administrivia. Overview. Hardware. Software. Example. Program. Pseudocode. Flowchart. Control Structures. Hello World Program CSCE150A

Computer Science & Engineering 150A Problem Solving Using Computers

What is programming? What are computer languages and how have they evolved? What is the basic process of programming, including the tools involved?

Spring 2018 NENG 202 Introduction to Computer Programming

Computer is an electronic machine that can receive, store, transform and output data of all kinds (image, text, numeric, graphics and sound).

EKT 120/4 Computer Programming KOLEJ UNIVERSITI KEJURUTERAAN UTARA MALAYSIA

C Programming for Engineers Introduction

Chapter 1: Introduction

Week 1 Introduction to Programming

ITC213: STRUCTURED PROGRAMMING. Bhaskar Shrestha National College of Computer Studies Tribhuvan University

INTRODUCTION TO THE COURSE

Lecture 1: Preliminaries

Chapter 1 Basic Computer Organization

IS 0020 Program Design and Software Tools

ENT 189: COMPUTER PROGRAMMING. H/P: Home page:

! Learn how to think like a computer scientist. ! Learn problem solving. ! Read and write code. ! Understand object oriented programming

Microprocessors I MICROCOMPUTERS AND MICROPROCESSORS

Chapter 1. Computer Technology Concept of Programming & Algorithm and Flow Charts

Chapter 1: Why Program? Computers and Programming. Why Program?

Introduction To Computers. About the Course

EL2310 Scientific Programming

1.The First Instrument known in the history of computers was. a) Pascal s adding machine b) Napier s bones c) Abacus d) Analytical Engine

Week 0: Intro to Computers and Programming. 1.1 Why Program? 1.2 Computer Systems: Hardware and Software. Hardware Components

Test Bank for Prelude to Programming Chapter 0

An Overview of the Computer System. Kafui A. Prebbie 24

Computer Fundamentals

Topics. Hardware and Software. Introduction. Main Memory. The CPU 9/21/2014. Introduction to Computers and Programming

Computer Architecture. Fall Dongkun Shin, SKKU

INTRODUCTION TO OPERATING SYSTEMS. Jo, Heeseung

An Introduction to Computers and Java CSC 121 Spring 2015 Howard Rosenthal

Programming Languages FILS Andrei Vasilateanu

LECTURE/ STUDY NOTES ON C

Programming 1 - Honors

Computer Programming-1 CSC 111. Chapter 1 : Introduction

Advanced Programming Concepts. CIS 15 : Spring 2007

Programming Fundamentals (CS 302 ) Dr. Ihsan Ullah. Lecturer Department of Computer Science & IT University of Balochistan

Introduction to OS. Introduction MOS Mahmoud El-Gayyar. Mahmoud El-Gayyar / Introduction to OS 1

CHAPTER 1 Introduction to Computers and Java

Chapter 1. The Big Picture

Instructor. Mehmet Zeki COSKUN Assistant Professor at the Geodesy & Photogrammetry, Civil Eng. (212)

Programming 1. Lecture 1 COP 3014 Fall August 28, 2018

Chapter 2: Computers: The Machines Behind Computing.

Chapter 1 INTRODUCTION

Introduction to Operating Systems. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

CS120 Computer Science I. Instructor: Jia Song

CS133 C Programming. Instructor: Jialiang Lu Office: Information Center 703

CIS* Programming

Unit. Programming Fundamentals. School of Science and Technology INTRODUCTION

C LANGUAGE AND ITS DIFFERENT TYPES OF FUNCTIONS

An Introduc+on to Computers and Java CSC 121 Spring 2017 Howard Rosenthal

COMP1917: Computing 1 1. Introduction

CHAPTER 1 Introduction

Introduction to Operating Systems. Jo, Heeseung

Segment 1A. Introduction to Microcomputer and Microprocessor

Introduction. Instructor: Jia Xu CSCI-135

COMP1917: Computing 1 1. Introduction

Computer science First Class Lecture 1

Introduction. Arizona State University 1

CS1100 Introduction to Programming

Multiple Choice Questions UNIT-I

CS 1713 Introduction to Computer Programming II Ch 0 Overview - Problem solving

1. Introduction. Course Web Site. COMP1917: Computing 1. Textbook. Occupational Health and Safety (OHS)

Introduction to Operating Systems. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

Unit 1: Introduction to Programming. Saurabh Khatri Lecturer Department of Computer Technology VIT, Pune

Principles of computer programming. Profesor : doc. dr Marko Tanasković Assistent : doc. dr Marko Tanasković

CS 241 Computer Programming. Introduction. Teacher Assistant. Hadeel Al-Ateeq

Operating Systems Concepts. CMPUT 379, Winter 2014 Section B1

v.m.g.rajasekaran ramani sri sarada sakthi mat. Hr. sec. school

CS 241 Data Organization. August 21, 2018

CS240: Programming in C

Chapter 1 Introduction. Jin-Fu Li Department of Electrical Engineering National Central University Jungli, Taiwan

Transcription:

Borrowed from lecturer notes by Omid Jafarinezhad Fundamentals of Programming (C) Group 6 Lecturer: Vahid Khodabakhshi CE 40153 - Fall 97 Lecture 1 Introduction and Brief History Department of Computer Engineering

Outline Review of Course Materials Grading Policy An Overview of Computer Computer Components Hardware Software Introduction to Programming Programming Paradigm Machine Languages Assembly Languages High-Level Languages History of C/C++ Typical C Program Development Environment Compilation Process Department of Computer Engineering 2/44

Review of Course Materials Computer number format Data Types, Variables, Operators, Input/Output Algorithm and Pseudo code Functions Strings and Pointers Arrays, Structures Files Object-Oriented Programming Department of Computer Engineering 3/44

Core reference 1. C How to Program 8 th Edition, by Paul Deitel, Harvey Deitel, Publisher: Pearson; March 8, 2015. 2. The C Programming Language, Kernighan, B.W., Ritchie, D.M., 2nd edition, Prentice-Hall, 1988, ISBN: 8120305965, 9788120305960. 3. C Programming Language, Einollah Jafarnejad Qomi, 4th edition, Computer Science Publisher. Department of Computer Engineering 4/44

Grading policy Tentative Midterm exam: 5 pts (15 Azar 1397) Final exam: 6 pts (23 Dey 1397) Assignments: 4 pts Quizzes: 2 pts Final Programming Project: 3 pts Extra (bonus) o Programming Contest: +1 pts o Extra Assignments: +1 pts o Regular Presence at Class: +0.5 pts o Class Activity: up to +1 pts o Some other bonus chances? pts Department of Computer Engineering 5/44

Instructor Vahid Khodabakhshi vkhodabakhshi@ce.sharif.edu Website http://ce.sharif.edu/courses/97-98/1/ce153-6/index.php Department of Computer Engineering 6/44

TAs 1. Ali Najimi [Head], najimi56@gmail.com 2. Mohamadreza Karegar, karegar@gmail.com 3. Mohsen Naghipourfar, mn7697np@gmail.com 4. Poyan Shirzadian, pshirzadian26@gmail.com 5. Amirhossein Khajepour, amirhossein_kh@ymail.com 6. Saba Torabi Ardekani, torabi.saba16@yahoo.com 7. Shayesteh Arasti, shayesteharasti@gmail.com 8. Arvin Azarmina, arvinazarmina@gmail.com 9. Alireza Mahmoodi, mahmoodia1376@gmail.com 10. Sajed Karimi, karimisajed1378@gmail.com 11. Mohamadhosein Shahmoradi, mh.shahmoradi@ie.sharif.edu 12. Kamyar Maroufi, kmaroufi76@gmail.com 13. Mojtaba Farsian, farsian.mojtaba@gmail.com 14. Mohamadreza Ahmadkhaniha, mr.ahmadkhaniha@gmail.com 15. Mohamad Alizadeh, alizadehmohamd77@gmail.com Department of Computer Engineering 7/44

Homework Submission Submit your homework on course s page on Quera.ir Register to Quera: Invitation link has been sent to your university e-mail If not, contact the head TAs Department of Computer Engineering 8/44

An Overview of Computer Computer: Programmable general purpose machine Can not do anything without a program Receives Input Letters, Numbers, Images Processes and Stores input Provides Output in a useful format Department of Computer Engineering 9/44

Computer Components Hardware The physical parts or components of computer such as monitor, keyboard, hard disk, mouse, etc. Software Set of instructions you write to command computers to perform actions on hardware Department of Computer Engineering 10/44

Overview of Computer Hardware Ordered sequence of storage location (memory cell) Department of Computer Engineering 11/44

Logical Units Regardless of differences in shape (physical appearance), virtually every computer may be envisioned as divided into six/6 logical units or sections: 1. Input unit 2. Output unit 3. Memory unit 4. Arithmetic and logic unit (ALU) 5. Central processing unit (CPU) 6. Secondary storage unit Department of Computer Engineering 12/44

1. Input unit Receiving section obtains information (data and computer programs) from input devices and places it at the disposal of the other units so that it can be processed examples: keyboards and mouse Department of Computer Engineering 13/44

2. Output unit This shipping section takes information that the computer has processed and places it on various output devices to make it available for use outside the computer Department of Computer Engineering 14/44

3. Memory Unit Rapid-access, relatively low-capacity (in comparison with secondary storages) Warehouse section retains information that has been entered through the input unit, making it immediately available for processing when needed The memory unit also retains processed information until it can be placed on output devices by the output unit Information in the memory unit is volatile it s typically lost when the computer s power is turned off The memory unit is often called either memory or primary memory (RAM) Department of Computer Engineering 15/44

4. Arithmetic and logic unit (ALU) Manufacturing section performs calculations addition, subtraction, multiplication and division It also contains the decision mechanisms that allow the computer, for example, to compare two items from the memory unit to determine whether they re equal The ALU is usually implemented as part of the next logical unit, the CPU Department of Computer Engineering 16/44

5. Central processing unit (CPU) Administrative section coordinates and supervises the operation of the other sections tells the input unit when to read information into the memory unit tells the ALU when information from the memory unit should be used in calculations tells the output unit when to send information from the memory unit to certain output devices Multiprocessors computers have multiple CPUs and, hence, can perform many operations simultaneously A multi-core processor implements multiprocessing on a single integrated circuit chip Dual-core processor has two CPUs Quad-core processor has four CPUs Department of Computer Engineering 17/44

6. Secondary Storage Unit Long-term High-capacity warehousing section Programs or data not actively being used by the other units normally are placed on secondary storage devices until they re again needed Information on secondary storage devices is said to be persistent it is preserved even when the computer s power is turned off Hard drives, CDs, DVDs and flash drives Department of Computer Engineering 18/44

History - First Generation Computers Mid-1940s Used vacuum tubes Huge and complex The ENIAC, weighing 30 tons, using 200 kilowatts of electric power and consisting of 18,000 vacuum tubes Department of Computer Engineering 19/44

History - Second Generation Computers 1955 1960 The invention of Transistor The era of miniaturization begins. Department of Computer Engineering 20/44

History - Third Generation Computers 1960s The Integrated Circuits, also known as microchips Silicon chips containing multiple transistors Department of Computer Engineering 21/44

History - Fourth Generation Computers 1971 present large-scale integration or LSI 1000 devices per chip) very large-scale integration or VLSI 10000 devices per chip) Department of Computer Engineering 22/44

Overview of Computer Software Operating System (OS) the collection of computer programs that control the interaction of the user and the computer hardware. E.g. Windows, Unix Application Software Programs developed to assist a computer user in accomplishing specific tasks. E.g. Microsoft Word In order to create new application software, we need to write lists of instruction (program) to the computer to execute Department of Computer Engineering 23/44

Programming Language The defining feature of modern computers which distinguishes them from all other machines is that they can be programmed Programming is a process for instructing a computer to do something for you with the help of a Programming Language A programming language contains instructions for the computer to perform a specific action or a specific task: Display I like programming Display the current time Department of Computer Engineering 24/44

Programming Language Programming Language is a Formal Language used to communicate to a computer Very specific (one word means one thing context free) since to 'talk' to a computer; to instruct a computer; our commands must be 100% clear and correct The description of a programming language is usually split into the two components of syntax (form) and semantics (meaning) A programming paradigm is a fundamental style of computer programming: Functional : tell what to do but not how (sum [1...10]) Imperative : describing step by step Object-Oriented and Logical Programming Department of Computer Engineering 25/44

Programming Language Special-purpose : is design for a particular type of application Structured Query Language (SQL) General-purpose : can be used to obtain solutions for many types of problems. Machine Languages Assembly Languages High-Level Languages Department of Computer Engineering 26/44

Machine Language The only language that the processor actually understands Consists of binary codes: 0 and 1 Example: 00010101 11010001 01001100 Each of the lines above corresponds to a specific task to be done by the processor Programming in machine code is difficult and slow since it is difficult to memorize all the instructions Mistakes can happen very easily Processor and Architecture dependent (different machine language for different type of CPU) not portable Department of Computer Engineering 27/44

Assembly Language Enables machine code to be represented in words and numbers Example of a program in assembly language: LOAD A, 9999 LOAD A, 9999 LOAD A, 0111001100 9999 LOAD B, 8282 LOAD B, 8282 LOAD B, 1000110011 8282 SUB B Assembler SUB B 1001111001 SUB B MOV C, A MOV C, A1100110010 MOV C, A Easier to understand and memorize (called Mnemonics), compared to machine code but still quite difficult to use Cannot be processed directly by a computer, must be converted to machine language using assemblers Processor and Architecture dependent not portable Department of Computer Engineering 28/44

High-Level Language Machine independent programming language that combines algebraic expression and English words Example: c = b - a Processor independent - the same code can be run on different processors Examples: Basic, Fortran, Pascal, Cobol, C, C++, Java High level language needs to be translated (compiled) to machine code by a program called compiler so that it can be executed by the processor Department of Computer Engineering 29/44

Programming Language Abstraction C C++ Java Fortran PL1 High-Level Language Assembly Language Machine Language Hardware Department of Computer Engineering 30/44

C History BCPL,1967, Martin Richards writing operating-systems software and compiler B, 1969, Ken Thomson based on BCPL C, 1972, Dennis Ritchie based on BCPL and B at Bell Laboratories originally implemented on a DEC PDP-11 Department of Computer Engineering 31/44

C History In 1983, the American National Standards Institute (ANSI) established a committee to provide a modern, comprehensive definition of C. The resulting definition, the ANSI standard, or ANSI C, was completed late 1988 updated in 1999 Because C is a hardware-independent, widely available language, applications written in C can run with little or no modifications on a wide range of different computer systems Portable programs Department of Computer Engineering 32/44

C An Imperative Language C is a highly imperative formal language We must tell it exactly how to do what the means and functions to use which libraries to use when to add a new line when an instruction is finished in short: everything and anything filename.c Department of Computer Engineering 33/44

C++ Programming Language early 1980s, Bjarne Stroustrup at Bell Labroratory C++ a superset of C object-oriented programming Objects are essentially reusable software components that model items in the real world filename.c filename.cpp Department of Computer Engineering 34/44

Typical C Program Development Environment C systems generally consist of several parts: a program development environment the language the C Standard Library C programs typically go through six phases to be executed: edit, preprocess, compile, link, load and execute Department of Computer Engineering 35/44

Department of Computer Engineering 36/44

Microsoft Visual Studio Editing a file with an editor program Integrated Development Environment (IDE) Department of Computer Engineering 37/44

Dev-C++ Department of Computer Engineering 38/44

Code::Blocks Department of Computer Engineering 39/44

Preprocessor And compiler a preprocessor program executes automatically before the compiler s translation phase begins The C preprocessor obeys special commands called preprocessor directives, which indicate that certain manipulations are to be performed on the program before compilation The compiler translates the C program into machine language-code (object code) Department of Computer Engineering 40/44

Linking, Loading And Execution C programs typically contain references to functions defined elsewhere, such as in the standard libraries or in the private libraries A linker links the object code with the code for the missing functions to produce an executable image Before a program can be executed, the program must first be placed in memory This is done by the loader, which takes the executable image from disk and transfers it to memory Additional components from shared libraries that support the program are also loaded Finally, the computer, under the control of its CPU, executes the program one instruction at a time Department of Computer Engineering 41/44

Compile log Department of Computer Engineering 42/44

Common Problems of Programming Usability Your program is too complicated or too simple to be useful to most people Maintainability Other people, or yourself at a later time can't easily understand the programming behind your program. This means your project won't grow and become all it's capable of being Department of Computer Engineering 43/44

Summary Computer Components Hardware Logical Computer Organization: Input unit, Output unit, Memory unit, ALU, CPU, Secondary storage unit Generations Of Computer Hardware: vacuum tube, transistor, IC, LSI, V LSI Software Operating System Application Software Programming Languages programming paradigm: Functional, Imperative, Object-Oriented, Logical Machine Languages: language of processor; represented by 0 and 1 Assembly Languages: represented in words and numbers High-Level Languages: machine independent History Of C/C++ : based on BCPL, B; imperative language Typical C Program Development Environment Compilation Process : edit, preprocess, compile, link, load and execute Department of Computer Engineering 44/44