Spring 2005, Gülcihan Özdemir Dağ BIL104E: Introduction to Scientific and Engineering Computing, Spring 2010. Outline 1.1Introduction 1.2What Is a Computer?

Slides:



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

Lecture 2 Introduction to C Programming
Introduction to C Programming
 2000 Prentice Hall, Inc. All rights reserved. Chapter 2 - Introduction to C Programming Outline 2.1Introduction 2.2A Simple C Program: Printing a Line.
Introduction Kingdom of Saudi Arabia Shaqra University
 2000 Prentice Hall, Inc. All rights reserved. 1 Chapter 1 – Introduction to Computers and C++ Programming Outline 1.1Introduction 1.2What is a Computer?
Three types of computer languages
Java Environment (CSS444)
 2007 Pearson Education, Inc. All rights reserved Introduction to Computers, the Internet and the Web.
Bil104E Introduction to Scientific and Engineering Programming
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Chapter 1 – Introduction to Computers and C++ Programming.
 2003 Prentice Hall, Inc. All rights reserved. 1 Machine Languages, Assembly Languages, and High-level Languages Three types of computer languages 1.Machine.
 2000 Prentice Hall, Inc. All rights reserved. Chapter 1 – Introduction to Computers and C++ Programming Outline 1.1Introduction 1.2What Is a Computer?
Introduction to C Programming
 2000 Prentice Hall, Inc. All rights reserved. 1 Introduction to Computers and C Programming Outline Introduction What Is a Computer? Computer Organization.
C programming language Computer Programming Language 計算機程式設計 Chapter 1 Overview 台大電機系 吳安宇教授 Sept
Introduction to computers and programming RIZWAN REHMAN Assistant Professor Centre For Computer Studies.
COMPUTER SCIENCE I C++ INTRODUCTION
1 Chapter 1 - Introduction to Computers, the Internet, and the World Wide Web Outline 1.1Introduction 1.2What Is a Computer? 1.3Computer Organization 1.4Evolution.
“C” Programming Language What is language ? Language is medium of communication. If two persons want to communicate with each other, they have to use.
Lecture 1: Introduction to Computers. OBJECTIVES In this lecture you will learn:  Basic computer concepts.  The different types of programming languages.
Programming Design Ku-Yaw Chang Assistant Professor, Department of Computer Science and Information Engineering Da-Yeh University.
 2008 Pearson Education, Inc. All rights reserved Introduction to Computers, the Internet and World Wide Web.
 2000 Deitel & Associates, Inc. All rights reserved. Chapter 1 – Introduction to Computers and C++ Programming Outline 1.1Introduction 1.2What is a Computer?
Chapter 1 Introduction to Computers, the Internet and the World Wide Web.
History of C and C++ C++ evolved from C ANSI C C++ “spruces up” C
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.
 2000 Prentice Hall, Inc. All rights reserved. 1 Introduction Jyh-Cheng Chen Department of Computer Science and Institute of Communications Engineering.
 2006 Pearson Education, Inc. All rights reserved Introduction to Computers, the Internet and World Wide Web.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Chapter 1 Introduction to Computers, the Internet and.
Department of Computer and Information Science, School of Science, IUPUI Dale Roberts, Lecturer Computer Science, IUPUI CSCI.
1 CISC181 Introduction to Computer Science Dr. McCoy Lecture 1 February 8, 2005.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Chapter 2 Chapter 2 - Introduction to C Programming.
INTRODUCTION Kingdom of Saudi Arabia Princess Nora bint Abdul Rahman University College of Computer Since and Information System CS240.
1 MIS 131 Introduction to Algorithms and Programming 2015/2016 Fall - Chapter 1 -
1 Programming Fundamentals How to Program in C++ How to Program in C++
COMPUTER PROGRAMMING. Computer programming the objective of the module to gain the necessary skills to develop a computer program using one of the high.
 2000 Prentice Hall, Inc. All rights reserved. 1 Chapter 1 - Introduction to Computers, the Internet, and the World Wide Web Outline 1.1Introduction 1.2What.
Spring 09- ICE0124 Programming Fundamentals I Java Programming XuanTung Hoang Lecture No. 1.
 2001 Prentice Hall, Inc. All rights reserved. Chapter 1 – Introduction to Computers, the Internet and the World Wide Web Outline 1.1Introduction 1.2What.
