CS1010 Programming Methodology

Slides:



Advertisements
Similar presentations
CS1010 Programming Methodology
Advertisements

CS1010: Programming Methodology
CS1101: Programming Methodology
1 Chapter 2 Introduction to Java Applications Introduction Java application programming Display ____________________ Obtain information from the.
Welcome and Administrative Matters.
Programming Basics Aims of Programming: –The aim of programming is to write programs to accomplish complex tasks Programming method: –functional decompositional.
Problem Solving and Program Design Programming. COMP104 Lecture 3 / Slide 2 Problem Solving Process l Define and analyze the problem. l Develop a solution.
CS1101: Programming Methodology Aaron Tan.
 Knowledge and use of tools and resources in a system: standard libraries, system calls, debuggers, the shell environment, system programs and scripting.
COS120 Software Development Using C++ AUBG Fall semester 2010 Ref book: Problem Solving, Abstraction and Design Using C++ Authors: Frank Friedman, Elliot.
CS1101: Programming Methodology
Welcome and Administrative Matters Lecturer’s slides.
CS 140 Computer Programming (I) Second semester (3 credits) Imam Mohammad bin Saud Islamic University College of Computer Science and Information.
WEEK 4 Class Activities Lecturer’s slides.
CSEB114: PRINCIPLE OF PROGRAMMING Course Introduction.
CS1101: Programming Methodology
Chapter 1 Introduction Chapter 1 Introduction 1 st Semester 2015 CSC 1101 Computer Programming-1.
UNIT 13 Separate Compilation.
CHAPTER 1 INTRODUCTION 1 st Semester H King Saud University College Of Applied Studies and Community Services CSC 1101 Computer Programming-1.
CHAPTER 1 INTRODUCTION 2 nd Semester H King Saud University College Of Applied Studies and Community Services CSC 1101 Computer Programming-1.
CS1101: Programming Methodology
WEEK 1 Class Activities.
Welcome and Administrative Matters Lecturer’s slides.
CS1010: Programming Methodology Preparing for Practical Exam (PE)
CS1010: Programming Methodology
WEEK 10 Class Activities Lecturer’s slides.
1 Chapter 1Chemistry in Our Lives 1.3 A Study Plan for Learning Chemistry Copyright © 2008 by Pearson Education, Inc. Publishing as Benjamin Cummings.
Week 12 Class Activities.
L131 Assignment Operators Topics Increment and Decrement Operators Assignment Operators Debugging Tips rand( ) math library functions Reading Sections.
WEEK 1 Class Activities.
Problem Solving and Program Design. Problem Solving Process Define and analyze the problem. Develop a solution. Write down the solution steps in detail.
CS140 – Computer Programming 1 Course Overview First Semester – Fall /1438 – 2016/2017 CS140 - Computer Programming 11.
Chapter 1 Introduction 2nd Semester H
CS1010 Programming Methodology
CS1010 Discussion Group 11 Week 3 - Computational Thinking/Algorithms.
UMBC CMSC 104 – Section 01, Fall 2016
Chapter One Problem Solving
CS1010 Programming Methodology
Completing the Problem-Solving Process
CS2100 Computer Organisation
Basic operations in Matlab
CS1010: Programming Methodology Preparing for Practical Exam (PE)
CS1010 Programming Methodology
CS1010 Programming Methodology
TMC 1414 Introduction to Programming
CS2100 Computer Organisation
COSC051: Computer Science I
Learning to Program in Python
IPC144 Introduction to Programming Using C Week 1 – Lesson 2
Chapter 1 Pseudocode & Flowcharts
Midterm Exam Preperation
Programming Funamental slides
Rational Expressions and Equations
Programming Fundamentals (750113) Ch1. Problem Solving
Escape sequences: Practice using the escape sequences on the code below to see what happens. Try this next code to help you understand the last two sequences.
COP 3502.
Chapter 1 Pseudocode & Flowcharts
King Saud University College Of Applied Studies and Community Services CSC 1101 Computer Programming-1 Done By: Asmal Alosaimi Edited By: Fatimah Alakeel.
Assignment Operators Topics Increment and Decrement Operators
Assignment Operators Topics Increment and Decrement Operators
King Saud University College Of Applied Studies and Community Services CSC 1101 Computer Programming-1 Done By: Asmal Alosaimi Edited By: Fatimah Alakeel.
Programming Fundamentals (750113) Ch1. Problem Solving
SECTION 10-4 : RADICAL EQUATIONS
Programming Fundamentals (750113) Ch1. Problem Solving
Summary of what we learned yesterday
Basic Concepts of Algorithm
Exam # 1 INFORMATION Scheduled for Thursday 7/20
Midterm Exam Preperation
Assignment Operators Topics Increment and Decrement Operators
Chapter 1 Pseudocode & Flowcharts
Presentation transcript:

CS1010 Programming Methodology Lecturer’s slides http://www.comp.nus.edu.sg/~cs1010/ WEEK 1 Class Activities

CS1010 Programming Methodology © NUS CS1010 (AY2014/5 Semester 1) Week 1: Getting Started Welcome and Admin Matters Unit 1: Computing Fundamentals Unit 2: Algorithmic Problem Solving Things-To-Do Announcements

Unit 1: Computing Fundamentals CS1010 Programming Methodology © NUS CS1010 (AY2014/5 Semester 1) Unit 1: Computing Fundamentals We will go through the document “Getting Started with UNIX and CodeCrunch” (http://www.comp.nus.edu.sg/~cs1010/labs/2014/intro_lab/gettingStarted.html) Objectives: To learn basic UNIX commands, the edit-compile-execute process, and the software use (vim for editing, gcc for compiling) We will do CodeCrunch next week.

Unit 2: Algorithmic Problem Solving CS1010 Programming Methodology © NUS CS1010 (AY2014/5 Semester 1) Unit 2: Algorithmic Problem Solving We will go through some tasks on problem- solving. You are to discuss and write the algorithms in pseudo-code.

Task 1: Area of a Circle (1/2) CS1010 Programming Methodology © NUS CS1010 (AY2014/5 Semester 1) Task 1: Area of a Circle (1/2) What is the data? Side of square = 2a 2a What is the unknown? Area of circle, C What is the condition? That is, if what is known, then what can be computed? If radius r is known, C can be computed. What would be the next question? How to obtain r ?

Task 1: Area of a Circle (2/2) CS1010 Programming Methodology © NUS CS1010 (AY2014/5 Semester 1) Task 1: Area of a Circle (2/2) a r Pythagoras’ theorem: r2 = 2 * a2 Area of circle C =  * r2 =  * 2 * a2

CS1010 Programming Methodology © NUS CS1010 (AY2014/5 Semester 1) Task 2: Coin Change Given these coin denominations: 1¢, 5¢, 10¢, 20¢, 50¢, and $1, find the smallest number of coins needed for a given amount. You do not need to list out what coins are used. Example 1: For 375 cents, 6 coins are needed. Example 2: For 543 cents, 10 coins are needed.

Task 2: Coin Change – A Possible Algorithm CS1010 Programming Methodology © NUS CS1010 (AY2014/5 Semester 1) Task 2: Coin Change – A Possible Algorithm Enter amt coins  0 coins  coins + (amt / 100) amt  remainder of amt / 100 coins  coins + (amt / 50) amt  remainder of amt / 50 coins  coins + (amt / 20) amt  remainder of amt / 20 coins  coins + (amt / 10) amt  remainder of amt / 10 coins =  coins + (amt / 5) amt  remainder of amt / 5 coins  coins + amt Print coins We call this the integer modulo (or modulus) operation. It’s very handy! In C, the modulo operator is %. Hence, amt  remainder of amt / 100 can be written as: amt  amt % 100 amt % 100 amt % 50 amt % 20 amt % 10 amt % 5

Task 3: Breaking Up An Integer CS1010 Programming Methodology © NUS CS1010 (AY2014/5 Semester 1) Task 3: Breaking Up An Integer A common sub-task in many problems involves number manipulation 252040312 5 3 2 2 4 2 1 Example: Given a positive integer n, how do you sum up all its individual digits? The answer for the above example is 19 (2 + 5 + 2 + 0 + 4 + 0 + 3 + 1 + 2)

Algorithm Before Coding CS1010 Programming Methodology © NUS CS1010 (AY2014/5 Semester 1) Algorithm Before Coding The earlier examples show that we can discuss problems and their solutions (algorithms) without writing out the codes. A sample program development process: Understanding the problem (if in doubt, ask questions!): 5 minutes Writing the algorithm: 30 minutes Testing the algorithm: 20 minutes Writing the program: 20 minutes Testing and debugging the program: 30 minutes to 3 hours or more For more complex problems, time spent in thinking about the algorithm could far exceed time spent in writing the program. The more time you invest in writing a good algorithm, the more time you will save in debugging your program.

CS1010 Programming Methodology © NUS CS1010 (AY2014/5 Semester 1) Things-To-Do Read the CS1010 Student Handbook Continue to practise the UNIX commands and vim on your own Very important as you will need them in your practical exams Revise Chapter 1 Programming Fundamentals Preparation for next week: Read Chapter 2 Variables, Arithmetic Expressions and Input/Output Read Chapter 3 Lessons 3.1 Math Library Functions and 3.2 Single Character Data

CS1010 Programming Methodology © NUS CS1010 (AY2014/5 Semester 1) Announcements Introductory workshop If you think you still need extra help on UNIX and vim after attending today’s sectional session and trying them out yourselves Check out the IVLE forum on the dates and times and how to sign up

CS1010 Programming Methodology © NUS CS1010 (AY2014/5 Semester 1) End of File