Two-week ISTE workshop on Effective teaching/learning of computer programming Dr Deepak B Phatak Subrao Nilekani Chair Professor Department of CSE, Kanwal.

Slides:



Advertisements
Similar presentations
Chapter 11 Introduction to Programming in C
Advertisements

Introduction to Programming in C++ John Galletly.
Lecture 1: Overview of Computers & Programming
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
COSC 120 Computer Programming
Computer Science 1620 Variables and Memory. Review Examples: write a program that calculates and displays the average of the numbers 45, 69, and 106.
Your First C++ Program Aug 27, /27/08 CS 150 Introduction to Computer Science I C++  Based on the C programming language  One of today’s most.
Wednesday, 9/4/02, Slide #1 1 CS 106 Intro to CS 1 Wednesday, 9/4/02  Today: Introduction, course information, and basic ideas of computers and programming.
Three types of computer languages
 2007 Pearson Education, Inc. All rights reserved Introduction to C Programming.
Understanding Arrays and Pointers Object-Oriented Programming Using C++ Second Edition 3.
Introduction to C Programming
Starting Out with C++: Early Objects 5/e © 2006 Pearson Education. All Rights Reserved Starting Out with C++: Early Objects 5 th Edition Chapter 1 Introduction.
Basic Elements of C++ Chapter 2.
Two-week ISTE workshop on Effective teaching/learning of computer programming Dr Deepak B Phatak Subrao Nilekani Chair Professor Department of CSE, Kanwal.
Copyright 2003 Scott/Jones Publishing Brief Version of Starting Out with C++, 4th Edition Chapter 1 Introduction to Computers and Programming.
Copyright © 2012 Pearson Education, Inc. Chapter 1: Introduction to Computers and Programming.
Alternate Version of STARTING OUT WITH C++ 4 th Edition Chapter 1 Introduction to Computers and Programming.
Chapter Introduction to Computers and Programming 1.
CSC 125 Introduction to C++ Programming Chapter 1 Introduction to Computers and Programming.
Two-week ISTE workshop on Effective teaching/learning of computer programming Dr Deepak B Phatak Subrao Nilekani Chair Professor Department of CSE, Kanwal.
Modular Programming Chapter Value and Reference Parameters t Function declaration: void computesumave(float num1, float num2, float& sum, float&
Copyright © 2012 Pearson Education, Inc. Chapter 1: Introduction to Computers and Programming 1.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 1: Introduction to Computers and Programming.
IT253: Computer Organization Lecture 4: Instruction Set Architecture Tonga Institute of Higher Education.
CS161 Topic #21 CS161 Introduction to Computer Science Topic #2.
Modular Programming Chapter Value and Reference Parameters computeSumAve (x, y, sum, mean) ACTUALFORMAL xnum1(input) ynum2(input) sumsum(output)
C How to Program, 6/e © by Pearson Education, Inc. All Rights Reserved.
Two-week ISTE workshop on Effective teaching/learning of computer programming Dr Deepak B Phatak Subrao Nilekani Chair Professor Department of CSE, Kanwal.
Chapter 1 Introduction to Computers and C++ Programming Goals: To introduce the fundamental hardware and software components of a computer system To introduce.
1 Problem Solving with C++ The Object of Programming Walter Savitch Chapter 1 Introduction to Computers and C++ Programming Slides by David B. Teague,
Two-week ISTE workshop on Effective teaching/learning of computer programming Dr Deepak B Phatak Subrao Nilekani Chair Professor Department of CSE, Kanwal.
Functions Introduction to Programming By Engr. Bilal Ahmad 1ITP by Engr. Bilal Ahmad.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Chapter 2 Chapter 2 - Introduction to C Programming.
Fundamental Programming: Fundamental Programming Introduction to C++
C++ Basics C++ is a high-level, general purpose, object-oriented programming language.
CSC141 Introduction to Computer Programming Teacher: AHMED MUMTAZ MUSTEHSAN Lecture - 6.
Chapter 1 Computers, Compilers, & Unix. Overview u Computer hardware u Unix u Computer Languages u Compilers.
Two-week ISTE workshop on Effective teaching/learning of computer programming Dr Deepak B Phatak Subrao Nilekani Chair Professor Department of CSE, Kanwal.
Programming Fundamentals. Overview of Previous Lecture Phases of C++ Environment Program statement Vs Preprocessor directive Whitespaces Comments.
CHAPTER 1: INTRODUCTION C++ Programming. CS 241 Course URL: Text Book: C++ How to Program, DETITEL & DEITEL, eighth Edition.
© 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.
Two-week ISTE workshop on Effective teaching/learning of computer programming Dr Deepak B Phatak Subrao Nilekani Chair Professor Department of CSE, Kanwal.
Lecture #1: Introduction to Algorithms and Problem Solving Dr. Hmood Al-Dossari King Saud University Department of Computer Science 6 February 2012.
Two-week ISTE workshop on Effective teaching/learning of computer programming Dr Deepak B Phatak Subrao Nilekani Chair Professor Department of CSE, Kanwal.
1 Types of Programming Language (1) Three types of programming languages 1.Machine languages Strings of numbers giving machine specific instructions Example:
1 8/30/06CS150 Introduction to Computer Science 1 Your First C++ Program.
Chapter 1: Introduction to Computers and Programming.
 Problem Analysis  Coding  Debugging  Testing.
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.
Bill Tucker Austin Community College COSC 1315
Chapter Topics The Basics of a C++ Program Data Types
Chapter 1: Introduction to computers and C++ Programming
Computing Fundamentals
Basic Elements of C++.
Revision Lecture
Basic Elements of C++ Chapter 2.
CS 1430: Programming in C++ Turn in your Quiz1-2 No time to cover HiC.
Chapter 2 - Introduction to C Programming
Chapter 2 - Introduction to C Programming
Introduction to C++ Programming
Chapter 2 - Introduction to C Programming
Programming Funamental slides
Chapter 2 - Introduction to C Programming
Chapter 2 - Introduction to C Programming
Introduction to C Programming
Presentation transcript:

Two-week ISTE workshop on Effective teaching/learning of computer programming Dr Deepak B Phatak Subrao Nilekani Chair Professor Department of CSE, Kanwal Rekhi Building IIT Bombay Lecture 1, Introduction to Programming Monday 28 June 2010

Overview  Teaching and Learning Computer Programming  The three contexts of data and information handling Human, computing environment, program  Mr Dumbo: Model of Computing for a program Dumbo’s memory How Dumbo interacts with us Dumbo’s computing Instructions and their execution Dumbo’s ability to store programs

Teaching Computer Programming  The following sequence is often observed: Computers are introduced, with some information on hardware, operating systems, compilers, and editors Syntax of the chosen programming language is explained with examples Different features such as data types, control structures, arrays, functions, etc., are covered ‘Advanced’ topics such as pointers, structures, files, etc., are discussed  The subject is often called by the language used. Thus we have C programming, Java programming, etc.

Learning Computer Programming  Students first struggle with actual computers, often failing to type correctly and speedily  They then struggle to understand the programming concepts which are being doled out one by one  Several first year students have studied in their own language. They find difficulty in understanding lectures given in English, and with English books  While they may sketchily understand individual programming concepts, they are uncomfortable writing full programs. Size of their average program rarely exceeds 100 Lines of Code (LoC)  They struggle to learn problem solving due to the emphasis on details of syntax.

Information Handling in different contexts  The Human way has evolved from spoken languages to written scripts to organized information management using spoken words, handwritten documents, letters, books, instruction manuals, data sheets, registers and ledgers, forms, etc.  In particular, human exchange of information, when done manually, can take multiple forms.  Consider the following exchanges between a manager (M) and a clerk (C)

Human information exchange – scene 1 (M) Has read the temperature in the room from an instrument which gives readings in Fahrenheit. Assume the value is 86 0 F. (M) asks (S) to convert it in centigrade. (M) can give this value to (S) in many ways: 1. Verbally tells him : Writes the value on a piece of paper as (a) 86 (b) Eighty Six (c) Temperature is 86 0 F

Human information exchange – scene 1... (S) Calculates the converted value in degree Centigrade using the well known formula C = (F-32) x 5/9, finds out it is 30 0 C. Again (S) can give this value to M in many ways: 1. Verbally tells him : Writes the value on a piece of paper as (a) 30 (b) Thirty (c) Temperature is 30 0 C

Human information exchange – scene 2 Results of an exam, in the form of a list of roll numbers of students who have passed the examination along with the marks scored, have been declared in a news paper. (M) Asks (S) to find whether a student has passed the exam. (M) Can give to (S) the desired roll number in any of the ways we have seen. How would (M) give the list of declared roll numbers? 1. Write down all the numbers on a page in ascending order of marks and give it 2. Hand over the news paper to (S) which has the list in ascending order of roll numbers

Context of the Computing Environment  Hardware (monitor and Key board)  Operating Systems, command prompt  File system: Directories, subdirectories and files  Compilers, linkers, executables  Debuggers, Development Environment  Students have to cope up with all of this without properly understanding the underlying principles

Environment of a program  The ‘model’ of computing implemented by our program as seen by the user Variables Memory locations Data types Input output, files Use of control structures and data structures in the program

Teaching of CS 101 at IIT Bombay  The course is titled “ Computer Programming and Utilization”, emphasizing problem solving  We currently use C/C++ to convey programming concepts  We always discuss a problem first, describe a solution (i.e., evolve an algorithm) and then develop the program to implement that algorithm. We attempt to show complete programs. “Segments” are discussed only in the context of a full program  Lab assignments often have ready programs which they have to suitably modify.  Students form a team to do a course “project”. The code written often exceeds 2000 LoC

Approach chosen in this Workshop  We will keep in mind the syllabus usually followed in most colleges. We will generally cover topics in that order. However, the IIT style is chosen to always take a problem, work out its solution first, and then discuss the complete program. Each problem and corresponding program will have a new programming concept implicitly introduced  Labs will require modifying and executing given programs. There will be group projects

Buddhu Ram Computer - Mr Dumbo We will use the second caricature having a monitor as its head A keyboard is not shown, but learners will assume it by implication

Buddhu Ram Computer - Mr Dumbo  Dumbo cannot do anything on his own but can execute given instructions correctly  Can do arithmetic, logical comparisons, manipulate strings, etc.  Essentially, can manipulate values, and produce resultant values  He can Compute So he is a computer

Dumbo has poor memory  Dumbo cannot remember anything in his head

Dumbo has poor memory  Dumbo uses a cupboard with drawers as memory Dumbo’s memory A B C D F E

Dumbo can store values in his memory  Each drawer contains some value, for example A number: 437 A name (string): Ranade Location B: 437 Location F: Ranade B F 437 Ranade Dumbo’s memory

Some Peculiarities of memory  Each location can contain only one value And not multiple values  How does a value get into a location? Dumbo stores a given value Dumbo calculates and stores that value Some values may already exist in a location (How?)  Such values are ‘unknown’ or ‘undefined’  Not supplied by us

Exchanging values with Dumbo  Dumbo uses a cart (‘Data Bus’) to move values in and out  He can put a value in a location as instructed or can copy a value from a location and give it to us A B C D F E 58

Exchanging values with Dumbo …  But Dumbo does anything only if instructed  So if we give an instruction: cin >> B; Why do we to use ‘>>’ ? Why cin?, why not any other phrase, such as input, read, get ? Or even scanf(“%d”, &B);  Dumbo will collect a value given by us,  take it to his memory cupboard,  store it in location B Any earlier value will be overwritten

Exchanging values with Dumbo …  Dumbo can output values from locations to us  The instruction to do so is cout << G; cout << a << g << coeff << root;  Dumbo will copy values from memory locations and present these to us Values in locations are not changed  A useful additional feature cout << "Value of count is” << c;

Let us try out Dumbo’s Input/Output  cout << “Give value for B”;  cin >> B; A B C D F E 437

Let us try out Dumbo’s Input/Output …  cout << "Give value for F";  cin >> F; A B C D F E Ranade

Dumbo Computing  If two numbers are stored in drawers A and B, say 35 and 12, Dumbo can add these and store the result in a drawer, say, SUM, B SUM 12 ? A

Dumbo Computing  We instruct him by saying: SUM = A + B; B SUM 12 ? A [35]

Dumbo Computing …  How will Dumbo do this?  Dumbo uses rough sheets or ‘Registers’ Access the location A and copy the value (35) into a register Access the location B and copy the value (12) into another register Add the two values to get (47) Store the result value back in location SUM Location SUM will now contain value 47

Dumbo Computing  Dumbo uses a set of local registers Working Sheets on a table B SUM 12 ? A

Result of Dumbo Computing  A and B continue to hold the existing values  Location SUM will now contain 47 B SUM A [35]

Animated Dumbo  An Introduction to Dumbo Showing Dumbo, his memory drawers and a typical input operation  Dumbo performing computations Showing addition of two numbers

How do we give instructions  Most machines take one instruction at a time, and execute it special  Dumbo is special  We can write all our instructions in advance, and give the entire lot to him programThis collection is called a program  Dumbo has a ‘stored program’ capability

Where does Dumbo keep the program?  In the same memory!  Dumbo uses some space for storing data values, and another separate space in the same cupboard to store instructions of our program Instruction space Data Space

A complete program // program 1 (prog1.cpp) #include // #include for c programs, for using scanf, printf using namespace std; // this program reads two integer numbers and calculates the sum int main() { int A; int B; int SUM; cout << “Give two numbers” << “\n”; cin >> A >> B; SUM = A + B; cout << “Sum is” << SUM << "\n"; return 0; }

Convert temperature from 0 C to 0 F // Program 2 (prog2.cpp) #include using namespace std; // this program converts from Centigrade into Fahrenheit int main() { float C; float F; cout << “Temperature in degree Centigrades ?"; cin >> C; F=C*9/5+32; cout << F << “\n”; return 0; }

Quiz 1 Approximately, how many different programming languages have been defined so far by the computer scientists? (you have to guess) (A) About 5 (B) 6 to 20 (C) 21 to 100 (D) More than 100

Quiz 2 The symbol “\n” in the instruction: cout << F << “\n”; Will produce the following additional output: (A)Nothing visible, an end of line is inserted (B) \n (C) n (D)I cannot guess

Home Assignment  Rewrite the programs to as proper C programs  How will you explain the difficult syntax and its semantics (meaning) of the input/output instructions in C to a novice student? (scanf and printf)