CHAPTER 1: INTRODUCTION C++ Programming. CS 241 Course URL: Text Book: C++ How to Program, DETITEL & DEITEL, eighth Edition.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Chapter 2 - Introduction to C Programming Outline.
 2007 Pearson Education, Inc. All rights reserved. A Simple C Program 1 /* ************************************************* *** Program: hello_world.
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.
1 Types of Programming Language (1) Three types of programming languages 1.Machine languages Strings of numbers giving machine specific instructions Example:
 2003 Prentice Hall, Inc. All rights reserved Introduction Software –Instructions to command computer to perform actions and make decisions Hardware.
BIL 104E Introduction to Scientific and Engineering Computing Lecture 1.
Structured programming 1 st stage By Heba.A Raheem Assist Lecturer College of Sciences/Computer Sciences Department.
1 Lecture 2 - Introduction to C Programming Outline 2.1Introduction 2.2A Simple C Program: Printing a Line of Text 2.3Another Simple C Program: Adding.
 2001 Prentice Hall, Inc. All rights reserved.
Chapter 1: Introduction to computers and C++ Programming
CSC201: Computer Programming
Introduction to C Language
Chapter 2 - Introduction to C Programming
Chapter 1 – Introduction to Computers and C++ Programming
Getting Started with C.
Chapter 2 - Introduction to C Programming
Chapter 2 - Introduction to C Programming
Chapter 2 - Introduction to C Programming
Chapter 2 - Introduction to C Programming
Programming Fundamentals Lecture #3 Overview of Computer Programming
Chapter 1 – Introduction to Computers and C++ Programming
Introduction to Computer Programming
Chapter 1 – Introduction to Computers and C++ Programming
Chapter 2 - Introduction to C Programming
Introduction to C Programming
Chapter 1 – Introduction to Computers and C++ Programming
Presentation transcript:

Spring 2005, Gülcihan Özdemir Dağ BIL104E: Introduction to Scientific and Engineering Computing, Spring Outline 1.1Introduction 1.2What Is a Computer? 1.3Computer Organization 1.4Evolution of Operating Systems 1. 5 Machine Languages, Assembly Languages and High-level Languages 1. 6 The History of C 1. 7 The C Standard Library 1. 8 The Key Software Trend: Object Technology 1. 9 Other High-level Languages Structured Programming The Basics of a typical C Program Development Environment 1.1 2Examples of C programs General Notes About C

Spring 2005, Gülcihan Özdemir Dağ 1.1 Introduction We will learn: 1.How to convert (or formulate) a science (math, physics, chemistry etc) or an engineering (electrical, computer, civil, mechanical etc) problem into a psuedo code (algorithm) such that it can be turned into a code and solved on computer. 2.When writing the code we have to use a programming language. In this course we learn “The C programming language” as a tool to convert our algorithm into a program for the computer. In this respect we also learn the Structured programming and proper programming techniques This course is appropriate for –Technically oriented people with little or no programming experience, such as you all.

Spring 2005, Gülcihan Özdemir Dağ 1.2 What is a Computer? Computer –Device capable of performing computations and making logical decisions –Computers process data under the control of sets of instructions called computer programs Hardware –Various devices comprising a computer –Keyboard, screen, mouse, disks, memory, CD-ROM, and processing units Software –Programs that run on a computer

Spring 2005, Gülcihan Özdemir Dağ 1.3 Computer Organization Six logical units in every computer: 1.Input unit Obtains information from input devices (keyboard, mouse) 2.Output unit Outputs information (to screen, to printer, to control other devices) 3.Memory unit Rapid access, low capacity, stores input information 4.Arithmetic and logic unit (ALU) Performs arithmetic calculations and logic decisions 5.Central processing unit (CPU) Supervises and coordinates the other sections of the computer 6.Secondary storage unit Cheap, long-term, high-capacity storage Stores inactive programs

Spring 2005, Gülcihan Özdemir Dağ 1.4 Evolution of Operating Systems Batch processing (eg., Disk Operating System, DOS) –Do only one job or task at a time Operating systems –Manage transitions between jobs –Increased throughput Amount of work computers process Multiprogramming –Computer resources are shared by many jobs or tasks (we can run MS- Word, MS-Excel, , internet at the same time, but only one may be active at given time) Timesharing –Computer runs a small portion of one user’s job then moves on to service the next user

Spring 2005, Gülcihan Özdemir Dağ 1.5 Machine Languages, Assembly Languages, and High-level Languages Three types of programming languages 1.Machine languages Strings of numbers giving machine specific instructions Example: Assembly languages English-like abbreviations representing elementary computer operations (translated via assemblers) Example: LOAD BASEPAY ADD OVERPAY STORE GROSSPAY

Spring 2005, Gülcihan Özdemir Dağ 1.5 Machine Languages, Assembly Languages, and High-level Languages 3.High-level languages Codes similar to everyday English Use mathematical notations (translated via compilers) Example: grossPay = basePay + overTimePay

Spring 2005, Gülcihan Özdemir Dağ 1.6 History of C C –Evolved by Ritchie from two previous programming languages, BCPL and B –Used to develop UNIX operating system –Used to write modern operating systems –Hardware independent (portable) –By late 1970's C had evolved to "Traditional C" Standardization –Many slight variations of C existed, and were incompatible –Committee formed to create a "unambiguous, machine- independent" definition –Standard created in 1989, updated in 1999

Spring 2005, Gülcihan Özdemir Dağ 1.7 The C Standard Library C programs consist of pieces/modules called functions –A programmer can create his/her 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

Spring 2005, Gülcihan Özdemir Dağ 1.9 Other High-level Languages Other high-level languages –FORTRAN (new versions are: F, Fortran 90, F95 etc) Used for scientific and engineering applications –C++ Object oriented version of C –Java Based on both C and C++ and used mostly for internet applications –COBOL Used to manipulate large amounts of data –Pascal Intended for academic use (used to be)

Spring 2005, Gülcihan Özdemir Dağ 1.10 Structured Programming Structured programming –Disciplined approach to writing programs –Clear, easy to test and debug and easy to modify Multitasking –Specifying that many activities run in parallel

Spring 2005, Gülcihan Özdemir Dağ 1.11 Basics of a Typical C Program Development Environment Phases of C Programs: 1.Edit 2.Preprocess 3.Compile 4.Link 5.Load 6.Execute Program is created in the editor and stored on disk. Preprocessor program processes the code. Loader puts program in memory. CPUtakes 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 Primary Memory Dis k CPU Dis k

Spring 2005, Gülcihan Özdemir Dağ A Simple C Program: Printing a Line of Text Welcome to C! Output for the program is:

Spring 2005, Gülcihan Özdemir Dağ 1.12 Examples of C programs: Our first program Comments –Text surrounded by /* and */ is ignored by computer –Used to describe program #include –Preprocessor directive Tells computer to load contents of a certain file To compile (get rid of syntax error, link to the necessary libraries and convert into binary, that is executable program) above program you have at least two options: 1. Use any visual development environment such as Visual C, Turbo C, or Borland C : 2. Use Linux operating system’s compilers: cc, or gcc: > cc file1.c –o file1 (on the command line) To run the prog the program just type: > file1 1 2 /* A first program in C */ 3#include 4 5int main() 6{6{ 7 printf( "Welcome to C!\n" ); 8 9 return 0; 10}

