 Good morning everybody and welcome back. So we now proceed with the introduction to programming which is the first lecture on the theme of effective teaching learning of computer programming. In this lecture, I will briefly discuss the teaching and learning of computer programming as it happens. Some of the points I had made during my talk on the introduction to workshops, I will elaborate these a bit further. More specifically, I will talk about the three contexts of data and information handling. I have not seen any book on computer programming discussing these issues because some of these actually are outside the learning of programming, but they very deeply affect the way our students are able to learn. What are these three contexts? The first context is the human context because that is the context with which our students are familiar. Before they have come to the world of computers in our engineering colleges, they have been interacting with human beings and it is important to understand what they mean by exchange of information, by exchange of data values. How do they carry out these exchanges? The second context is the context of computing environment comprising of the hardware operating system, compilers, etcetera, where we expect people to interact with the computer primarily through a command language, which is peculiar to operating system or to the development environment. And third and the last is the environment described by our computer program. In fact, that is the matter of study of detailed investigations during a course on programming. Once we understand all these three, we will then go to describe the program environment which is the subject matter of computer programming. Here I have chosen to model a computer program or a computer by one Mr. Dumbo or what I call a Budhuram computer. So we will describe the model for the Dumbo's memory, we will describe how Dumbo interacts with us, namely the equivalent of input-output operations, we will describe very briefly the way Dumbo does computing without really using the words like arithmetic and logic unit and processor and so on. We will try to go to the heart of how the computing is done inside just by a very simple example. Finally we will talk about instructions and their execution and most importantly the ability of Dumbo to store our programs leading to the stored program concept in digital computers. To begin with, let me consolidate our findings and I believe most of my colleagues will agree with these findings. This is about the teaching of computer programming that happens in our colleges. Typically the following sequence is observed when we teach computer programming. First we introduce the computers, little information on hardware like the keyboard, monitor. Then we describe very briefly the operating system, again primarily the fundamental commands that we give to the operating system. We briefly describe the compiler, the notion of compiler, editors, etcetera. I would like you to appreciate that this entire introduction is covered in a very limited period at the beginning. Consequently our students are not fully aware of the underlying concepts yet because they are smart they are able to learn to use these sort of mechanical. Then we proceed with description of the syntax of the chosen programming language which we explain with examples. We introduce different features such as data types, control structures, arrays, functions etcetera. And then the so called advanced topics typically in a course on C programming these would include pointers, structures, files etcetera. This subject often gets referred to by the language that is used. So this is an unfortunate consequence of our choosing a particular programming language. If we have chosen C programming language students start calling this course as a course in C programming. If we choose Java students call this a Java programming. So it is not uncommon to find in fact students even after they pass out their degree to see that they write in their curriculum vitae skills. They will say C C plus plus Java. I have not seen a single student writing competence in programming. In fact we all know as teachers that if we at all we wish to distinguish between different programming paradigms the correct distinction is based on the type of programming that we do. Commonly acknowledged paradigms are procedural programming as represented by languages like C, Pascal, Fortran, Cobol or what have you. Object oriented programming represented typically by Java and C plus plus and functional programming often used in solving artificial intelligence problems. While there are distinct features in these three paradigms fundamentally the procedural programming has to be understood by all students. So even in universities where the first course in programming is taught using object oriented languages some fundamentals of control structures, assignments, variable types, data types, etc. have to be covered. Invariably all over the world the first course in programming often emphasizes procedural programming and therefore the language C is often chosen in these days earlier it used to be Fortran or Pascal. In India most of the universities has C as the first language chosen for teaching the first course in programming and consequently many people including some of our teachers refer to this as a C programming course. The first suggestion I would like to make to all my colleague teachers is stop calling programming courses by the names of the programming language that we use. We do a significant harm psychologically because our students start believing that what they have learned is a programming language. The objective of a first course in programming is to teach programming concepts. If we stop using such terms students will also be discouraged. In any case it is important to emphasize right in the first few lectures is what is being learned is programming concepts and incidentally those programming concepts are being conveyed using a particular programming language which happens to be C in our case. What about learning computer program? So consider now that how students first struggle with actual computers often failing to type correctly and speedily and that is because in India it is not a common practice for our students to learn plain typing when they are studying in schools. In other developed countries you will find that most of the students studying in school are well versed with typing. Consequently many of our students struggle with keyboard. They are unfamiliar with the ASDFG kind of sequencing that you see and they take a lot of time in typing simple things. They will eventually become expert as I said they are all smart people but this is an impediment. One way I have found a not exactly a solution but a reasonable stopgap arrangement is to give them a printed layout of the keyboard and ask them to practice just on that piece of paper. These days fortunately many students have computers at home and they are well versed with the typing but this is a problem. Having overcome this they then struggle to understand the programming concepts which are being doled out one by one. Now this is where I would blame our syllabus pattern which somehow is followed often very religiously. If the syllabus pattern says that you will first discuss the number representation, then you will discuss the data types, then you will discuss the assignment statement, then you will discuss the conditional etc. etc. We often keep looking at these concepts giving small examples not necessarily full programs. So they struggle to understand the programming concepts which are being given piecemeal to them. Additionally the problem which I mentioned earlier in the day several first year students have studied in their own language and they find difficulty in understanding lectures given in English and also with English books. Last but not the least while they may sketchily understand individual programming concepts they are not very comfortable writing full programs. I would like to quote from a book which I have seen being a reference book in most engineering colleges. It is a book called How to Solve It by Computers by Drume. He makes a statement there that we expect students to write programs without forcing them to read a large number of programs. He compares it with writing essays. You consider essay writing in English or Marathi or Telugu whichever language. Our students while learning to write essays typically would have read 10 or 12 complete essays on specific topics. They understand how other people have written essays and then they start writing essays. In our case however without exposing students to read 10, 20 programs which solve specific problems we suddenly start by asking them to write programs. This is rather unnatural. The fact that our students are still able to do that shows that the human mind is extremely capable. But perhaps we can help the students better if in all our examples we insist on writing full programs even if we are explaining a very simple concern. This way we will be exposing students to read full programs and also we will be able to slowly build the different features in such programs. Mainly whenever we write a program we are solving a problem. So right from day one we are emphasizing problem solves or solving the problem. In fact the objective of a computer program is to solve a problem. It is not about the correct syntax use. It is not even about the correct semantics use. But how the semantics has been deployed to solve the problem is what is important. As a result of what happens in real life you will notice and at least I have found it at many places. By the way by first hand experience with the teaching and learning of not just computer programming but our educational problems stretch back to 2002 when I took a sabbatical leave for one year and went around the country giving talks to engineering college students and teachers and interacting with them. I went to about 67 places. Amongst other things that I found I noticed that on an average the students who write the programs in programming course or even later the size of their average program rarely exceeds 100 lines of call. I was making a comparison between our university style of education and IIT and IIT style of education. It is not uncommon for a group project in my class for example to turn out about 2000 to 5000 lines of working code at the end of the semester. Now this is a very fundamental difference because the size of code actually in its absolute sense is not material. But what is material is that the confidence that the students gain they believe that they can write large programs which will work comfortable. Similarly, they struggle to learn problem solving due to the emphasis on details of syntax. I have tried to adopt a strategy in this course where if you have seen the schedule in the Moodle there is a topic that is discussed in the morning and there are examples in the second session in the morning. These examples are as well as introduction of a particular topic are all based on taking up a real problem a fairly not a very trivial problem. Of course, we start the course with some simple problems but take a really good problem and try to emphasize solving that problem. So, we will actually spend a lot of time in discussing let us say the underlying principle of Newton-Raphson method or the underlying principle of Fibonacci series when we look at that problem and only finally we arrive at the problem solution in terms of writing the program during which time we emphasize the different aspects of the programming language syntax and semantics. Now, I would like to spend some time on the three different contexts which I mentioned that our students are familiar with as a matter of fact if we reflect back in our own lives when we studied computer programming first time we had roughly faced the similar situation. First of all consider the human way of exchanging information or data it has evolved from spoken languages to written scripts to organized information management using everything spoken words hand written documents, letters, books in fact and I am talking about pre-computer era even before the computers came engineering discipline was well understood. So, there were instruction manuals there were data sheets in business side we would be using registers teachers use attendance registers bankers use lasers there are application forms for various things including when you want to you know book a seat or a birth in a railway nowadays all of these systems are computerized so similar things have been mapped on to the computer screens but traditionally these are the mechanisms that human beings use unfortunately when human beings use these mechanisms since they know they are dealing with other human beings they take a lot of liberties they may choose any one of these options at any point in time and feel fairly confident that the other humans will understand it unfortunately that is not with the case with the computer programs so they find it quite confusing sometimes that how a human being is able to understand the information that I am giving whereas this dumbo computer is not able to understand and it is important for us to bring out that distinction in particular human exchange of information when it is done manually between person to person can take multiple forms so to exemplify I have taken some following sample exchanges between let us say a manager whom I call M and a clerk whom I call C as computer here is first scene let us say M has read the temperature in the room in which he or she is working from an instrument which gives readings in degrees Fahrenheit the instrument was probably bought from United States which specializes in showing Fahrenheit since we follow the centigrade temperature our manager is not comfortable with the value that he or she has read assume the value is 86 and let's say M ask S to convert it in centigrade please note that when M ask S to convert the value in centigrade M assumes that S knows the underlying formula if the S does not know that formula to explain that formula is equivalent to writing an algorithm in a program for S to execute but we will keep that in advance because we are discussing only the data exchange consider this how will M give this value 86 to S M can do so in many ways number one verbally tells him 86 and that is adequate number two writes the value on a piece of paper now this writing can be done in multitude of ways one is just say 86 numerical second he writes in words 86 so that there is no conflict third he writes a elaborate thing temperature is 86 degrees Fahrenheit even when you say writing a number 86 the font that the person uses somebody would write in very large font 86 somebody will write in such a small font that will be barely understand somebody may write 86 in Marathi or Hindi or Telugu where the symbol used for 8 and 6 are different than what you see here on the screen unfortunately as far as human beings are concerned since the context is same we presume that M and S speak and use the same language S will understand whether the font is small or big whether the writing is in English or any other language which they mutually understand and therefore human beings have come to believe that exchanging information in any one of these forms is perfectly okay consider continuation of the scenario where S calculates the value let's say converts value in the degree centigrade using the well-known formula C is equal to F minus 32 multiplied by 5 by 9 please understand that as far as human being is concerned human being does not recognize the distinction between integer values and floating point values as we teachers do or as computers do so for a person 5 by 9 is a proper fracture the value is not 0 is actually finding out a ratio with which he has to multiply F minus 32 and C will correctly find out this value to be 30 in this extend case the value given is such that actually you get an integer num but even if you were to get a fractional number our S will be able to calculate it correct how will S give back this value again going back the same mechanism S will verbally tell manager value 30 or rise down on a piece of paper as 30 30 0 30 or word 30 or temperature is 30 degree centigrade or whatever what all of these are perfectly acceptable to him and understandable to him consider another scene these are more complex scene and I will later on in this workshop related to sorting and searching consider results of an exam I have been published in a newspaper and the newspaper gives the list of role numbers of students who have passed the exam along with the mark score the manager M is interested in knowing whether a particular student has passed the exam or not so M has asked to find out whether a student has passed the exam of course M has to give the role number of that student now this role number can be given in any one of the ways that we have seen earlier but there is a question of giving S the list of role numbers and their marks there are two different ways in which M can give this list of declared results to S one M writes down all the numbers on a page in ascending order of marks and gives it to us second the M hands over the newspaper to us which happens to have the list in ascending order of role numbers while our students may not be able to appreciate the difference because both of them seem same to a student for example if I am a student I will say how does it matter in which order the role numbers are given after all you have given me one role number and I have to search whether that role number exists or not so then naturally occurring algorithm to the student will be start reading the role numbers one by one if you find a match well the student has been found and the marks will tell you whether he has passed or not if you find don't find the match you say that students result is not declared but invariably every student will come up with a solution which will involve comparing a given role number with all the role numbers in the list now this is okay when there are 200 role numbers or 300 role is this okay when there are let's say 100,000 role numbers obviously that is where we shall subsequently talk about the notion of sorted arrays binary search and so on what I am trying to tell you here is that while human beings can interact with each other in multitude of different ways when it comes to a computer program there is a specific way of dealing with input and output and that has to be clarified that the students right from day one particularly when we talk about individual memory locations or collection of locations representing an array sorted array etc etc next let me briefly discuss the context of the computing environment itself please note I am not talking about programming language or the environment that a program sees that we shall describe in the air first we have discussed the environment with which student is familiar namely during the exchange of information and data with other human beings next I am now trying to describe the context of computing environment where do the students see the computing environment when the first time sit in front of a computer so in our laboratories we will have a first lab where we will expose the student saying this is your terminal this is your keyboard typically a teaching assistant or a teacher will explain to him the basic hardware components the student will learn these things mechanical monitor and keyboard the student can see keyboard is something the student is going to operate upon so student understands these things better the student can see some lines coming up lines of text coming up on the screen so the student can understand these things better but the concept of operating system the command prompt the notion of login all these are new the students might be thrilled what the student is learning and please note in his mind his or her mind what the student is thinking the student tends to treat the computing environment as another hidden human being and therefore constantly compares in his or her own mind the interaction with other human beings that he or she is familiar with so I have been interacting with human beings in a particular way now you are asking me to interact with this terminal and keyboard and then you are telling me there is something called operating system behind it and it shows a command prompt and you have to give a command then I will suddenly tell you there are directories and sub directories so there is a notion of a file system the only directory I know beforehand before coming to your lecture was the telephone director I do not have any concept of a sub directories I do not know the concept of a file the only file that I know of is an assignment file which I will submit which contains some papers I think we ought to appreciate that it is not straightforward and easy for students to make a mental model of this environment yet they are smart as I said and therefore they learn some basic things but quite often they form in their mind a semi-cooked model of this environment we further complicate the matter by saying there are compilers and their compile time options and you have to link the libraries and there are executable files and there are text files in programs then later on we say there are debuggers there are development environments in short it is a recipe for a great disaster in confusion the fact that our students are able to cope up with this I will repeat once again shows how smart human beings are but we must endeavor to do something what is it that we can do please note that ultimately our objective in the course is to teach computer program and the earlier we go to programming concept the beta it is for us to cover adequate material in that semester long course but since this is the first course is the first time the students are coming close to a computing environment it is well worthwhile to spend the time in the labs in the first two weeks where without necessarily explaining the conceptual framework of all these underlying themes you just tell them what is the minimal thing that they require to understand the notion of directories sub directories text files which represent their program the notion of compilation process and how to execute a program or the minimal it is like you are teaching a student to drive a car without having to explain the underlying IC engine the clutch system the gear system the steering wheel as long as the student knows that if it turns the steering left the car will move to the left you turn the steering right the car will move to right if you press the accelerator pedal car will move faster if you press break it will stop so how do you extract the minimal important concepts and strengthen those while giving an overview of all the remaining things will decide how successfully or how easily the student can cope up with the entire thing I will conclude this by saying that students have to cope up with all of this without properly understanding the underlying principles so too early in life please do not try to unnecessarily emphasize clarity of understanding of the underlying principles of issues such as operating system hardware command prompt file system etc etc whatever is minimal required for the student to quickly get into learning of programming should be our endeavor subsequently during the course of the subject teaching later on we can elaborate some of these in this context I find the way the syllabi are organized in many universities are to be blamed the traditional way the computer programming was taught in the early evolution and I am talking about 60s and early 70s when I and several of my senior colleagues learned programming at that time programming languages as we know them were just coming up the essential computer was a digital computer those of you who have programmed the early computers will know that assembly language programming was still heart of program compiler was an afterthought and therefore the normal teaching of computer programming always started with a complete hardware description the description of machine language and assembly language programming and higher level language programming was considered as a subsequent development however in modern days it is well understood that to teach fundamental computer programming concepts as will be practiced by our lack of students in their professional lives do not require a thorough understanding of these underlying hardware or the message they must understand the programming concept first those of them who have to for example work with embedded systems or with electronic systems or with other instruments they may eventually learn all those details that we talk of so this is the context of computing environment in a nutshell we shall keep it short and sweet whatever is important will be indicated and people will learn more by practice of their our obvious objective in the at this juncture is to ensure that our students are able to compile and execute a program when we start teaching program so first week and I have tried to reflect it the first lab session today that you will do you will essentially familiarize yourself with the Linux environment and the model nothing else so you will fire you will adopt yourself to how to give commands understand directories subdirectories of course I have shortened the thing because all of your teachers and all of you know these concepts even if some of you have not worked with you next it doesn't matter because you are familiar with all underlying concepts what I am trying to request you is when you go back reflect upon how you would like to teach this portion to the students with minimal facts emphasize correctly such that they are sufficient for the students to ultimately compile and execute their programs any additional thing that we wish to emphasize either because they are dictated by the syllabus or because we feel our students must learn should be done appropriately at some later stage during the course finally we come to the environment of a program it is the model of a computing implemented by our program as seen by the user or as seen by the program what is that model the notion of variables the notion of memory locations the notion of data types the notion of input output and subsequently the notion of files the notion of control structures and data structures which we deploy in our program this is essentially the subject matter of this computer programming course often we start with these concepts and that is the order which we have to follow whichever way we look at it but I have found it useful to explain a fundamental model of a computer program you explain the notion of memory locations input output computations etc is to use what I call mr. Dumbo let me explain that model to you you feel you can use this or you can adopt your own model but I believe it is important that in the first lecture we try to explain to our students in as simple a way as possible the fundamentals of this model of computing as is implemented by a program before going to the model of Dumbo I will very briefly recapitulate the teaching of CS 101 which is our first course in IIT Bombay in fact to my teacher colleagues I would like to request that if not individually at least as groups if they would like to comment upon how a programming course is taught what are the various components in their own places it would be perhaps a very useful thing because all of us can learn from each other there will always be some good practice followed somewhere which we would like to use coming back to CS 101 the course is titled computer programming and utilization thus emphasizing problem solving by the way in IIT Bombay and most rarely in all IITs many NITs and many of the other reputed institutions particularly those which have academic autonomy the course is never known by the tool deployed so for example we do not have a course in oracle or we do not have a course in my SQL or post base SQL we have a course in database management system we have a course in object oriented program we have a course in web technology we do not ever mention the specific technology by name we currently use cc plus plus to convey programming concepts I would also like to suggest I would also like to mention that this course is taken by all first year students in IIT Bombay and primarily it is regarded as a service course and not as a first course to computer science students for computer science students in their second semester we have a special follow-up course but this course is primarily meant for teaching basic programming concepts to students of all branches because we know that mechanical engineers electrical engineers civil engineers geologists physicists kms everybody is going to use programming to some extent or the other and therefore this course is a course meant for all students and therefore we emphasize problem solving so we always discuss a problem first we then describe a solution which is akin to evolving an algorithm and then we develop the program to implement that algorithm we often attempt to show complete programs if there are segments to be discussed they are discussed only in the context of the complete program a segment is rarely introduced for the first time and talking about a new concept first a program will be shown and then the segment will be described or discussed if need be not everybody may agree with this style I am just describing what we do at IIT Bomb and I am not talking only about myself we have had about 10 teachers teaching this course in the past ten years and as you know there is a joke about teaching computer programming the joke says that if there are m teachers teaching computer programming then there are n different ways in which programming is taught and n is often greater than m because the same teacher may hold different ideas of teaching programming at different times this is only the first part of the joke the second part of the joke says that irrespective of how the programming is taught a student learns programming on his or her own that is slightly derogative but there is a partial truth in both of these statements what we are trying to come together in this great collaborative endeavor is to learn from each other the best practices and perhaps adopt some of them in whichever way we teach the course so coming back to CS 101 our lab assignments often have ready programs which students have to suitably modify so we typically give full programs in the lab assignments which the students are required to suitably modify this works very well initially please understand that if I expect a student to write a program even of hundred lines to expect a student to type in hundred lines in a limited time of the lab is unfair on the other hand what do we want to teach the student and what we want to test whether the student has understood or not are some very specific constructs within the program so there is no harm in giving a whole lot of mundane things pre-return and already kept in the appropriate director for example include stdio.h or in c++ include IO stream this is a this is a stupid statement which if every student has to type again and again it's completely wasteful it does not add any value to either the understanding or the concept of the program anyway as I said earlier the students form a team to do a course project by the way what you call a subject in IIT we call a course so consider this to be a subject project typically the code return often exceeds 2000 lines and this all happens within a semester the projects are assigned to the teams of students somewhere at the end of the first month of the course and in the remaining two months the students work on this project which is a fairly larger problem and they come up with a solution the approach that we choose in this workshop is that we will keep in mind the syllabus usually followed in most colleges I would like to inform all the participating teachers that as a preparation for this workshop almost two months ago we conducted a coordinators workshop where our colleagues from the respective centers where you are attending this workshop came to IIT and participated we had done similar thing in the pilot earlier what we did is we collected typical syllabus and the examination pattern and some of the examination papers from various colleges and university as a matter of fact later in the workshop I will expect each one of you or the teams or the people who are coming from the same college to contribute to this general knowledge namely what is the syllabus that is followed what is the teaching style what is the evaluation pattern and what are the sample question papers so what we have done is we have tried to generally cover topics in that order unfortunately there is not a single order which is followed everywhere in the country but fortunately we found a lot of similarities in fact if you will see this the schedule of this workshop you will find roughly these topics appearing in that order in which they appear in your syllabus however the IIT style is chosen to always take a problem work out its solution and then discuss the complete program so each problem and the corresponding program we have tried to say that a new programming concept is implicitly introduced in the process for those of you want to adopt this style you may still use this slide as style and additionally in a lecture you may want to emphatically state certain details of syntax and semantics which are indicated as requirement in your syllabus or on which questions are specific incidentally I have seen many question papers in which we see question one part a explain something part to write short notes on part 3 describe something our style of teaching computer programming and evaluating the knowledge of computer programming is completely different we never ever have such explanatory answers sought from the students in our papers our papers have problems which are all programming problems and students are simply required to write the programs either full programs or partial programs we genuinely believe that that is how a programming knowledge should be evaluated however if the syllabi and the examination pattern of different universities required such explanatory answers to be given in the final exam then obviously such things must be discussed and described by the teachers while they teach I would submit that it is possible to combine the present approach that most of you take with the approach that some of us have practiced not only in IIT Bombay but in many institutions across the country as I said wherever the academic autonomy is available I would suggest that please try to find out the best of breed combination of these approaches to decide the way you would like to teach in IIT as I said the labs will require modifying and executing given programs and there will be group projects with this now I proceed to describe the model of computing as exhibited by a computer program is a different way of looking at it so I would submit you please look at this you may want to adopt this or a similar strategy later first of all I have tried some caricatures I call this a buddhuram computer or mr. Dumbo in my initial courses I used to use this kind of line caricature but ever since we embarked on this national mission I got some animators to work with me and a colleague of mine Mrs. Sahasrabut they actually had worked out a model which looks like this so it has a monitor like thing in place of a head there is no keyboard shown here but our students will implicitly assume so this is the buddhuram computer mr. Dumbo is characterized by our statement that first of all Dumbo cannot do anything on his own but can execute given instructions correctly Dumbo can do arithmetic Dumbo can do logical comparisons Dumbo can manipulate strings essentially Dumbo can manipulate values and produce resultant values since he can compute we call him a computer this is by far a simplest definition of a computer as mr. Dumbo by the way the word Dumbo I have seen does interest and impress the students because they can relate to Dumbo as somebody less than themselves in intellectual capability it is very important for us to convey to our students that however comprehensive and strong the machine might look as human being you are always superior to that machine in both your thinking capability and therefore it is your endeavor to make that machine work to your satisfaction so our Dumbo computer is a dumb fellow Dumbo has very poor memory so we state that Dumbo cannot remember anything in his head now if the Dumbo has to compute something Dumbo has to remember at least the values which we have asked him to compute with so how does Dumbo solve this problem we introduce a memory model for Dumbo we say that why Dumbo has poor memory Dumbo uses a cupboard with drawers as memory so this is the Dumbo's memory here these are drawers I have artificially labeled these drawers as a b c d e f how does Dumbo use this memory we say that each drawer contains some value for example a drawer may contain a number such as 437 a drawer may contain a string such as run a day we will say each drawer is a memory location it can contain a value so location b contains 437 location f contains the string run a day I hope you will appreciate that when we are going to teach c programming in further details we will have to tell students at some stage that the entire word run a day will not be stored in a single memory location however conceptually in IIT Bombay at least we teach c c plus plus and therefore we have a type called string in c we do not have a type called string but you will agree the programmers are able to write such strings in their program there are occasions when such strings are written and such strings are handled by c and there is no harm to convey to students that the various data types look at what we are doing we are achieving two or three things we are able to introduce the notion of a memory location we are able to introduce the notion that a location will contain one value and we are able to introduce a notion that a value could be numerical or string is good enough to begin with we further emphasize that each location can contain only one value and not multiple values now how does a value get into a location we describe the following scenario either Dumbo stores a given value there or Dumbo calculates and stores that value or some values may already exist in a location how can such values exist in a location well these values are not supplied by us so we say such values are unknown or undefined how does Dumbo store a given value obviously there has to be some mechanism for give for us to give a value to them essentially we emphasize that Dumbo can either take a value from us and store it inside or Dumbo can calculated a value and store it inside and we conclude that there is no third way for a value to get into a memory location we indicate this by another model here so this is exchanging values will Dumbo I have put a caricature of a cart here a wheeled cart or a wheelbarrow which is shown to work on a path essentially I am introducing the notion of a data bus please note that there is a mistaken mapping that will happen in the minds of students at this stage which I think is perfectly right the notion of a data bus in a computer is not that of a bus or a vehicle or a car but it is a path however the students when they see data bus they will think this cart is a data bus this is okay at this juncture we're not going to the details of in hearts of the computer so it is perfectly all right for students to imagine that somehow if I give a value 58 to mr. Dumbo to be stored in one of the memory locations Dumbo will take this value in a car from us to the computer's memory and put it inside now even exchanging values we say Dumbo will not automatically do it you see in case of the exchange of humans between manager and the clerk when manager gave me a paper I automatically took it read it and sort of store that value in my mind now this I will not do directly if I am a computer if I have a double computer I must be told to do this so we give an instruction see in greater greater be why do we use greater greater why do we say see in why not we use any other phrase such as import read gate or even scan f percent d and b I would like to spend a minute to describe this in details because this has very important repercussions on how our students appreciate programming particularly in the early months this is a lacuna which happens whenever we use any programming language and in particular whenever we use C programming line those of you are familiar with other programming languages will see for example in Fortran I could say read star in C plus plus I will say C in in C I will have to say scan f double code percent d double code close comma and b all enclosed in parenthesis you will all agree that for a student who does not understand the notion of a function who does not understand the notion of a pointer who does not understand the notion of spring with percent etc to semantically understand the meaning of this at an early stage is impossible the way we solve the problem in IIT Bombay is that for most of the initial part of the course we use C in and C out as input and output instructions I would humbly submit particularly if you are using the GCC compiler which we recommend strongly and which is what you will be using during the workshop there is hardly any distinction between C and C plus plus as long as I stick to using only the input output statements of C plus please note that in C plus plus strictly speaking the greater greater symbol represents an operator in the context of object-oriented program but it is easy for us to tell the students that this is an input instruction so whenever I say C in Mr. Dumbo will take some value from us and whenever I say C out Mr. Dumbo will give a value to us for those of you who would like to still introduce scan f and print f very early what we will do is in our programs towards the end of this workshop if not at least at the beginning we will redo all our slides and we will introduce as comments in our program the scan f and printer statement corresponding to every C in and C out so this is for the for the benefit of those who would like to take these programs and use them they could simply comment our C in C out uncomment the scan f and printer and compile these programs using a C compiler rather than a gcc anyway coming back to all this Dumbo will collect a value given by us will take it to his memory covered and store it in location B if we have said C in greater greater B in the process any earlier value will be overwritten this might appear to be a very simple concept but let me state that it is very important for us to emphasize to the students that when a value goes from outside the environment into the computer's memory location the old value is overwritten only the new value stays there in exactly the same way for exchanging values we will say dumbo can output values from locations to us and the instruction to do so could be C out less less g or C out less less a less less g less less square f less less root essentially we can list a series of names of the drawers or the tags of the memory locations from which we wish to get the values out to us and we explain this by saying dumbo will copy values from memory locations and present these to us what is the most important thing to state at this juncture values in the location themselves are not changed so we distinctly define the difference between an input and output operation an input operation changes the value of a memory location whatever was the old content is overwritten an output operation does not at all affect the value stored in the memory location we now introduce an additional feature by saying that incidentally in the output command or instruction to mr. Dumbo we can also include an explanatory string for example if the location C represents some kind of account then just saying C out less less c will just give us a value we would know what that value is whereas if we ask add an explanatory string the meaning will be clearer to us we would also like to emphasize to our students that when they go to a computing environment and when they are executing a program on each line after they begin the execution of the program these are the things that they will see input to be given by us and output given by dumbo and therefore the lines of text or lines of the variable names etc that we write here have a direct implication on the way input and output is done so let's try out dumbo's input output we say here C out give values for b C in greater greater b we'll explain to our students that when we say C out give value for b mr. Dumbo will actually show us the string give value for b so dumbo is asking us give me some value and value for a name called b then it will execute the instruction input b and will take probably the value let's say 437 that we give and restore it in location b if we wish to give a character string well it could read it and put it in location f those of you do not wish to introduce the notion of character string as early as this may simply discard this particular slide and the corresponding strings let us now try to build a model of computing that mr. Dumbo follows consider this if two numbers are stored in drawers a and b let us say 35 and 12 dumbo can add these and store the result in another drawer let us say we call it some this actually is very straightforward and most students understand it there is a value in drawer a there is a value in drawer b these two values are to be added and the resulting value is to put in the drawer or location called some please note that ideally I should have shown the value inside a also this is the drawing which I myself made and I found out that if I open the drawer a the drawer b got hidden so I could not show both perhaps it is bad drawing on my part but in some animation that I will show I will try to correct that situation to explain that a contains a value 35 and b contains the value 12 and the sum is unknown but it has to be computed I have tried to correct it by showing this to explain how dumbo is computing first of all the instruction that we give mr. Dumbo the instruction in our case will be sum is equal to a plus b while we do spend some time in describing the distinction between an equation and assignment at a later stage my suggestion is at this juncture if we just say some is equal to a plus b most of our students will understand what we are trying to tell them they will understand that we want dumbo to evaluate a plus b and somehow put the value in the location for some because that is what we have stated early while showing mr. Dumbo thinking very hard as to how to add this I have done something else I have put here 35 in brackets merely to indicate that the drawer a inside contains the value 35 whereas the drawer b is shown to contain the value 12 the drawer sum continues to contain a question mark it is useful to indicate to our students once again based on our earlier description of the model that question mark does not mean an empty drawer question mark means some value which existed in that drawer because of some other earlier program that could have been executed so as far as we are concerned that value is a question mark is an unknown or undefined value how will dumbo carry out this calculation well in my model I say that dumbo will use sheets or registers first dumbo will access the location a copy the value 35 into a register next dumbo will access the location b and copy the value 12 into another register then on this register on a working table or work bench dumbo will compute the sum total to get 47 and finally dumbo will store the result value back in location for some after dumbo completes the execution of this instruction the location sum instead of a question mark or an undefined value will now contain the value 47 I have tried to show this by this dumbo computing caricature which says dumbo uses a set of local registers which are called working sheets on a table so what I have shown is value 35 comes from a I am sorry I should introduce that 35 as a hidden thing or some colleague teacher would like to redraw this drawing by pulling out a draw array and shown 35 there then this 35 and 12 are shown on this table the value 47 is shown to come out hopefully in a third register and the dumbo is going to put this value 47 back into the sum consequently we show that a and b continue to hold the existing values the location sum will now contain 47 we now say that this dumbo model represents our computer to emphasize the same concepts and to strengthen the notion that there is a memory location which is akin to a drawer that the dumbo uses a card to do input output operations and dumbo does computing using some kind of a register or a workbench what we have attempted to do is to create two educational animations these were created by expert animators they are probably not the best but I believe is a good attempt I would like to show you those two animations now so here is our dumbo this is a caricature made by our animators this is the cupboard with various drawers artificially named as ABC the animator is showing that every drawer can be opened and can be accessed here is dumbo being shown to get a input value of five and putting it in one of the memory locations so he's opening the drawer and putting that value inside so the value goes into a memory location here this is and the dumbo of course take takes the card back let me let me put it this way it's a very small animation but I think it is very instructive let's quickly watch it is a few seconds animation these are our dumbo so a human-like model this is the memory drawers with various labels there and an input output operation is being shown to get a value from outside and put it in one of the memory locations so this is a cult and this value is being collected by Mr. Dumbo and this value is being put inside the memory drawer there are umpteen ways in which this model can be made better our animators and some of my colleagues are already working on it but I thought there is another animation which I would like to show you this describes the way Mr. Dumbo does computing so here is the second animation where there is a input of 35 in variable a input of 12 in the location B and then dumbo has to calculate some of A and B the location C is shown to have a question mark so what dumbo does is notice he makes a copy of 35 and puts it on the workbench on a register then since he has to add from location B he makes a copy of the contents of location B and copies that value in another register so as to registers in which he has 12 and 35 now he's shown thinking he adds 12 and 35 to get value 47 now dumbo picks up that value 47 and puts it inside the register at the end dumbo shows that a continues to have 35 B continues to have 12 but C now contains 42 you will agree that this simple animation can go a long way in emphasizing to our students first of all the notion of a location second the notion of a tag or a name for a location third the fact that location can contain only one value fourth the fact that whenever either an input operation is done or a compute an assignment operation is done whatever is the old value in the location it gets destroyed and replaced by another value I have found that this kind of introduction is often adequate for students to form a simple model in their minds so these were the two animations incidentally my colleague professor Sridhar Iyer started a very large project few years ago on preparing an open source repository of educational animations my project is taking you from that and we have now animators working to create educational animations not only for this course but for several other courses later on in this course I will show you an animation developed on showing the working of disk drives so you will see how disk drives are to be used or explain to the students on how reading and writing of blocks on the disk drives happen I will show that animation later but I will request all the colleague teachers to think of different ways or different ideas which could be shown better through an animation of this sort and we will be very glad to receive those suggestions and work on those animations at a later day now we come finally to describe as to how we give our instructions to Mr. Dumbo in this context we compare Dumbo with other machines and we tell our students that as far as other machines are concerned whether are leth machines or a fan or a motor or a whatever machine that we can think of they will take one instruction at a time and execute it so if I press a button a microwave oven may start work if I press another button it will set may be power to something else basically I give one instruction it is followed by the machine instantaneously Dumbo is special because we can write all instructions in advance and give the entire lot to him and such a set of instructions written in advance by us to be given for execution to Mr. Dumbo is called a program this is essentially the concept of a computer program and I have found this to be an extremely simple and elegant way to explain to students what a program is additionally we said Dumbo is special not only he can read my program instruction by instruction and execute them he is able to take my entire program even if it has 100 instructions 500 instructions and store all those instructions in my program inside his own memory and that is why we call Dumbo a stored program concept or Dumbo has the capability of storing programs one question students may ask if Dumbo has cupboards which can store values where does Dumbo store instructions our programs well the correct answer is in the same memory however we do not want Dumbo to get confused between an instruction and the data values that those instructions are going to manipulate so we say that Dumbo you use a some space of my cupboard to storing data values and some other space in the same cupboard to store instructions our program I have found it extremely easy later on to relate the notion of instruction space and data space when we explain it later to our student there is no harm in introducing these two terms here conceptually we can tell them imagine the cupboard is broken into two parts divided into two parts one part let us say contains only data values which we want to be manipulated and the other part will contain instructions of our program that in any case is often the reality then we show a complete program to our students so here is a program one of course what I am trying to attempt now and we'll try to do that before the workshop ends that we will be providing all the sample program as separate files so I name those files now this will be called prog1.cpp our endeavor will be to create two versions of each file one is prog1.cpp and the other is prog1.c what is the distinction as I told you earlier we prefer to use see in and see out in all our programming courses we are students to compile this program to C++ however in most of the lectures in major part of our course we do emphasize constructs of C program as I said we consider it completely trivial and unnecessary to talk about whether we are using C or C++ as long as people learn the programming concepts if you are comfortable with that in your teaching you can adopt these slides without any change and use prog1.cpp, prog2.cpp etc if you are uncomfortable with that you can use prog1.cpp, prog2.cpp etc which also will provide I'll try to finish all that work at the end of this workshop if not within the two weeks that you submit your assignments my staff here will submit this assignment and we will definitely have all of these available to us so here for example I have said include IO stream in a comment I have said include stdio.h for C program for using scanf and printer using namespace STD that is a requirement whenever I use IO stream please note that whether I use C programming language or whether I use C++ programming line for my students who are barely becoming familiar with the model of computing as used by Dumbo all of this is Greek and Latin what is slash slash what is hash include IO stream what is include this what is int main opening bracket closing bracket all of this is Greek and Latin and I can assure you that most of the students cannot understand the underlying concern in my humble opinion and in the opinion of many of my colleague teachers were taught this course they we emphatically ignore these statements at the beginning we just tell our students that look the computing environment including the compiler and things like that are such that unless we put these lines of text our environment will not understand what we are doing however as far as we are concerned our program is from here up to here even the return zero they will not understand why why do we use the word return and why zero being return is not a concept which can be very clearly stated at least in the first lecture maybe in the second and third lecture it is better to keep mum about these except to say that look these statements have to be there eventually we will explain what these statements mean and students are comfortable with it because at this juncture what we are trying to suggest we are trying to augment or we are trying to consolidate the computing model that they have formed in their mind looking at the dump so here we are saying we have declared a and b what is in a and into b at this stage without going to the details of integer floating point string whatever whatever we will simply say this is the way in which the C programming language declares the labels for those rovers or memory location so once we say this dumbo will reserve a location for a and a drawer for me and then rest of the instructions you will see are exactly what we had described the only differences in the example we had C equal to a plus b here we are saying some is equal to a plus and this is a working program so this program people can execute they can give two numbers they can see result working out correctly etc. here is another program to convert temperature from degree centigrade to degree sphere and I inverted the problem which I described while discussing the context of the human interaction we call this program to again in this program there is include IO stream using namespace std etc. it is useful to tell people that such comments are written because the programs are not only read by dumbo but they are also read by human being so you write a program I will try to read it if for nothing else either to understand that program or to collect that program if there are missed and if I want to read it I would better have some more explanation then the cryptic language in which you instruct Mr. Dumbo hence these are called commands which need to be written we can tell the students that if I do not put slash slash here our dumbo will think it is an instruction and you will get completely confused because dumbo has a very limited vocabulary it can understand only simple instruction so far we have seen only three instructions that dumbo can understand dumbo can understand input dumbo can understand output and dumbo can understand computation notice that this is the first time we are introducing some complex computation here please note that many of our students will be familiar with x as the multiplication symbol and with a with a dash with two dots above and below as the division symbol they may not all be familiar with slash and star it is useful to explain that this is nothing but c multiplied by 9 divided by 5 plus 30 and they can relate very easily some of them of course may be familiar with the programming language but even a person who is not familiar can understand that okay I am using star to represent multiplication and I am using slash to represent division and a student can easily relate that this formula will calculate the value of the temperature in Fahrenheit and when I say f equal to this I know the dumbo's model dumbo is going to do these computations and put the resulting value in the location for f therefore when I later on say c out the value of f will come back to me what the student may get confused about is what is this backslash n here now this backslash n actually represents new line in a proper c plus plus program it is customary to write nl or end of line which is a symbol defined and understood by c plus here I am deliberately using backslash n because even if you use a c program in a print of instruction you will usually have a backslash n at the end to go to the next line I typically follow the description of this program by a quiz in fact there are two quiz questions the first quiz that I ask is approximately how many different programming languages have been defined so far so far by the computer scientists so you have to guess here now of course you are all teachers so you know much more about computer programming than fresh students do and it is not uncommon for me to find out that a majority of the students describe the number of programming languages as between 6 to 20 so B is their choice of few of them who are adventurous think of having more than 20 programming languages because they themselves have heard of four or five so they think the world may be larger than what they think and they give an option c very rarely people give an option a which is of course incorrect but very rarely people give an option d more than 100 I would submit that some of you may also not be completely aware of the large number of programming languages that have been defined from the time high-level programming languages are defined in fact in mid 80s itself there were more than 600 programming languages that have been defined by various researchers most of the languages died in natural death it was commented at one time that the ambition of every computer scientist researcher is to define a new programming language and the only users where that scientist himself or herself and some of his or her students however the ability to define new programming language is very straightforward in the context of computer science research those of you know if I define a grammar for a programming language and if I define a semantics then whatever number jumbo I use I essentially have a new programming language with me so the correct answer to this is more than 100 why do I give this quiz not merely to emphasize that there are many more programming language but primarily to emphasize that therefore it is stupid for anyone of us to say that I know this programming language or I know that programming language it doesn't make sense if there are 600 programming languages in my whole life I can never learn 600 but if I know programming concept then whichever language I am required to use for solving a particular problem I will be able to learn that programming language and use it to solve my problem that is the confidence which we wish to impart to our students incidentally that is the confidence with which we teachers also must endeavor to work in our own professional life so we ourselves should never say we are experts in C programming or C plus first programming or something we should just say we understand programming concept for example I remember when the Unix environment first came and scripting languages such as AUK were first introduced AUK is by the way a very simple scripting language but none of us were worried about using AUK in fact in one of the joint intense exam result tabulation when something urgently was required by the committee of the chairman of JEE I am talking about 20 years ago we could very easily write some AUK scripts on the fly analyze the entire nationwide data and give them results in minutes so such is the power of programming and such is the plethora of programming languages that exist we should never be worried about it and there is no harm in telling our students that there exists a large number of programming languages but don't worry what we are going to learn in this course is the basic programming concepts later on we will tell our students that what we have studied here are procedural programming concepts there are two important programming paradigms called object-oriented paradigm and functional programming paradigm and eventually those of you learn computer science or learn these specific things can do some additional electric and learn those paradigm but once you learn some basic programming paradigm you should be able to learn any new programming language embodying those concepts on your own and carry on with it solving problems the second quiz is more interesting the second quiz says the symbol backslash n in double apostrophe in the instruction c out less less f less less backslash n will produce the following additional output here are four choices given a nothing visible and end of line is inserted b backslash n c l d I cannot guess what is the objective of this quiz obviously the correct answer is nothing visible and end of line is inserted who will be able to tell this answer correctly either somebody who has already known this programming language or somebody who has sat in the lab and put backslash n multiple times in a program while trying things executed that program and found that nothing visible happens however every time he puts a backslash n somehow the computer shows the next output on the next slide he or she will be able to guess this provided one has executed many such that is what we should emphasize to our students that the lab environment is not merely to do the lab exercises which we are designed we do design lab exercises such that the minimal things are well done by the student but a laboratory must be truly what it name suggests namely it's a place for experimentation so students should be encouraged to do variety of experiments change this line change that line we should tell them that please remember that house ever smart mr. Dumbo is Dumbo cannot do one thing Dumbo cannot shout back at us so we make mistakes in our program the computer program will terminate possibly with an error doesn't matter we can rewrite that program 50 times given the speedy compilation and execution that we can do it is possible to do variety of experimentation so those who do those experimentation or those who are already familiar will give the answer many of them will say be many of them will say see I have deliberately included a choice d here which says I cannot guess the fact is for 90 percent of our students who have never seen computer computer programming in their lives they will not be able to guess but they will hesitate in saying this they come from a competitive environment remember the rat race for marks they they must know everything and they think it is the meaning if they admit that they know don't know anything this is where we probably convey the most important message to our students when I conduct this quiz when I see not many these here I politely tell them please understand that is all right not to know things I tell them that after 40 years of teaching experience there are so many things which I still do not know and only by admitting very clearly that I do not know this I have been enthused to learn it either from the books or from colleagues or from other people and I specifically tell them that many of the tricks in programming I have learned from my students and from my younger colleagues or programmers who have done far more programming than I have this is something that I think we should truly imbibe in ourselves and should convey to our students as well namely in computer programming just as any other professional branch learning is not limited to learning only from seniors or only from teachers learning happens everywhere indeed the notion of a collaborative environment is that I will learn from all the members of the collaborating team let's take these thousand teachers there will be some of you are fresh teachers are probably joined teaching last year there will be some more as old as me or even more ancient but the fact of is that each one has something to offer and something to learn from others and the same thing applies to these two I will conclude this by saying that in this quiz I would expect a large number of people to honestly admit that they cannot guess and if they say so we should be delighted we say you are very right you cannot guess because these all number jumbo all Greek and Latin what is backslash and in human context please remember interacting with humans in any kind of information exchange no human being would have ever said backslash and to any other human being so these mumbo jumbo only meant for computers which is perfectly fine here is an home assignment this is distinct from the lab assignment this is something I would like to share with you we also have in our courses laboratories but additionally we have home assignment so when those students do home assignments they do the labs in the afternoon then they go and play their football or cricket or whatever then they go have dinner probably they see a movie or taxation and then around 10 o'clock or 11 o'clock in the night they start working on home assignment they work for two or three hours of course sleep for five six seven hours and come back in the class I would submit that all of us who are all teachers should actually endeavor if not in our regular life which is preferable but at least during the workshop a habit of having some discussions after dinner with our colleagues and it is during those discussions I would suggest that we should attempt to do not only such home assignment which I will rarely give but something different something that comes to your mind as to what we can do additionally which would enhance the effectiveness of teaching learning of computer programming to a large number of students who we teach every day or every year or every semester in this particular case I'm merely suggesting that you might want to consider rewriting these programs as proper C program and the question that I want you to deliberate upon amongst the discussion is how will you explain the difficult syntax and its semantics of the input output statements in C namely the scan f and printer it's not easy to explain I have not found it easy at all if you can find some solution or you can find a nice way of explaining it then I will be very glad to do that failing which however I would submit that there is no harm in our continuing to use C in and C out for basic input output operation subsequently at a later stage will introduce scan f and printer and as I said for all those teaching teacher colleagues would like to use scan f and printer right from day one will endeavor to convert all our program files into proper C program files which will contain these statements that is roughly the end of my talk now thank you very much over and out from Professor Fatak from IIT Bombay