Software Lesson 1 Outline

Similar documents
What is Software? Software, for our purposes, is just a word meaning programs. CS1313: Software Lesson Fall

C Introduction Lesson Outline

Arithmetic Expressions Lesson #1 Outline

Software Lesson 2 Outline

CS : Programming for Non-majors, Fall 2018 Programming Project #2: Census Due by 10:20am Wednesday September

CpSc 1111 Lab 4 Part a Flow Control, Branching, and Formatting

Characters Lesson Outline

for Loop Lesson 3 Outline

CpSc 1111 Lab 5 Formatting and Flow Control

Chapter 11 Introduction to Programming in C

CpSc 1011 Lab 4 Formatting and Flow Control Windchill Temps

Chapter 11 Introduction to Programming in C

User Defined Functions 2 Outline

CS : Programming for Non-majors, Summer 2007 Programming Project #2: Census Due by 12:00pm (noon) Wednesday June

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

C - Basics, Bitwise Operator. Zhaoguo Wang

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

for Loop Lesson 1 Outline

Chapter 11 Introduction to Programming in C

Preview from Notesale.co.uk Page 6 of 52

Numeric Data Types Outline

Chapter 11 Introduction to Programming in C

Chapter 11 Introduction to Programming in C

CpSc 1111 Lab 4 Formatting and Flow Control

Chapter 11 Introduction to Programming in C

Welcome to... CS113: Introduction to C

Array Lesson 1 Outline

Your first C and C++ programs

while Loop Example #1

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

AN OVERVIEW OF C. CSE 130: Introduction to Programming in C Stony Brook University

Chapter 11 Introduction to Programming in C

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

BASIC COMPUTATION. public static void main(string [] args) Fundamentals of Computer Science I

EP241 Computer Programming

Outline of Fortran 90 Topics

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

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

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

Physics 306 Computing Lab 1: Hello, World!

Informatica e Sistemi in Tempo Reale

Fundamentals of Programming

Fundamentals of Programming. Lecture 3: Introduction to C Programming

CSE 303 Lecture 8. Intro to C programming

Outline. Lecture 1 C primer What we will cover. If-statements and blocks in Python and C. Operators in Python and C

EL2310 Scientific Programming

User Defined Functions 1 Outline

Chapter 1 INTRODUCTION

Introduction to Linux

Introduction Objectives: 1) differentiate between high-level, low-level, and machine language; 2) explain why it is necessary to translate a program

CS 211 Programming I for Engineers

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

Pointer Lesson 2 Outline

Hello, World! in C. Johann Myrkraverk Oskarsson October 23, The Quintessential Example Program 1. I Printing Text 2. II The Main Function 3

Character Strings Lesson Outline

CpSc 1011 Lab 3 Integer Variables, Mathematical Operations, & Redirection

CSc 10200! Introduction to Computing. Lecture 1 Edgardo Molina Fall 2013 City College of New York

CMPE-013/L. Introduction to C Programming

C Language, Token, Keywords, Constant, variable

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

Motivation was to facilitate development of systems software, especially OS development.

CS Prof J.P.Morrison

Introduction to C. CS 2060 Week 1. Prof. Jonathan Ventura. Outline Introduction Introduction to C Homework 1 C Coding Style Wrap-up

while Loop Outline while Loop Lesson CS1313 Spring

CS240: Programming in C

Absolute Value. if Lesson 1 CS1313 Spring

CS240: Programming in C. Lecture 2: Overview

CSC231 C Tutorial Fall 2018 Introduction to C

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

Introduction to Scientific Computing

for Loop Lesson 2 Outline

Course Outline Introduction to C-Programming

CS : Programming for Non-Majors, Fall 2018 Programming Project #5: Big Statistics Due by 10:20am Wednesday November

3/13/2012. ESc101: Introduction to Computers and Programming Languages

Programming for Engineers Introduction to C

Motivation was to facilitate development of systems software, especially OS development.

CpSc 111 Lab 3 Integer Variables, Mathematical Operations, & Redirection

EL2310 Scientific Programming

Computer Science & Engineering 150A Problem Solving Using Computers

Computer Science & Engineering 150A Problem Solving Using Computers. Chapter 3. Existing Information. Notes. Notes. Notes. Lecture 03 - Functions

CpSc 1111 Lab 6 Conditional Statements, Loops, the Math Library, and Random Numbers What s the Point?

UIC. C Programming Primer. Bharathidasan University

Unit. Programming Fundamentals. School of Science and Technology INTRODUCTION

COMP-202: Foundations of Programming. Lecture 2: Java basics and our first Java program! Jackie Cheung, Winter 2016

Algorithms and Programming I. Lecture#12 Spring 2015

CMPT 115. C tutorial for students who took 111 in Java. University of Saskatchewan. Mark G. Eramian, Ian McQuillan CMPT 115 1/32

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

The Compilation Process

Lecture 5: C programming

Arithmetic Expressions Lesson #2 Outline