Spring 2005, Gülcihan Özdemir Dağ A Simple C Program: Printing a Line of Text int main() –C programs contain one or more functions, exactly one of which must be main –Parenthesis used to indicate a function –int means that main "returns" an integer value –Braces ( { and } ) indicate a block The bodies of all functions must be contained in braces – allows standard input/output operations

Spring 2005, Gülcihan Özdemir Dağ A Simple C Program: Printing a Line of Text printf( "Welcome to C!\n" ); –Instructs computer to perform an action Specifically, prints the string of characters within quotes ( “ ” ) –Entire line called a statement All statements must end with a semicolon ( ; ) –Escape character ( \ ) Indicates that printf should do something out of the ordinary \n is the newline character

Spring 2005, Gülcihan Özdemir Dağ A Simple C Program: Printing a Line of Text return 0; –A way to exit a function –return 0, in this case, means that the program terminated normally Right brace } –Indicates end of main has been reached Linker –When a function is called, linker locates it in the library –Inserts it into object program –If function name is misspelled, the linker will produce an error because it will not be able to find function in the library

Spring 2005, Gülcihan Özdemir Dağ Alternative version to the first program: terminating the program with exit() function #include main ( ){ printf(“Welcome to C! \n”); exit(0); }

Spring 2005, Gülcihan Özdemir Dağ An example using math.h header file #include main ( ){ /* note that we did not use int */ float x=125; double y; y = pow(x,3); /* returns 125 cubed */ printf(“Hello World\n”); exit(0); }

Spring 2005, Gülcihan Özdemir Dağ 1.12 General Notes About C Program clarity –Programs that are convoluted are difficult to read, understand, and modify C is a portable language –Programs can run on many different computers –However, portability is an elusive goal We will do a careful walkthrough of C –Some details and subtleties are not covered –If you need additional technical details Read the C standard document Read the book by Kernigan and Ritchie