CS 251 C Programming for Engineers Spring 2016 Instructor: Dick Lang.

Slides:



Advertisements
Similar presentations
Etter/Ingber Engineering Problem Solving with C Fundamental Concepts Chapter 1 Engineering Problem Solving.
Advertisements

EC-111 Algorithms & Computing Lecture #1 Instructor: Jahan Zeb Department of Computer Engineering (DCE) College of E&ME NUST.
ICS103 Programming in C Lecture 1: Overview of Computers & Programming
Lecture 1: Overview of Computers & Programming
Copyright © 2002 W. A. Tucker1 Chapter 1 Lecture Notes Bill Tucker Austin Community College COSC 1315.
COSC 120 Computer Programming
Engineering Problem Solving With C++ An Object Based Approach Fundamental Concepts Chapter 1 Engineering Problem Solving.
Chapter Chapter Goals Describe the layers of a computer system Describe the concept of abstraction and its relationship to computing Describe.
1 Engineering Problem Solving With C++ An Object Based Approach Fundamental Concepts Chapter 1 Engineering Problem Solving.
Software Lesson #1 CS1313 Spring Software Lesson 1 Outline 1.Software Lesson 1 Outline 2.What is Software? A Program? Data? 3.What are Instructions?
Chapter 9_3 Following Instructions: Principles of Computer Operation.
Three types of computer languages
1 Lecture 1  Getting ready to program  Hardware Model  Software Model  Programming Languages  The C Language  Software Engineering  Programming.
©TheMcGraw-Hill Companies, Inc. Permission required for reproduction or display. COMPSCI 125 Introduction to Computer Science I.
CGS 3460 PROGRAMMING USING C Spring 2007 Instructor: Rong Zhang TAs: Ting Chen and Sungwook Moon.
1 CHAPTER 4 LANGUAGE/SOFTWARE Hardware Hardware is the machine itself and its various individual equipment. It includes all mechanical, electronic.
CHAPTER 1: INTORDUCTION TO C LANGUAGE
1 Programming Languages Examples: C, Java, HTML, Haskell, Prolog, SAS Also known as formal languages Completely described and rigidly governed by formal.
 2000 Prentice Hall, Inc. All rights reserved. 1 Introduction to Computers and C Programming Outline Introduction What Is a Computer? Computer Organization.