1. The Mac Environment in Sierra Hall 1242

Integer Representation. Variables. Real Representation. Integer Overflow/Underflow

1 Anatomy of a Program 4

Lecture 2. Examples of Software. Programming and Data Structure. Programming Languages. Operating Systems. Sudeshna Sarkar

Computer Science 2500 Computer Organization Rensselaer Polytechnic Institute Spring Topic Notes: C and Unix Overview

1. The Mac Environment in SIE 1222

Week 1, continued. This is CS50. Harvard University. Fall Cheng Gong

Computers and Computation. The Modern Computer. The Operating System. The Operating System

C-Programming. CSC209: Software Tools and Systems Programming. Paul Vrbik. University of Toronto Mississauga

Chapter 2. Designing a Program. Input, Processing, and Output Fall 2016, CSUS. Chapter 2.1

Transcription:

Software Lesson 1 Outline 1. Software Lesson 1 Outline 2. What is Software? A Program? Data? 3. What are Instructions? 4. What is a Programming Language? 5. What is Source Code? What is a Source File? 6. What is an Operating System? 7. Operating System Examples 8. A Simple C Program 9. Anatomy of a Simple C Program 10.Block Delimiters 11. What Is a Comment? #1 12. What Is a Comment? #2 13. Are Comments Necessary? 14. hello_world.c with Comments 15. hello_world.c without Comments 16. Flowchart for hello_world.c 17. Outputting, Compiling and Running a C Program 18. Anatomy of Outputting, Compiling and Running 19. A Less Simple C Program #1 20. A Less Simple C Program #2 21. A Less Simple C Program #3 22. A Less Simple C Program: Compile & Run 23. Flowchart for my_add.c CS1313 Fall 2017 1

What is Software? A Program? Data? Software, for our purposes, is just a word that means programs. A program is a specific, precise, detailed description of: a collection of data in RAM, on disk, etc and a sequence of actions on those data. The actions in a program are known as instructions. In computing, data are values stored in storage locations: for example, RAM, disk, etc. CS1313 Fall 2017 2

What are Instructions? The actions in a program are known as instructions. Examples: Arithmetic/Logical calculation: for example, add, subtract, multiply, divide, square root, cosine, etc. Memory operations: load from or store into RAM I/O: read from or write to secondary storage Branch: jump to an instruction that is out of sequence Repetition Allocation of resources and many more. CS1313 Fall 2017 3

What is a Programming Language? A programming language is a well-defined set of rules for specifying a program s collection of data and sequence of actions. Examples: C, C++, Fortran 90, Java, Basic, HTML, Perl, SAS, Haskell, Prolog, Pascal, Unix shell, x86 assembly language, etc. See: https://en.wikipedia.org/wiki/list_of_programming_languages CS1313 Fall 2017 4

What is Source Code? What is a Source File? Source code is a sequence of instructions, written in a human-readable programming language, that constitutes a program, or a piece of a program. An example is shown on slide #8. A source file is a file of source code. CS1313 Fall 2017 5

What is an Operating System? An operating system is a program that manages interactions between: users and hardware; users and software; hardware and software;... and so much more. CS1313 Fall 2017 6

Operating System Examples PC Operating Systems MS Windows/MS-DOS MacOS built on top of FreeBSD (Unix) Phone and Tablet Operating Systems ios (iphone, ipad) Android (many cell phones and tablets) built on top of Linux Windows Mobile BlackberryOS Unix Linux (portable) FreeBSD (portable, underlies MacOS X) Solaris (Oracle) AIX (IBM) HP-UX (Hewlett-Packard) Unicos (Cray) CS1313 Fall 2017 7

A Simple C Program Program: hello_world Author: Henry Neeman (hneeman@ou.edu) Course: CS 1313 010 Fall 2017 Lab: Sec 014 Fridays 2:30pm Description: Prints the sentence "Hello, world!" to standard output. #include <stdio.h> int main () { main Execution Section (body) Print the sentence to standard output (i.e., to the terminal screen). printf("hello, world!\n"); } main CS1313 Fall 2017 8

Anatomy of a Simple C Program Comment block Preprocessor directive Block open Execution section (also known as the program body) Block close Program: hello_world Author: Henry Neeman (hneeman@ou.edu) Course: CS 1313 010 Fall 2017 Lab: Sec 014 Fridays 2:30pm Description: Prints the sentence "Hello, world!" to standard output. #include <stdio.h> int main () Main function header { main Execution Section (body) Print the sentence to standard output (i.e., to the terminal screen). printf("hello, world!\n"); } main CS1313 Fall 2017 9

Block Delimiters The open curly brace, also known as the left brace, { acts as the start of a block and is known as the block open. The close curly brace, also known as the right brace, } acts as the end of a block and is known as the block close. The block open and block close are said to delimit the block: they indicate where the block begins and where the block ends. Delimit: Indicate where something begins and ends. CS1313 Fall 2017 10

