Software Development Method. Assignments Due – Homework 0, Warmup Reading – Chapter 2 – 2.1-2.4.

Slides:



Advertisements
Similar presentations
Etter/Ingber Engineering Problem Solving with C Fundamental Concepts Chapter 2 Simple C Programs.
Advertisements

Computer Programming w/ Eng. Applications
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 to C Programming
TDBA66, VT-03 Lecture - Ch. 21 A complete C-program Display Fig. 2.1 and comment on different things such as Preprocessor directives Header files Identifiers.
Software Development Method & C Language Elements H&K Chapter 1-2
1 ICS103 Programming in C Lecture 3: Introduction to C (2)
Algorithms. Software Development Method 1.Specify the problem requirements 2.Analyze the problem 3.Design the algorithm to solve the problem 4.Implement.
Structure of a C program
C Programming Language 4 Developed in 1972 by Dennis Ritchie at AT&T Bell Laboratories 4 Used to rewrite the UNIX operating system 4 Widely used on UNIX.
Topic 2 – Introduction to the C Programming Language.
1 Lecture 2  Input-Process-Output  The Hello-world program  A Feet-to-inches program  Variables, expressions, assignments & initialization  printf()
1 Chapter 2 C++ Syntax and Semantics, and the Program Development Process Dale/Weems/Headington.
 2007 Pearson Education, Inc. All rights reserved Introduction to C Programming.
Algorithms. Software Development Method 1.Specify the problem requirements 2.Analyze the problem 3.Design the algorithm to solve the problem 4.Implement.
Declarations/Data Types/Statements. Assignments Due – Homework 1 Reading – Chapter 2 – Lab 1 – due Monday.
1 ICS103 Programming in C Lecture 2: Introduction to C (1)
Computer Science: A Structured Programming Approach Using C1 Objectives ❏ To understand the structure of a C-language program. ❏ To write your first C.
Introduction to C Programming
Basic Input/Output and Variables Ethan Cerami New York
CISC 105 – Topic 2 Last Topic Review Name the principle components of a computer. What advantage does assembly language have over machine language? What.
Basic Elements of C++ Chapter 2.
Chapter 2 : Overview of C By Suraya Alias. /*The classic HelloWorld */ #include int main(void) { printf(“Hello World!!"); return 0; }
Goals of Course Introduction to the programming language C Learn how to program Learn ‘good’ programming practices.
Chapter 2 Overview of C Part I J. H. Wang ( 王正豪 ), Ph. D. Assistant Professor Dept. Computer Science and Information Engineering National Taipei University.
C Programming Lecture 4 : Variables , Data Types
Agenda  Commenting  Inputting Data from Keyboard (scanf)  Arithmetic Operators  ( ) * / + - %  Order of Operations  Mixing Different Numeric Data.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Chapter 2 Chapter 2 - Introduction to C Programming.
Introduction to C Programming Angela Chih-Wei Tang ( 唐 之 瑋 ) Department of Communication Engineering National Central University JhongLi, Taiwan 2010 Fall.
1 INTRODUCTION TO PROBLEM SOLVING AND PROGRAMMING.
Lecture 2: Introduction to C Programming. OBJECTIVES In this lecture you will learn:  To use simple input and output statements.  The fundamental data.
Chapter 3: Formatted Input/Output Copyright © 2008 W. W. Norton & Company. All rights reserved. 1 Chapter 3 Formatted Input/Output.
THE BASICS OF A C++ PROGRAM EDP 4 / MATH 23 TTH 5:45 – 7:15.
Introduction to Programming
1 Chapter 2 C++ Syntax and Semantics, and the Program Development Process.
Functions with Input/Ouput. Assignments Due – Lab 2 Reading – Chapter 4 –
CSCI 3133 Programming with C Instructor: Bindra Shrestha University of Houston – Clear Lake.
Overview of C. C—a high-level programming language developed in 1972 by Dennis Ritchie at AT&T Bell Laboratories. We will discuss: –the elements of a.
9/29/99B-1 CSE / ENGR 142 Programming I Variables, Values, and Types © 1998 UW CSE.
© 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.
A.Abhari CPS1251 Topic 2: C Overview C Language Elements Variable Declaration and Data Types Statement Execution C Program Layout Formatting Output Interactive.
1 Types of Programming Language (1) Three types of programming languages 1.Machine languages Strings of numbers giving machine specific instructions Example:
1 C Syntax and Semantics Dr. Sherif Mohamed Tawfik Lecture Two.
C Language Elements Preprocessor Directives # (sign for preprocessor directive commands) #include Standard header file (.h) Library.
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.
CCSA 221 Programming in C CHAPTER 3 COMPILING AND RUNNING YOUR FIRST PROGRAM 1 ALHANOUF ALAMR.
Lecture2.
Chapter 1.2 Introduction to C++ Programming
CSCE 206 Structured Programming in C
Chapter 1.2 Introduction to C++ Programming
Chapter 2 - Introduction to C Programming
What's a Computer? Monitor Disk Main mouse Memory Keyboard Network
Revision Lecture
Chapter 2 Overview of C.
ICS103 Programming in C Lecture 3: Introduction to C (2)
Chapter 2 - Introduction to C Programming
Lecture2.
Introduction to the C Language
Variables In programming, we often need to have places to store data. These receptacles are called variables. They are called that because they can change.
Chapter 2 - Introduction to C Programming
CC213 Programming Applications
Chapter 2 - Introduction to C Programming
Chapter 2 - Introduction to C Programming
Chapter 2 - Introduction to C Programming
Chapter 2 - Introduction to C Programming
Introduction to C Programming
Presentation transcript:

Software Development Method

Assignments Due – Homework 0, Warmup Reading – Chapter 2 –

Software Development Method 1.Specify the problem requirements 2.Analyze the problem 3.Design the algorithm to solve the problem 4.Implement the algorithm 5.Test and verify the completed program 6.Maintain and update the program

Algorithms Step-by-step procedure for solving a problem Be as specific as possible – include all steps Example – laundry

Software Development Method 1.Specify the problem requirements In this class, often done for you 2.Analyze the problem Your job – what are the inputs and outputs 3.Design the algorithm to solve the problem Your job – write it down and turn it in! 4.Implement the algorithm Your job 5.Test and verify the completed program Your job – this is the most time consuming part Go back to step 4 if your program fails the tests 6.Maintain and update the program Always assume you will reuse your code at some point

Calculate Tax on an Item Problem Analysis Algorithm design Implementation Testing Maintenance

/* * A program to calculate tax and total cost. */ #include /* printf, scanf definitions */ #define TAX_RATE.05 //constant rate of taxation int main (void) { double cost, tax, total; //spaces for item cost, tax, and total cost /* get the cost of the item */ printf("Enter cost of item: "); scanf("%lf", &cost); /* calculate the tax */ tax = cost * TAX_RATE; // calculate the total cost total = cost + tax; /* display the result */ printf("The tax on your item is $%5.2lf.\n", tax); printf("The total cost of your purchase is $%5.2lf.\n", total); return(0); }

Heading Indicates what the program does –You will get a format to follow in lab Comments –/* … */ –// to the end of the line /* * A program to calculate tax and total cost. */

Preprocessor Directives #include – use a particular library #define – replace TAX_RATE with.05 in the program #include /* printf, scanf definitions */ #define TAX_RATE.05 //constant rate of taxation

Function Header All programs must have a main function void – inputs int – outputs main should always look like this int main (void) {

Syntax outline of main should always look like this int main (void) { body return(0); }

Variable Declaration Creates three spaces in the computer’s memory to hold numbers double –type – space will hold a number with a decimal –name – variables given unique identifiers Reserved words –words with special meaning (double, int, void, return) Identifiers –letters, digits, and underscores –cannot begin with a digit –cannot be a reserved word –cannot conflict double cost, tax, total; //spaces for item cost, tax, and total cost

Input and Output Standard identifiers printf – print to the screen scanf – read from the keyboard (standard input) –%lf – read a long float –store it in the cost space –& – address (instead of value) printf("Enter cost of item: "); scanf("%lf", &cost);

Calculation Typical math symbols –(+, -, *, /) = - assignment, not equality! alternative (if we don’t need tax alone) total = cost + (cost * TAX_RATE); /* calculate the tax */ tax = cost * TAX_RATE; // calculate the total cost total = cost + tax;

Display Results printf – formatted print replace “%lf” with number 5.2 – precision \n – escape character (newline) printf("The tax on your item is $%5.2lf.\n", tax); printf("The total cost of your purchase is $%5.2lf.\n", total);