CS Prof J.P.Morrison

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

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

EL2310 Scientific Programming

Preview from Notesale.co.uk Page 6 of 52

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

Unit. Programming Fundamentals. School of Science and Technology INTRODUCTION

EL2310 Scientific Programming

Introduction to C Programming. What is a C program?

Features of C. Portable Procedural / Modular Structured Language Statically typed Middle level language

Introduction to C Programming

CS2900 Introductory Programming with Python and C++ Kevin Squire LtCol Joel Young Fall 2007

LECTURE/ STUDY NOTES ON C

c) Comments do not cause any machine language object code to be generated. d) Lengthy comments can cause poor execution-time performance.

CS 31: Intro to Systems Binary Arithmetic. Martin Gagné Swarthmore College January 24, 2016

CS 261 Fall C Introduction. Variables, Memory Model, Pointers, and Debugging. Mike Lam, Professor

CHAPTER 1 Introduction to Computers and Java

Full file at C How to Program, 6/e Multiple Choice Test Bank

C Language, Token, Keywords, Constant, variable

Software Project. Lecturers: Ran Caneti, Gideon Dror Teaching assistants: Nathan Manor, Ben Riva

introduction week 1 Ritsumeikan University College of Information Science and Engineering Ian Piumarta 1 / 20 imperative programming about the course

Chapter 1: Introduction to Computers and Java

8/23/2014. Chapter Topics. Introduction. Java History. Why Program? Java Applications and Applets. Chapter 1: Introduction to Computers and Java

Binghamton University. CS-120 Summer Introduction to C. Text: Introduction to Computer Systems : Chapters 11, 12, 14, 13

Key Differences Between Python and Java

EC 413 Computer Organization

Tutorial No. 2 - Solution (Overview of C)

Intro to Computer Programming (ICP) Rab Nawaz Jadoon

Fundamentals of C Programming

Compilation and Execution Simplifying Fractions. Loops If Statements. Variables Operations Using Functions Errors

3. Simple Types, Variables, and Constants

History of C Programming Language. Why Name C was given to Language? Summary of C Programming Language History. C Programming Language Timeline:

9/5/2018. Overview. The C Programming Language. Transitioning to C from Python. Why C? Hello, world! Programming in C

Programming for Engineers Introduction to C

Course Outline Introduction to C-Programming

CS 326 Operating Systems C Programming. Greg Benson Department of Computer Science University of San Francisco

printf( Please enter another number: ); scanf( %d, &num2);

1.1 Introduction to C Language. Department of CSE

The C Programming Language. (with material from Dr. Bin Ren, William & Mary Computer Science)

Some Computer Preliminaries

C Introduction. Comparison w/ Java, Memory Model, and Pointers

Spring 2018 NENG 202 Introduction to Computer Programming

Lecture 2: C Programming Basic

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

SKILL AREA 304: Review Programming Language Concept. Computer Programming (YPG)

Running a C program Compilation Python and C Variables and types Data and addresses Functions Performance. John Edgar 2

Hands-On Ethical Hacking and Network Defense 2 nd edition

Chapter 1 Introduction to Computers and C++ Programming

EL2310 Scientific Programming

Basics of Java Programming

Computers in Engineering COMP 208. Computer Structure. Computer Architecture. Computer Structure Michael A. Hawker

Chapter 1 INTRODUCTION

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

Operating System Labs. Yuanbin Wu

Introduction to Computing Lecture 01: Introduction to C

Chapter 2, Part I Introduction to C Programming

REVIEW. The C++ Programming Language. CS 151 Review #2

Programming in C. What is C?... What is C?

Programming in C UVic SEng 265

Slide 1 CS 170 Java Programming 1 The Switch Duration: 00:00:46 Advance mode: Auto

Room 3P16 Telephone: extension ~irjohnson/uqc146s1.html

Programming in C. What is C?... What is C?

The component base of C language. Nguyễn Dũng Faculty of IT Hue College of Science

CS 61C: Great Ideas in Computer Architecture. Lecture 2: Numbers & C Language. Krste Asanović & Randy Katz

BCA-105 C Language What is C? History of C

CS 113: Introduction to

Agenda. CS 61C: Great Ideas in Computer Architecture. Lecture 2: Numbers & C Language 8/29/17. Recap: Binary Number Conversion

Introduction to Basis and Practice in Programming

Fundamentals of Programming. Lecture 1: Introduction to C Programming

Software Development. Integrated Software Environment

CS 220: Introduction to Parallel Computing. Beginning C. Lecture 2

BRANCHING if-else statements

CS 240 Fall 2015 Section 004. Alvin Chao, Professor

Computer programming & Data Structures Unit I Introduction to Computers

Chapter 1 & 2 Introduction to C Language

Programming. Data Structure

CS 61C: Great Ideas in Computer Architecture Lecture 2: Introduction to C, Part I

