 సి ఎవి వి మావివిన ఆవాంది భతికి కరింది కింది సివిటి మానంది కారిస౿ం. to solve real world problems. So, solving problems is our fundamental objective. Computer programming as most of you would know has to be done using some artificial language called a programming language. How many languages do you think exist? Those of you who have heard of computer programming. 5, 10. How many for 50 languages? 1 or 2? More than 50. How many? 100? More than that. How many? Give a number. In 1989, 1990 when I last taught this course, before I taught it last year of course, there were more than 600 programming languages. Consequently, knowing a programming language is a completely useless activity. Knowing how to use a programming language to write good programs is the important activity. So, what we will concentrate on is learning principles. We will of course have to use some language. We shall be using C++ but mostly that subset of C++ which coincides with C for the initial period of the course and towards the end we might introduce some specific features of C++. You are division which division? D3. So, that is what civil and electrical. This is the overview of my talk. Since we are going to learn programming through a programming language and since programming languages have been designed by humans almost on the lines of human languages, it is useful to identify certain basic features of human languages. In particular, how human beings use that language for data and information management. The second title says what is there in a name. All of us have names. So, we will ponder about in defining what I call the context of our understanding. Last but not the least, why is grammar important? Needless to add, all of these issues you have tackled substantially during your education. So, there will be nothing new that I will be talking about but the points that I may, I will try to relate to programming languages. We will very briefly see the world of computers. We are not going to look at computer internals in details. The reasoning is as follows. When as young children you learn, let us say, cycling, when you learn to ride bicycle riding. At that stage, I do not think you ever worry about how does the chain mechanism work. You do not worry about how the wheels rotate. You do not worry about the steel frame that constitutes the bicycle. You are not interested in those things. You are interested in balancing yourself and riding the bike. In exactly the same fashion, we are interested in learning to use the computer. We will, of course, during the course of this semester, learn much more about computers. Since computer is an involved machine, much more difficult to comprehend than bicycle. A good example would be a modern gadget like a complex TV or a complex washing machine where you get a user manual. He says, press this button to do this, press this button to set this, use menu, whatever, whatever. So, to that extent, we have to become familiar with the computer system so that we can use it for the objective that we have, namely our ability to write programs and run them. But we will just look at the basic capabilities. The visible components like hardware is all obvious to everyone. I will comment something on the software. The last two points, our lab environment and our quiz are omitted from today's session. We will have it on the next class when I describe the course argument. So, I begin with some recapitulation of human history and evolution of languages. We all use languages so intrinsically in our lives that we cannot generally imagine what life would be without a language. The basic sensors which we use for interaction with the rest of the world are essentially touch, smell, audio capabilities, not only hearing, but also vocal capabilities, uttering sounds and of course the Vijay. These are senses that have been endowed by God in all species. That human species evolved something better than that. Generally, all external information is handled visually and verbally by human beings. It is not that we don't have a sense of smell. So, for example, if there is a blooming rose somewhere in the vicinity, we can smell the fragrance. But we certainly do not have smelling capabilities to the same extent that some other animal species have. For example, dogs can actually identify things on the smell. On the other hand, our visual and verbal capabilities have been extensively developed because we are the only species who have developed languages. It is true that some other species do communicate vocally, but they communicate through some sounds like specific barking in a special tone or every species which has vocal cords, mammals particularly, they would make some sounds. But that is extremely rudimentary. There is no organized effort and certainly there is no development of a language as we know it. The initial use of course was limited by the verbal facilities because people could speak. Languages actually have spoken languages. Human species have evolved over the last 7 million years or 5 million. Give or take two, doesn't matter. But the languages as we understand started evolving only about 15,000 years ago. There are no languages there. When languages evolved, people actually organized themselves in societies. People did a whole lot of things. What a language does is that it permits the accumulated knowledge to be passed on to the young of the species over a period of time which is otherwise not possible. Young of any species in the world learn the tricks of survival first from their parents and then from their peers. So you take a cat, you take a lion, you take anybody. But that is limited knowledge. The only knowledge they carry is the one which is genetically passed. And as you know genetic evolution takes long time. Today for example it is not necessary that those of you are electrical engineers when you have children they will automatically be electrical engineers. That is not yet possible. So what do we humans do? We accumulate that knowledge and use the languages to both accumulate it and disseminate. But the most important development occurred when languages acquired a script. Script did not exist earlier. So writing in any language did not exist. This development started happening around 3000 years BC. So the written language in the entire human history of millions of years is just 5000 years old. But once the script developed amazing things happened. Once people realized that pattern drawing and recognition of pattern. Note that any symbol that you write is actually a graphic pattern. We do not call it graphics or pictures or anything. We just call them letters, alphabets. All of you can read them. I can write them, you can write them, I can read them. So there is a convention which is understood by all. And now go back and imagine how wrong you spent to assimilate this convention in any language that you study. First few years of schooling entirely devoted to understand reading, writing and then subsequent years in expressing yourself in the written form. Please note that all of us have innate capability to do an extremely difficult thing which is intellectually challenging namely learning a foreign language. How many of you learnt a foreign language? One, two. I am not talking of the foreign language that you learnt recently. You must have attended a course or something. Okay. Okay, so one year, two year course, etc., etc. I am talking about a foreign language that each one of us has learnt when we were between three years to six years of age. Later on that language was called the mother tongue. Please remember the innate ability of the human mind to learn a foreign language at that age without any school, without any college, without absolutely any exam, no certificates. Nobody telling you you got a 90% mark, so you are great man. You got only 40% you are useless. So even if I got 40% mark later, I still learnt my mother tongue as well as you did. I could express myself completely and I could understand anybody saying anything. That is the ability. But once this ability is developed, then the language is used to preserve past knowledge, add to it and to disseminate to young human. So this is something about the humanity. This is what makes us patient. But this also puts an onus on us. Language not only preserves knowledge and helps us to disseminate it, language also shapes our own thinking. Generation of new ideas will come in language. If we did not know a language, it is extremely difficult to precisely think of an idea and articulate it and to work on it. Language is extremely important that sense. This is the reason why only humanity has an institution called a teacher and only humanity has an organized system of education. And you can see number of years that we spend learning things. In fact, as you grow older, you realize that learning never stops. Now we come back to relating the languages to our own concepts. We note a few simple things well known. Every language has nouns signifying things like table, chair, pencil, paper, instruction manual, book, form, file, cabinet. You understand cabinet? A cupboard in which you store files. Or a cupboard where you can store clothes or books or whatever. Office, institution. These are all names. Verb signifying actions. Eat, calculate, count, add, subtract, divide, multiply. You all understand the meaning of these words. How do you understand them? You use them in some context and you all learn their meaning. The context is very important. So when you say add, automatically what comes into your mind? Somebody is talking about adding numbers. So numbers are implicitly understood. Can you imagine a sentence which says add Everest to Narmada? Then makes sense. You don't add a mountain and a river. But you add numbers. So how do you interpret the meaning of any word? Not only because you have mugged it or you have understood it by reading from a dictionary, but because you have used it and you have understood the convention of the usage of a word. So there is a context in which you understand all words. You remove the context and then you will have to explain the meaning of the word by full sentences. Like add means taking numbers and adding them together to calculate the sum, some such thing. Read, write, edit. What do you understand by edit? Somebody has written something. Somebody is correcting it. So editing it. Changing the contents of a text. Adding words, inserting letters, deleting something, modifying something. Put store. Store means keep it something somewhere. Retry, get. Get me my shirt from that cupboard. Put this file in the almeera. All these things are understood by you. Remember I said about what is there in the names. Proper nouns are names which we choose to give to specific things. Most of the proper nouns are automatically understood by us using the context which those proper nouns indicate. When I say Sachin, what occurs to most of us? Sachin Tendurkar. When we say Everest, what occurs to most of us? The mountain peak. Same thing with Narmada. The last name does not occur anything to us unless we know somebody by that name. But we can suspect that this last name is actually name of a person. It is indeed. He is my research associate and closely involved with the course CS10. Similarly when I say academic, now that you are in IIT, you would probably guess that it means academic office. When I say chemical, in the context of discussing various departments of the institute, you would know that it is a chemical engineering department that I am talking about. The context is important to understand meanings of sentences because verbs and nouns together form sentences. So Nagesh eats dosa. Now having understood that Nagesh is probably name of a person, this sentence makes perfect sense. When we use the word dosa, which is another proper noun, most of us in India would recognize that dosa is a good eatable commodity. But try to say the same thing in Chinese, where you translate everything except dosa. And you have a Chinese proper name, you have a Chinese verb which says eats. And when you say dosa, Chinese probably will not understand because they don't have the context. Ishan edits the report. Apparently Ishan is another proper noun of a person and edits the report is understood as modifying a report. Sum of 5 and 7 is 12. This is a statement but it is a valid sentence. We all understand it from the context of numerical manipulation. Last one is an order. Because get me the file named cs101 mid-sem marks. Again because probably is the name of one of my associates and I am asking him to get something. I am asking him to get a file. Now even if you have not worked in any office, you probably all understand the meaning of an office file where papers are kept. And what papers would be kept in a file? That is indicated by the name. Look at the file name cs101 mid-sem marks. Now you are all students of cs101, so you understand that the file contains papers related to cs101 course. The last word mark says, yeah, it has something to do with marks. And you understand semester, you perhaps can imagine that mid-sem might mean some mid-sem or mid-sem. In a flash, the meaning of the entire contents of the file, what they signify is understood by. So this file probably contains the mid-sem marks scored by the students of cs101. And that would be the right understand. Other words such as propositions, articles, etc. are related to refine and convey the exact meaning. But the context is most important. For example, when I say Sachin is a great cricketer, again the context tells us that it is Sachin Tendulkar we are talking about. Mohammed Rafi was great. Suppose we stop this sentence. But most of us who have at least heard Mohammed Rafi will immediately relate it to saying Mohammed Rafi was a great singer because we associate with this sentence the context of music. Consider on the other hand a sentence like this. Sachin writes very good programs in C++. Now I don't know whether Sachin Tendulkar also writes programs. Could be. But it's very difficult to imagine that he would have time from cricket to spend on program. So again the context tells you that this Sachin cannot be Sachin Tendulkar because the context is of C program. And then you will invoke a local context. You will imagine that probably a student is called Sachin who is a good C++ person. Notice then that whenever we utter sentences there could be multiple contexts. There is a global context such as Everest, Narmada, Sachin Tendulkar, Mohammed Rafi. There is also a local context, names of people in the hostels. And whenever there are two contexts generally the local context prevails. Much later in the course when we will discuss the scope of variables in our programming languages you will see this theme occurring again. So the local context in which a name is used is more important. The context also helps us by the way to figure out immediately that there is something possibly wrong with the sentence. Let me just write a sentence here for you. Okay what do you make of this? Well, we immediately conclude that this cannot be the global context of the mighty peak of the mountain Himalaya because mountain peaks are generally not in the habit of eating those hearts. There are better things to do in life. Now what could this be? This could probably be the name of a person as we concluded in the context of Sachin writing C++ program. But have we ever heard of a person staying in IIT campus whose name is Everest? It's a very uncommon name. So we suspect that somebody has goofed up in writing this sentence. We are not sure. There could be a person and somebody could be talking about that person eating those hearts. Please note that this suspicion will ask us to verify whether this sentence is correct or not. When you deal with programming languages you will also find exactly similar thing being done by the back end systems when you present sentences in your programming language which are suspected not to be right. Either they don't follow the grammar rules that time of course you will be shouted back at saying this is nonsense. But on the other hand they may not mean anything correct because of the wrong use of context. So this is how languages are handled actually by us. Let us go one step further and consider human handling of organized information. When we manage information we not only use words and sentences but typically we write them in the form of handwritten documents. Incidentally you don't have to take these down. For the first week on Friday I will be distributing handouts which will contain all these slides and in subsequent weeks all the slides will be put onto the home page where you can see them. So words, handwritten documents, letters, books, instruction manuals, data sheets, registers, lasers, forms notice that most of the words used here relate to office kind of environment. So within an office I will be using that. So consider how do we manage information let us say related to marks scored by students in an exam. Let's take an example of this course itself. You will all be giving examinations and tests as I will later on tell you next lecture. Suppose there is a mid semester examination and we conduct an exam and I need to record the marks obviously but these marks have to be added to other marks that you score and finally some letter grade etc. has to be given. Let's say the students have been divided into lab batches as you would be because you will be doing labs together. I want to keep record of information like roll number, name, maybe the lab batch that the student belongs to and the marks scored. How should I collect and write this information to store it so that I can retrieve it and use it later? There could be multiple ways of doing it so we will look at one way of organizing the information. I have taken a sample of data of six students who did CS 101 last year in my course and let us look at what sense we can make out of this data represented. Just spend half a minute in reading what you see here. First line, I have two names. Shailendra Seraf, Harsh Somani and there is a comma that says 35. 35 does look like marks. Incidentally the maximum marks for the mid semester I conducted was 45. If you know that context then 35 does appear to be marks. But whether 35 marks are marks scored by Harsh Somani or by Shailendra Seraf is not very absolutely clear because 35 is written next to Harsh Somani we might believe that 35 might be the marks scored by Harsh Somani but then next line foxes us completely. 10901010 comma 0A comma 476 comma something. Out of these two we can identify as possible roll numbers. Are these the roll numbers of Shailendra Seraf and Harsh Somani? We have no clue. Just because they appear on the second line we may suspect that they belong to the two people. But then what is 476? What is one? One could be marks obtained by someone anywhere between 0 to 45. But 476 clearly are not marks. It's not even a roll number. What is such a thing doing here we don't know. Then we have another line which says 209D01020 etc. Since one has occurred somewhere and two has occurred later we possibly suspect that one and two may be serial numbers in some sense. And then knowing that there were large number of students last year I had 850 students. It stands to reason that possibly 476 could be a serial number of some sort because you are being told that sample records of only 6 students are being shown here. 6 out of 850. So could be. Next line is further confusing. 22 comma 0A331010 well that's a roll number. comma comma. What the hell is comma comma? Mayan Bendarkar Vinayagagrani 7029. The last but one line says Vinayagagrani 7029. Because of our natural association of words which stand together we may relate all of them and think that Vinayagagrani belongs to lab batch 70 and has quote 29 marks. Isn't that what most of us will think? Then last line again there are 3 comma now comma comma comma. In general isn't it safer to conclude that absolutely nothing can be concluded about information from this. In short even the conclusions which we have reached saying that Vinayagagrani could have these marks etc. we must start suspecting that looks reasonable but in the presence of absurdity everywhere else we must discard whole of it. Indeed this is not the way even any one of you would write marks or record marks. What would you do? You would probably have this alternate way of writing. So these are the observations. We cannot correlate any data about a student with these or her marks. Clearly we need to organize this information more meaningful. It is a common practice to write this information of one student on a single line of text and have as many lines as there are students. Doesn't it make sense? For a student if I want to write a serial number alright I'll write a serial number, I'll write role number, I'll write name, I'll write lab batch, I'll write marks and that becomes a record of a student and I'll write as many lines as required in more pages, assemble them and put them in a file. That would be a very natural way for all of us to organize information. Using this approach we will get this all. Do you agree that this makes eminent sense? Each row contains data about one student. The first value that you see are serial numbers. Since this is sample data the serial numbers are not from 1 to 850 but some sample serial number. The next one is role number. That is correct. The next one is name. So Mayank Bendarkar 0A is the lab batch and 35 are the mark score. Second line also we can understand it. Third line we have a problem. We see serial number, we see role number but we don't see anything between next two commas. What do we interpret? The name of the student is not known at the time of recording. Only role number was known. Probably the student did not write the name on the answer sheet. So the teaching assistant who recorded it just put a comma followed by a comma saying this is missing value. 0B all right, minus 2. Okay, you might suspect that CS 101 has negative marking because you must have come across negative marking many times in your class. But if this was to be presented to my last year's CS 101 students and now to you when I explain to you that I do not have negative marks in any paper. So that means minus 2 is not real marks. Why minus 2 could have been given? Just imagine. Sorry, how do you know? By the way, cheating. You mentioned cheating? He's given me an opportunity to tell you something very vital. Cheating is the only thing which is not permitted in this course. Everything else is permitted. And the day you cheat and you are caught an F grade will be awarded immediately for the entire course with a recommendation to authorities to take external action. So please be under absolutely no illusion. Cheating you will not get away with minus 2 marks. You will get away definitely from this course and possibly from this institute. Have absolutely no illusions about it. The reason I don't have negative marks is just as I don't believe in attendance I don't believe in marks either. But I am required to give marks because that is how the evaluation is to be conducted and that is how the world unfortunately distinguishes between different people, what grade you got and so on. So I am required to comply with it. I do a proper job of it but no negative marks. Anyway, this stratagem was designed by one of my teaching assistants to designate people who are absent who did not appear for the exam. If I do not appear for the exam in the marks field note that I have to write a numerical value of there because marks are all numerical. Can I write 0? No. Because I could have attended an exam and still scored as 0. So 0 could be valid marks. So if you want to designate something which is not there you have to give some value which is other than possible legal value. Note that this is not a field embedded amongst the record. Then I could have put two simultaneous, two commas one after another and said there is no value here. Note that there is no value for the name either. As it turned out, this particular student with this roll number had quit the institute and that is why there is no traceability of the name or whatever. But they put minus to there. Somebody put minus 3, somebody put minus 4. Additional convention which is being set by a group of people for their own knowledge. There is nothing to do with general convention. Anyway, you can notice that Vinayak Gagrani did not score 29 marks as you might have imagined from the previous slide but scored 43.5. What do we learn out of all of this? We learn that the information must be presented to anybody in an organized form. And we also learn that the organization must be explained in some way. Right now I explained to you that first field is roll number, serial number, second field is roll number, etc. Generally, when you are very meticulous you are expected to write details about how this information is organized. So, this is about formatted data. These lines could be written on multiple pages which are kept in a single office file. Each line will be a record containing values for various fields which together describe information for one student. And the field values are separated by commas in our lines. These could also be separated by blank spaces. These could also be separated by any character, star. But you generally don't separate pieces of information by star or zebra or lambdas or something. So, you separate them generally by spaces. The reason we don't use space is that the name itself could be two or three words. And if it could be multiple words it is generally the practice to put a blank between those words. So, nageshrao karmali. So, there are two blanks already. And if I designate blank to be a symbol which separates different field values there could be a problem. Because some name could have two strings some could have three, some could have only one. So, we use some other symbol. Incidentally, those of you who have used any spreadsheet like Microsoft Excel will know that if you enter data into a spreadsheet and that is normal for entering such large data and then you want to process that data by a computer program you have to extract data from that spreadsheet into a format which is called a formatted data or a text file format. And the most common text file format is called CSV. It's an acronym for comma separated values. So, if there are six columns or eight columns or ten columns spreadsheet when you ask the spreadsheet to export data in a comma separated value format put those ten columns separated by comma. And if any particular cell does not contain any value it will put commas side by side to indicate that field is black. This is the kind of format which could later on be used as input data to a program that we write. And we may name this file as mirseh marks. So, remember the first slide I said what is in the name. Suppose I name this file as choose something, ok. If I give this name to the file can you ever imagine that this contains value marks that you have scored in exams. That is what is there in the name. The names that we choose have to make sense automatically to people as far as possible without having explicitly to state a long explanation of what that name is. And since proper nouns are chosen by us they are not said by the conventions of the language how to take this responsibly. When we write computer programs we will be choosing proper nouns for variety of things to be represented. And we ought to be extremely careful in representation which is automatically visible to people from the name itself. So that is the importance of that. Please note the additional information that I might give about such a formatted data which is stored in a file. We have got as following fields a serial number, roll number, name of the student batch code and marks. But notice the brief explanation given after each identifier which identifies the field. Integer number generally starting with one. Well that is not necessary because serial number is what is understood automatically. Roll number and 8 character code which specifically state that it is not 8 digit code. Why? Because later D in IIT roll number signifying a dwelling. Now I understand that most of you have 9 character code. I first thought that there was a mistake done by the people who put that data onto the website. But yesterday I checked you indeed have 9 character roll numbers. Is that right? Wonderful. So all the programs that I wrote to analyze your marks last year have to be rewritten now and this definition has changed. So now what should be the definition? Roll number is 9. No. What if somebody who has failed 2 years ago in the course and registers this year to pass 8 or 9? You understand the complication now? The roll number could be an 8 character or a 9 character code. Now this description is important. Why is it important? Because all of you logically think it should be 9 character code. I wrote this. I don't know anything about computer program. Let's say I am teaching history or something. Now I go to experts like you programmers. I say I have this data. Can you write me a program which will give me the average marks scored by the class batch wise and the top 10 scores? Now you will write a program which will assume that the roll number is 8 character and the program will flop. As a history teacher I have extraordinary regard for engineers and scientists like you who can actually manage to make computer work. My respect for you will vanish immediately. A lallu is they can't write a single program. The lallu really happened because I did not specify things correctly. Now you as possible prospective programmers must remember this and therefore when you write anything you must be very precise and complete in any specification that you do. This incidentally is termed metadata or data about data. So when you have these attribute names or field names or what we may call variable names etc. you are actually describing what these names stand for. And incidentally you also associate not just the meaning with a name but the possible valid values which can be associated with that meaning that is what is important. The last we consider in natural languages giving instructions to a human consider this we have read the temperature in a room from an instrument which gives readings in degrees Fahrenheit. In India we don't use Fahrenheit scale we use Celsius degrees centigrade. So obviously I don't understand that Fahrenheit value psychologically so I want to instruct someone to convert it in degrees centigrade. How will you give such instruction? To a person who is familiar with the conversion formula and everything let's say I don't remember that formula but I know my friend does and I notice the reading let's say 86 degrees Fahrenheit. So what I will say my instruction to him is 86 degree Fahrenheit that's it. 86 degrees Fahrenheit is immediately understood by my friend as being the temperature measured in degrees Fahrenheit. The reason I am asking the question means that I don't understand it because it is in degrees Fahrenheit so I need the answer in degrees centigrade all of this is understood from the context and of course the friend who can do quick mental calculations the answer will be 30 degrees yeah that's it the instruction ends you have given him the value in the single instruction and you got back the answer now imagine that you are giving this instruction to a dumbo a dumb person dumb as in not physically dumb but dumb in mind does not he is very obedient but does not understand now you will probably have to give elaborate instructions this could be possibly one form of so I tell him he does not understand gadget, reading temperature so I tell him I will give you a numerical value written on a piece of paper let's say he understands arithmetic that's the only thing he understands nothing else so I will give you a value numerical value he understands 100, 5000, 20,000 minus 27, 31.34 all of these he understands so my first instruction is understood by him but yes sometime later this gentleman will give me some value written on a piece of paper the instruction cannot be calculates the instruction should be calculate the converted value in degree centigrade using the formula c equal to f minus 32 multiplied by 5 by 9 please note that mr. dumbo will not understand degree centigrade or something but he will understand that some value is given from which I have to calculate something the only unknown on the right hand side is f so most value that is given to me belongs to f ordinarily an additional another person who still dumbo will be required to be told that I will be giving you a value for the symbol f but let's say this instruction for Adam human is adequate and finally my last instruction write the calculated value of paper and give it to me this is how you will write instructions it appears stupid for us because we never give instructions in this form to people whom we normally meet but imagine a very complex procedure a complex procedure which requires elaborate instruction that is why there are instruction manual and the more complex the gadget the more complex are the instruction so have you seen a car manual how to switch on the wiper how to switch on the engine everything there is a manual there are manuals which are explicit instruction 1, 2, 3, 4, 5 since we are talking in the context of computers which we propose to use at this stage we will merely note that computers are possibly dumber than the dumbest human being and therefore our instructions will have to be explicit with this we go over to world of computers as i said earlier we are not going to discuss details of a computer system as they are known through large number of books and large number of courses even in this course we will later have some better understanding of the computer system right now we are limiting ourselves to understanding some fundamental concepts and understanding how the interface between us and the computers work thats it then we will bother about things later so this is again a general observation generally a way that computers can process data as commanded by us and can produce results such commands are written in the form of a computer program the program is written in a programming language and we wish to learn how to program a computer so as to solve any real life problem and this real life problem may involve processing of all kinds of information it could involve processing of numerical data so some computations to be done analyzing information in text form of the kind that we just saw in terms of marks records it could be controlling working of gadgets i don't know whether you are aware that almost all modern gadgets contain computers inside i told you about a washing machine 30 years ago a washing machine had the fabulous property that if you connected it to the electric power supply and switched it on a rotor will start rotating and churning water period if you stop it it will stop rotating so what you did you put clothes there you put water you put soap and it only churned modern washing machines as many of you would know can do variety of things which can be programmed by you from the buttons that are available so you can say first soak the clothes in hot water then add soap to that hot water and further soak it for 10 minutes then rotate it at this speed clockwise then for 5 minutes let it relax then rotate it counter clockwise for 15 minutes then throw clean water in it and let the water be risen again rotate it etc etc all this complicated thing you will have readymade program which you can select by buttons how does it work actually how it works is there is a computer inside that washing machine that computer does not do matrix inversion does not solve general problems it solves a specific problem of reading the settings from the machine panel understanding those settings and actuators and valves etc operated by that computer in accordance with the logic that is written in the program but there is a program we will be using a gadget in this course to collect your quiz answers I will show that on Friday I will describe that embedded system but people like you will have to write programs which will also go on to such gadgets you know the largest number of computer processors are used where not in PCs and desktops and laptops they are used in modern gadgets every modern car that you see on the road anywhere between 4 to 25 computers and those computers won't work like any other computer they have to be programmed so these are the categories for which we might require to write program I will reiterate once again our ambition in this course is not merely to learn programming for the sake of learning program our ambition is to develop the ability to solve problems for the sake of programming we will learn so here are some basic facts computer store information digitally in magnetic desks modern magnetic desks we don't know we understand desks from the English word if you have not seen a desks doesn't matter so disk is some gadget and the disk gadget permits us to store information that's what we understand digital storage means it is not stored in the script form that we are familiar with computer has a keyboard and mouse to collect input all of you have seen a keyboard and mouse by the way last year there were some students who had actually not worked with the computer are there any people here some yesterday also we had some people as I said we will be arranging a special session Friday night incidentally all your labs will be Monday through Friday night 8.30 to 10.30 so that will avoid any clash with your football matches or NSO or any other activities you are free in the evenings I will describe that organization in the next class it has a monitor or a printer to display or print output results again you are familiar with monitor it has complex circuits inside which contain a processor connected to memory we don't understand anything about that complex circuitry we take it that there is something called a processor something called memory we just wonder that memory by definition means to store something but we already have a disk so why do we have a memory so the distinction is that memory to which the processor is connected is used to execute the programs that we write whereas the disk which is memory is used to contain large amount of data and other things as we shall see so obviously disk is a larger container pretty much like an almira which contains all the files and my table on which I take one file and I am reading a record I can't keep 2000 files on my table but whenever I require a file I will take it out from the cover and the file which is on my table is what I am reading currently is what I am working on currently so this is something similar to memory and that is something similar to disk so this memory is used to store data values and instructions of our programs all kinds of programs are generically termed as software this term was coined because the rest of it like the monitor keyboard mouse disk processor memory etc was termed hardware similar to the hardware shop where you physically see things like pipes, connecting cables whatever whatever so that is hardware and this is soft and now we observe that a computer can execute a program where instructions are given in a special language called machine language the brain of the computer is the processor and the processor is the one which has been designed to execute instructions that we give unfortunately the processor is also designed using electronic component which uses binary system to represent numerical or any other values zeros and ones and therefore the instructions that are to be given to the computer also have to take the form of one zero one zero one one or some such thing consequently the languages which are which the processors are designed to execute programs written in are called machine languages it is very inconvenient for human beings to write programs in machine languages but that is what processors are capable of doing so we note that a computer can execute a program where instructions are in its own machine language since that is not convenient we have to do something else and that something else is made available through another collection of programs called system software so if we use any other language our program must first be translated into its machine language otherwise the computer cannot execute it and that translation is done by special programs called translators or compilers so when we say we use C++ for writing our programs it is good for us to use C++ every C++ program must be compiled or translated into a machine language of a computer that we are using and please note different computers having different processors will require different compilers one translator program may be translating from C++ into one machine language another may be translating from one C++ into another machine language but these compilers or translators themselves are programs which read my program as data and produce another machine language program as output so these are special programs secondly since modern computers permit a large number of users to simultaneously work so let's say 200 of us are piled onto a lab we have in front of us a monitor, keyboard and something but there is a common server somewhere at the back end and that server is running all our programs now we note that in order to execute a program the program possibly will exist as some file on the desk so that has to be loaded onto the machine memory has to be allocated there is only one processor so processor has to be switched between different programs so that all programs execute simultaneously there will be 200 users all of them will have different files as a teacher I have admitted same file as a student you have a program file as somebody or something else now if that somebody should not be able to delete so some security has to be provided some buffers have to be provided between different users etc all these things have to be managed and therefore to manage such a complex scenario additional software has been provided this software is not a single program it's a collection of programs which is called operating system collection of all such programs that is operating system which itself is a collection of programs plus compilers plus utilities plus libraries all kinds of software which does not really solve a numerical problem or data processing problem but which helps us to do that is called system software and as opposed to that the program that we write would be called application software because we will be solving we will be applying it to solve some problem an operating system therefore is a collection of programs which together supervise and manage the operations of a company these are the typical names since all of you claim to be familiar with computers you truly have heard some of these names everybody has heard Microsoft windows yes that is what is most popular that is what would be used let me ask you a ticklish question did you always use always without exception a license copy of the Microsoft windows how would you feel if I call you things by the way that is what we are when we use unlicensed copy of a software product in this institute it is not permitted I have 5 machines I have Microsoft office loaded only on 2 because I have only 2 license copies I use open office on other machines when I was the dean of resources I struck a deal with Microsoft to get a site license for operating system for the campus where there is a rampant use of pirated software in computer science department labs if somebody is found using an unlicensed illegal software the person is deregistered from all computing resources for a minimum period of 7 days this is how seriously we take it and I would humbly request you to be very very should I say clear in your mind that what you are doing is actually a criminal activity and we are not criminals we do it just because everybody seems to be doing and we don't find anything wrong I am telling you it is absolutely absolutely wrong there is no difference between you going to a friend's place and running away with a television or a radio or a book from his there is no difference that is stealing physical goods this is stealing intellectual so please my humble request please forgive yourselves rethink very very important anyway what we use in our labs is a variation of unix operating system unix is another popular operating system mostly used in larger servers across the world but also on smaller machines now hpux solaris and ibmaix are some of the variants of unix operating system we use a varion called linux which is an open source operating system so this is a free license when I use linux I am not stealing anything I am legally permitted to use linux because it is a free license we use the specific version called ubuntu in our labs I will show you some screen shots from ubuntu this is what their operating system does by the way it manages all users so all users have user identity names password authentication so some password is given it is like a key to a lock without that you can so only you should have that key so that nobody else can damage your files delete and whatever the operating system also manages the file system remember we talked of one file there could be hundreds of data files there could be programs that I will be writing in some programming language those programs will be written as text it stands to reason that those programs themselves will be stored in some text files when those programs are translated by the translator the translated program will be stored as some files the translator itself will be a file because it will be a program and it will have to be stored somewhere consequently all this jammela has to be managed in terms of managing both the disk space the file system the file system is actually organized as directories and sub directories in each of these there could be multiple files and all devices connected to the computer also managed by the operating system so whenever I type something on the keyboard it is the operating system which traps the input key and gives it to the appropriate program similarly whenever I say show me something give me output like give me the centigrade value my program will simply say throw this to this device it is the operating system which will actually take that output and put it on the monitor or whatever and finally it manages execution of all program so operating system is responsible for running anything running your compiler, running your translator for you running your translated program everything so how does it do that as I said to run a program the program must go into the computer's memory that is the table space not in the cupboard and then it must be allocated CPU resources and memory so the operating system does this whenever you say run a program it will actually take that program from the disk in the form of a file load it in the memory the program itself may contain say 20 instructions which occupies so much space but that is not the only memory that the program require the program might be handling a 100 by 100 matrix for which it will have to store data so 100 into 100 elements equivalent of memory will have to be allocated for that program to function operating system takes care of this and once it allocates data space and the instructions in the memory then it says okay now you start running I will permit you to use my CPU once in a while typically in a round robin fashion it will give CPU time to that program that is how the operating system manages execution of the program our interaction with the operating system always begins when we use a computer system in fact it is impossible to get inside a computer system without the operating system now if I want to get in I have mentioned user ID and password but my user ID and my password has been perhaps told to me by some human being how does the operating system know it if operating system doesn't know it it can't imagine that this user name and this password is mine so somebody has to feed that information the group of people who do that work who configure the operating system they are senior engineers they are called sysads you heard this word this is an abbreviation unfortunately the whole computer world is replete with abbreviations so some of the abbreviations you have to learn to use the full name is system administrators this name makes sense to you they administrate the system but it is beneath the dignity of the god like people who manage systems to be called system administrators they are called sysads so we have sysads in our labs what they would do is as soon as you register as soon as you have been given an LDAP login ID by the institute in our CS department lab those login IDs will be given some initial password will be given not only that but they actually load the operating system they configure this file system they load all required language compilers they load libraries they load text editors other utility programs create usernames everything all of this is done in the background by people while configuring the operating system and once it is configured well you start using it when you are using a laptop or a personal computer at home unfortunately you don't get services of a sysad so what do you do well the person who says to the computer probably loads the operating system but as far as user account creation etc is concerned you have to do it yourself so then you are the sysad for your own machine whereas for larger environment there are separate sysads the first step is you are first authenticated by the operating system so user name called login ID operating system shows a login window shows a password window once you login a specific environment is created for that user it ensures that you will land up directly into your home directory because different users have to have access to different components of this file system which will land up there there are certain search parts which are set for the user so that the necessary utilities and programs get easily loaded again I said what is in a name each program will have a name not only programs written by you will have names programs written by system software authors will also have names now whenever you say execute this program the operating system the operating system has to locate that program ordinarily it should expect that it is in the current directory where you are working but if it doesn't find it there it will have to search somewhere else should it search across the entire file system no so there is a mechanism by which a path is defined that if you don't find it here then search it here if you don't find it here then search it here now this environment is automatically created by the operating system for you to log in in general you will get one of the two interfaces when you log in either a graphical interface showing various icons if you have been mostly using Microsoft windows then that is what you will get a graphical user input every icon actually describes a program so when you click on an icon double click on an icon see you say power point you say something but you may also get a text terminal interface which you show a prompt and there you have to type a command so either you can graphically select a command or you can type a command you can switch between these two interfaces very easy so in a graphical window you move the cursor to the desired icon and click to order that program or service to be executed and in a terminal window you have to type the commands followed by a return and then you press to tell the OAS in general in unique systems the command prompt is a dollar symbol whenever we actually give a command whether graphically or through text what happens is the operating system will now load the name service or the program into the memory and handover control to that program now our input output is handled by our program which we have started execution not the operating system operating system still helps that program to do physical input output but the values that we give go directly to our program the values that program produces come directly to us at the end when the program execution terminates the program returns control to the operating system in short every program that we run is some kind of a function which is invoked by the operating system temporarily and when that function finishes its job it has to return control to the operating system so that is how this activity works those of you who have not used computers extensively might not fully understand the implication of everything that is stated it is perfectly all right it is not required what is required is to become familiar with these interfaces so I have some screen shots to show you this is the blank screen shot you can see on ubuntu so you will notice some of the letters are very small to read you will probably be able to read them when I circulate the handouts on the next week this is the kind of terminal interface that you will see here so this is the dollar symbol what comes on the left is some description of where you are for example this is db fatak is my user name is on my laptop so this command is called pwd pwd stands for print working directory you will see these explanations of the unix commands in the handouts and the next week's lab in fact which will be described on friday you will be essentially practicing and using these things there is a command called ls here ls stands for list list means list all the files that exist in the current directory so this is what it is listing here this is another command who tells you who are all logged in onto your machine so on my own machine I was logged in in three different authors so it gives me three different things basically I was trying to run three sessions parallel here is a file browser made available by ubuntu so notice that I am in a directory called db fatak and what is shown here is the list of all subdirectories and some files etc with attendant information you note that on the left I have a terminal and on the right I have a file browser so in a graphical window interface I can have multiple windows open much like the Microsoft operating system that you would have seen and I will be able to operate this is the example of an editor it is called gedit and that is what you will be using for writing your programs, modifying your programs preparing input data files etc etc so this is the example of a program called helloworld.cpp c++ program its only objective in life is to produce a string on our monitors called helloworld traditionally the first program that is written in any cse c++ and all but what it shows is an editor so you can see this particular symbol here this shows that the cursor is at this point so if you type something it will be typed here you can backspace to delete characters you can move using arrows the cursor up and down in general you can edit it just like you can edit any other text document this particular window shows an edited version of the same program observe that a whole lot of comments have been added that these are comments is not known to us but some lines have been added here this next slide shows the commands that I gave for editing so this is gedit helloworld.cpp add and says that execute this command but continue taking more commands from me c++ helloworld.cpp is a command to execute c++ compiler which will take my c program and translate it . is a funny command which says whatever program you translated recently run it now why . doesn't it sound like abrakadabrakad it does but for any program that I translate and if I want the most recently program to be executed you say the same abrakadabrakad every time so once you mug up abrakadabrakad you know how to run your program of course there are better and less stupid ways of doing it which you shall discover in the labs so that's it what I wanted to discuss today