What Is a Comment? #1 A comment is a piece of text in a source file that: tells human beings (for example, programmers) something useful about the program, BUT is ignored by the compiler, so it has absolutely no affect on how the program runs. In C, the start of a comment is indicated by and the end of a comment is indicated by All text appearing between these comment delimiters is part of the comment, and therefore is ignored by the compiler. Delimit: Indicate where something begins and ends. CS1313 Fall 2017 11

What Is a Comment? #2 A comment is a piece of text in a source file that: tells human beings (for example, programmers) something useful about the program, BUT is ignored by the compiler, so it has absolutely no affect on how the program runs. In C, the start of a comment is indicated by and the end of a comment is indicated by A comment can use multiple lines of text. The delimiters DON T have to be on the same line. CS1313 Fall 2017 12

Are Comments Necessary? Comments are ignored by the compiler, so strictly speaking they aren t needed to compile and run. But, if you don t put them into one of your CS1313 programming projects, YOU MAY LOSE A FULL LETTER GRADE OR MORE on that project. Why? Comments tell human beings useful things about your program. They help programmers including you, a month later when you ve forgotten everything about your program to understand your program. They also tell graders that you know what the heck you re doing. CS1313 Fall 2017 13

hello_world.c with Comments Program: hello_world Author: Henry Neeman (hneeman@ou.edu) Course: CS 1313 010 Fall 2017 Lab: Sec 014 Fridays 2:30pm Description: Prints the sentence "Hello, world!" to standard output. #include <stdio.h> int main () { main Execution Section (body) Print the sentence to standard output (i.e., to the terminal screen). printf("hello, world!\n"); } main CS1313 Fall 2017 14

hello_world.c without Comments #include <stdio.h> int main () { printf("hello, world!\n"); } CS1313 Fall 2017 15

Flowchart for hello_world.c int main () { printf("hello, world!\n"); } Start An oval denotes either the start or the end of the program, or a halt operation within the program (which we ll learn about later). Output Hello, world! End Reference: http://www.edrawsoft.com/flowchart-symbols.php A parallelogram denotes either an input operation or an output operation. An arrow denotes the flow of the program. CS1313 Fall 2017 16

Outputting, Compiling and Running a C Program % cat hello_world.c Program: hello_world Author: Henry Neeman (hneeman@ou.edu) Course: CS 1313 010 Fall 2017 Lab: Sec 014 Fridays 2:30pm Description: Prints the sentence "Hello, world!" to standard output. #include <stdio.h> int main () { main Execution Section (body) Print the sentence to standard output (i.e., to the terminal screen). printf("hello, world!\n"); } main % gcc -o hello_world hello_world.c % hello_world Hello, world! CS1313 Fall 2017 17

Anatomy of Outputting, Compiling and Running % cat hello_world.c Unix command to output to the screen Program: hello_world Author: Henry Neeman (hneeman@ou.edu) Course: CS 1313 010 Fall 2017 Lab: Sec 014 Fridays 2:30pm Description: Prints the sentence "Hello, world!" to standard output. #include <stdio.h> int main () { main Execution Section (body) Print the sentence to standard output (i.e., to the terminal screen). printf("hello, world!\n"); } main % gcc -o hello_world hello_world.c % hello_world Hello, world! Unix command to compile Unix command to run Program output CS1313 Fall 2017 18

A Less Simple C Program #1 Program: my_add Author: Henry Neeman (hneeman@ou.edu) Course: CS 1313 010 Fall 2017 Lab: Sec 014 Fridays 2:30pm Description: Input two integers, compute their sum and output the result. #include <stdio.h> int main () { main Declaration Section Named Constant Subsection const int program_success_code = 0; Local Variable Subsection addend: The addend value that the user inputs. augend: The augend value that the user inputs. sum: The sum of the addend and the augend, which is output. int addend, augend, sum; Continued on the next slide. CS1313 Fall 2017 19

A Less Simple C Program #2 Execution Section Greeting Subsection Tell the user what the program does. printf("i'll add a pair of integers.\n"); Input subsection Prompt the user to input the addend & augend. printf("what two integers do you want to add?\n"); Input the integers to be added. scanf("%d %d", &addend, &augend); Continued on the next slide. CS1313 Fall 2017 20

A Less Simple C Program #3 Calculation Subsection Calculate the sum. sum = addend + augend; Output Subsection Output the sum. printf("the sum of %d and %d is %d.\n", addend, augend, sum); return program_success_code; } main CS1313 Fall 2017 21

A Less Simple C Program: Compile & Run % gcc -o my_add my_add.c % my_add I'll add a pair of integers. What two integers do you want to add? 5 7 The sum of 5 and 7 is 12. % my_add I'll add a pair of integers. What two integers do you want to add? 1593 09832 The sum of 1593 and 9832 is 11425. CS1313 Fall 2017 22

Flowchart for my_add.c A rectangle denotes an operation other than I/O or branching (for example, calculation). CS1313 Fall 2017 23