Chapter 01 Nell Dale & John Lewis.
CCSA 221 Programming in C CHAPTER 2 SOME FUNDAMENTALS 1 ALHANOUF ALAMR.
Chapter 17 Programming Tools The Architecture of Computer Hardware and Systems Software: An Information Technology Approach 3rd Edition, Irv Englander.
Introduction COMP104: Fundamentals and Methodology.
1 Lecture 2 : Computer System and Programming. Computer? a programmable machine that  Receives input  Stores and manipulates data  Provides output.
© Janice Regan, CMPT 128, Jan CMPT 128 Introduction to Computing Science for Engineering Students Creating a program.
COMPUTER SOFTWARE Section 2 “System Software: Computer System Management ” CHAPTER 4 Lecture-6/ T. Nouf Almujally 1.
Spring 2005, Gülcihan Özdemir Dağ BIL104E: Introduction to Scientific and Engineering Computing, Spring Outline 1.1Introduction 1.2What Is a Computer?
Standard Grade Computing System Software & Operating Systems.
Introduction to Computers and Programming – Computer Programming.
Chapter 1 The Big Picture.
C++ Programming Language Lecture 1 Introduction By Ghada Al-Mashaqbeh The Hashemite University Computer Engineering Department.
Theory is when you know something, but it doesn't work. Practice is when something works, but you don't know why. Programmers combine theory and practice:
Programming With C.
Visual C++ Programming: Concepts and Projects
Introduction to Computer Programming in c
Copyright © 2007 Addison-Wesley. All rights reserved.1-1 Reasons for Studying Concepts of Programming Languages Increased ability to express ideas Improved.
Systems Software Operating Systems. What is software? Software is the term that we use for all the programs and data that we use with a computer system.
CSE 2541 – Advanced C Programming. Course info Prereq – CSE 2221 or CSE 222 Co-req – CSE 2231 Website
1 CISC181 Introduction to Computer Science Dr. McCoy Lecture 1 February 8, 2005.
Robert Crawford, MBA West Middle School.  Explain how the binary system is used by computers.  Describe how software is written and translated  Summarize.
1 Lecture 2 : Computer System and Programming. Computer? a programmable machine that  Receives input  Stores and manipulates data  Provides output.
EG280 Computer Science for Engineers Fundamental Concepts Chapter 1.
C Language: Introduction
CGS 3460 Why we choose UNIX n Powerful lMulti-user operating system lGood programming tools Most heavy-duty database management systems started out on.
Computing Systems & Programming ECE Fundamental Concepts Chapter 1 Engineering Problem Solving.
Programming in C++ Dale/Weems/Headington Chapter 1 Overview of Programming and Problem Solving.
CGS 3460 CGS 3460 PROGRAMMING USING C Summer 2007 Instructor: Neko Fisher TAs: Ritwik Kumar.
Agenda Computer Languages How to Write a Simple C Program
Principles of Programming Chapter 1: Introduction  In this chapter you will learn about:  Overview of Computer Component  Overview of Programming 
Computer and Programming. Computer Basics: Outline Hardware and Memory Programs Programming Languages and Compilers.
Chapter 1 Basic Concepts of Operating Systems Introduction Software A program is a sequence of instructions that enables the computer to carry.
Department of Electronic & Electrical Engineering Introduction to C - The Development cycle. Why C? The development cycle. Using Visual Studio ? A simple.
Chapter 4 Software. Introduction Program: is a set of sequence instructions that tell the computer what to do. Software: is a collection of programs,
Chapter 11  Getting ready to program  Hardware Model  Software Model  Programming Languages  Facts about C++  Program Development Process  The Hello-world.
An overview of C Language. Overview of C C language is a general purpose and structured programming language developed by 'Dennis Ritchie' at AT &T's.
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.
BASIC PROGRAMMING C SCP1103 (02)
Engineering Problem Solving With C An Object Based Approach
Chapter 1 The Big Picture
CSCI-235 Micro-Computer Applications
Lecture 1: Introduction to JAVA
BASIC PROGRAMMING C SCP1103 (02)
Computer System and Programming
ICS103 Programming in C Lecture 1: Overview of Computers & Programming
Programming COMP104: Fundamentals and Methodology Introduction.
Computer Science I CSC 135.
Computers: Hardware and Software
Fundamentals of Computer Programming
Introduction to Computer Programming
Presentation transcript:

CS 251 C Programming for Engineers Spring 2016 Instructor: Dick Lang

Goals We will learn –Read: Understand programs written in C language –Write: Design and implement programs using C language –Compile: Use compiler to convert C code into executable file in the UNIX environment. –Execute: Run corresponding code to get results –Debug: Identify and fix syntax and semantic errors in C code. –Simple numerical programming techniques –Basic data structure construction and operations (pointers!) Appropriate for –Technically oriented people with little or no programming experience, but with a strong mathematics background

View of Computers From a programmer’s viewpoint –Computers are tools –A computer program (hopefully) turns raw data into meaningful information –A program is the driving force behind any job that any computer does A program is a list of detailed instructions These instructions are written in a particular programming language

Your Mindset… From an engineer’s point of view: –A computer/program may control a mechanism or process –A computer/program may analyze data and aid in drawing conclusions or decision-making –A computer can model a mechanism or circuit in advance of fabricating it Embedded computers are components of most electro-mechanical systems and products

Available Programming Languages Machine Languages Assembly Languages High-level Languages –C/C++ –COBOL (obsolete) –Pascal (academic) –Fortran (nearing obsolescence) –Java –Python –etc…

Machine Languages System of instructions and data directly understandable by a computer's central processing unit (i.e. hardware). Example: Every CPU model has its own machine code, or instruction set, although there is considerable overlap between some

Assembly Languages Human-readable notation for the machine language that a specific computer architecture uses, representing elementary computer operations (translated via assemblers) Example: load hourlyRate, r1 mul workHours, r1 store salary, r1 Even into the 1990s, the majority of console video games were written in assembly language.

High-level Languages Higher level of abstraction from machine language –Codes “similar” to everyday English Use mathematical expressions (translated via compilers) –Example: salary = hourlyRate * workHours Make complex programming simpler => make programming more productive & reliable