CS/IT 114 Introduction to Java, Part 1 FALL 2016 CLASS 3: SEP. 13TH INSTRUCTOR: JIAYIN WANG

by Pearson Education, Inc. All Rights Reserved.

String Instructions In C Programming Language Using

AP Computer Science A: Java Programming

Introduction to C CMSC 104 Spring 2014, Section 02, Lecture 6 Jason Tang

CPS122 Lecture: From Python to Java

CS50 Supersection (for those less comfortable)

Language Design COMS W4115. Prof. Stephen A. Edwards Spring 2003 Columbia University Department of Computer Science

Introduction to Programming in C Department of Computer Science and Engineering. Lecture No. #03 The Programming Cycle

Chapter 3. Section 3.10 Type of Expressions and Automatic Conversion. CS 50 Hathairat Rattanasook

Lecture Programming in C++ PART 1. By Assistant Professor Dr. Ali Kattan

IS12 - Introduction to Programming. Lecture 7: Introduction to C

Project Data: Manipulating Bits

Lecture 9: Potpourri: Call by reference vs call by value Enum / struct / union Advanced Unix

IECD Institute for Entrepreneurship and Career Development Bharathidasan University, Tiruchirappalli 23.

The C language. Introductory course #1

Presented By : Gaurav Juneja

COMPUTER SCIENCE HIGHER SECONDARY FIRST YEAR. VOLUME II - CHAPTER 10 PROBLEM SOLVING TECHNIQUES AND C PROGRAMMING 1,2,3 & 5 MARKS

Administration Computers Software Algorithms Programming Languages

Java Fall 2018 Margaret Reid-Miller

Programming for Engineers: Getting Started

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

C++ Support Classes (Data and Variables)

CS16 Week 2 Part 2. Kyle Dewey. Thursday, July 5, 12

Transcription:

CS1061 2018-2019 Prof J.P.Morrison

C Programming C is the most popular language worldwide. Everything from microcontrollers to operating systems is written in C flexible and versatile, allowing maximum control with minimal commands. C is the predecessor of many modern computer languages. C++, Java, Python,... C is compact and easy to learn. C is a compiled language you need to run it through a compiler to transform the humanreadable form into machine-readable language. We will be using the Dev-CPP Integrated development Environment (IDE) to compose and run our C code. C is efficient and gives the programmer a great deal of control over the machine.

A Little History The language C was developed in the early 1970s at Bell Laboratories, primarily credited to the work of Ken Thompson and Dennis Ritchie. A user-friendly language from writing programs for the UNIX operating system was needed, which at the time required programs written in assembly language. Assembly programs, which speak directly to a computer's hardware, are long and difficult to debug, and they required tedious, time-consuming work to add new features. By 1973, C was stable enough that UNIX itself could be rewritten in C.

Compiling C is a compiled language you have to use a compiler to turn source code into an executable file before you can run it. The source code is written in one or more text files, which you can open, read and edit in any text editor, such as Notepad in Windows, TextEditon a Mac, and geditin Linux. An executable file is something the computer can run (execute). The compiler checks the source code for errors and, if it is error-free, creates an executable file.

A first C program Our first C program: 1. /* Sample program */ 2. #include <stdio.h> 3. int main() 4. { 5. printf("this is output from my first program!\n"); 6. return 0; 7. } When compiled and executed, this program instructs the computer to print out the line "This is output from my first program!" and then stop. Line 1 --This is a comment. Ignored by the compiler, it is for the benefit of the human reader. Line 2 --The #include command tells the compiler to include the standard I/O library functions so that they can be used in your code. Line 3 --This line is the start of the main function. Every C program has a main function. This holds the instructions that are executed first when the program is run. A typical C program will many functions, each describing and solving a specific problem. Lines 4 and 7 --The instructions of a function are enclosed in braces. Some programmers start and end a brace-enclosed block on separate lines as shown here. Others will put the open-brace ({) at the end of the first line of the function definition. Though lines of code in the program don't have to be typed on separate lines, programmers typically put each instruction on a separate line, indented with spaces, to make the code easier to read and edit later. Line 5 --This is a function call to a function named printf. That function is part of the stdio.hlibrary included from Line 1. This is an example of building on the work of other people. Note, Every line in the function must end with a semi-colon. Line 6 --Every function that returns a value must include a return statement like this one. In C, the main function must always have an integer return type, The returned value in sent back to the place from where the program is called.

Common Programming Concepts in C Functions--a function is a block of code representing something the computer should do when the function is called. Variables--a named location that can hold a value of a particular type. Data types--all data values in C has a certain size, measured in binary bits or bytes, and a certain set of rules about what these bits represent. Types include integers, floats, characters,... Operators --Operators work on operand data to produce resultant data: arithmetic operators, Boolean operators, bit-manipulation operators, etc. Control Structures Allowing the programmer to make decisions based on particular values: If, while.