Why Program using C Initial development occurred at Bell Labs in early 70’s by Ritchie, as part of Unix OS development General-purpose computer programming language –high-level assembly –Simplicity and efficiency of the code Most widely used compiled programming language –Commonly used for writing system software –Widely used for writing applications –Hardware independent (portable, mostly) –Great influence on many other popular languages (C++, Java)

Outline of the Course – I Introductory information C program structure Basic data types and variables declaration Arithmetic expressions and operators Control statements. –Conditional statements –The while loop –The do while loop –The for loop –The if else statement –The switch statement –The break statement –The continue statement

Outline of the Course – II Formatted Input and Output Arrays and Strings Functions –Declarations –Calling Pointers Struct(ures) Preprocessor * Advanced Material –Debug using gdb and/or Visual Studio –Binary Trees –Link Lists –Recursive Functions * may be adjusted according to time and interests of students

History- I ENIAC I (Electrical Numerical Integrator And Calculator) John Mauchly and J Presper Eckert 500,000 dollars (in 1946) –17,468 vacuum tubes –70,000 resistors –10,000 capacitors, etc –800 square feet floor space –30 tons –160 kilowatts of electrical power The ENIAC 1946

History- II First home computer –Mark-8 Altair –IBM 5100 Computers 1974/1975 Altair –8080 CPU –256 Byte RAM card –$400 –The consumer needs to put them together, make it work and write any needed software. –Paul Allen and Bill Gates develop BASIC for the Altair 8800 Mark-8 Altair

History- V Personal computer –Apple II in 1977 –IBM PC in 1981 –Apple Macintosh in 1984 –Microsoft Windows 1.0 ships in November, 1985 original IBM PC 1981

Operating System What is an OS? –A program that allows you to interact with the computer -- all of the software and hardware With a command-line operating system (e.g., DOS) With a graphical user interface (GUI) operating system (e.g., Windows) Two major classes of operating systems –Windows Nice interface ?, easy to learn ? –Unix reliable timesharing operating system Embedded computers use “real-time” OS’s which do not require disks…

Why choose UNIX Powerful –Multi-user operating system –Good programming tools Most heavy-duty database management systems started out on Unix Flexible –Thousands of tools that can be combined and recombined. Reliable –Unix is hard to crash. Simple things are simple in Unix…

Your First Program #include int main() { printf("Hello World\n"); return 0; } Preprocessor: interact with input/output of your computer You will see this at the beginning of nearly all programs Tells computer to load file named allows standard input/output operations

Your First Program #include int main() { printf("Hello World\n"); return 0; } Start point of the program Preprocessor: interact with input/output of your computer C programs contain one or more functions, exactly one of which must be main int means that the function main will "return" an integer value

Your First Program #include int main() { printf("Hello World\n"); return 0; } Start point of the program Preprocessor: interact with input/output of your computer Start and finish of function

Your First Program #include int main() { printf("Hello World\n"); return 0; } Printing a line of Text Start point of the program Preprocessor: interact with input/output of your computer Start and finish of function

Your First Program #include int main() { printf("Hello World\n"); return 0; } Printing a line of Text Start point of the program Preprocessor: interact with input/output of your computer Start and finish of function New line character

Your First Program #include int main() { printf("Hello World\n"); return 0; } Printing a line of Text Start point of the program Preprocessor: interact with input/output of your computer Start and finish of function Finish and return value 0 A way to exit a function It means that the program terminated normally in this case

Comments for programs Why comments are needed –Good habit –Readable to others –Remind yourself How to comment –/* … */ –// … Examples

Compiler What is compiler –A computer program (or set of programs) that translates text written in a computer language ( the source code) into another computer language (usually, an executable file) Why we need a compiler Available C compiler in UNIX system: gcc gcc sourcefile.c –o exefile

Procedure This is your C program. Type the code in any standard text editor, and save it as helloworld.c #include int main() { printf("Hello World\n"); return 0; } helloworld.c C-compiler Type gcc helloworld.c –o helloworld to compile helloworld.c into helloworld using the gcc compiler helloworld The gcc compiler generates the corresponding executable code named helloworld. The computer can execute this machine readable code if you type./helloworld