 and welcome to the fourth day of the two week workshop. Today we are going to discuss fundamentals of C programming language. Essentially we will cover the notion of data types in C, notion of expressions, conditional execution and iterations. As I had mentioned earlier since we will not cover things in which we actually teaching your students in very elaborate fashion. What I would like to do here is to cover those aspects of the elements of C programming language which I believe are important and perhaps indicate a way in which these important aspects can be put across to our students. Very obviously, those of you who wish to use this material in actual lectures will have to curtain past these slides and use these appropriately in the larger set of slides that you will have for your actual lectures. So here we go. First we extend the Dumbo model of computing to the real world computers. We indicate that we have studied the abilities of a modern computer through a simplistic model represented by Mr. Dumbo. We know that Mr. Dumbo can store values in his memory. We have modeled the memory as a cupboard with a set of drawers. We know that he can compute and compare values. So that means he can do manipulation of values. We know that he can exchange values with us. That means he is capable of doing input and output operations. More importantly, we know that Dumbo is incapable of doing anything on his own. He will only follow instructions and therefore he is capable of executing instructions which are given by us. And last but the most important factor of a modern computer that the computer is a stored program machine. So we model it in our Dumbo model by saying that we can give Mr. Dumbo a set of pre-written instructions which we call a program and which Mr. Dumbo can store and automatically execute instructions of that program one by one. We have noticed that Mr. Dumbo has a memory which is divided in locations like drawers in a cupboard where each drawer can contain a single value. We also clarified that in this memory model each location has a tag. The tag is usually a name or a number. We introduced the notion of number here to indicate that in actual practice the memory locations are addressed through numbers. However, at our level of programming, we emphasize the notion of a name working as a tag. Further, we have observed that a location is never empty. It always contains some value. Now this is slightly hard for our students to understand. How can a location contain a value unless we have put it? So we try to indicate that these values might have come from some previous computing activity done by Dumbo. Essentially then when our program starts execution, each drawer in the memory including those which have been tagged by us or named by us will contain some value. Since we have not given that value or Dumbo has not computed those values as per our instruction, these are sort of initial undefined values. We have represented them using a question mark put inside the drawer. These are some of the important points that we wish to make to reiterate our Dumbo model of computing. Now we make some comments on the capability of Dumbo to execute instructions. So we have said that Dumbo can exchange information with us which means he can read a value given by us and put it into a designated location. Dumbo can compute a new value by evaluating an expression and assigning it or putting the resulting value in a designated location. Further we observe that whenever an input operation or a computation and assignment operation takes place, the original value in that location, that designated location is replaced by the new value that we put it in. The new value could come either through an input operation or through an expression evaluation followed by an assignment. It is useful to repeat to our students that input operation and assignment operation are only two operations which can change the value of a variable or value of a tagged location. Lastly Dumbo can show us a value in any location which is actually equivalent of an output statement. Having reiterated these simple things we now move over, I am sorry, there is still an important aspect that needs to be mentioned. We have indicated in our simplistic model that Dumbo has a stored program capability. What it means is that the instructions in our program that we supply to Dumbo have to be stored somewhere. We have indicated that these are also stored in the same memory perhaps in a separate set of locations. It is perhaps useful to emphasize that the separate set of locations do not constitute a physically separate memory but rather may be an equivalent of two cupboards or three cupboards instead of one cupboards or portions of a cupboards being used for storing data values and other portion being used for storing instructions. Equally importantly we state or restate that whenever we give a program comprising of instructions that we have written for Dumbo, Dumbo will execute these instructions one by one automatically and in the given sequence. Lastly to instruct Dumbo we must use a precise language. This language is called a programming language. So you see now we are slowly connecting our simplistic Dumbo model of computing to the real world computer. Observe that we have used the words like program, we have used the words like memory, we have used the words like programming language. These are essentially words which describe the real world computer. We now proceed to further expand this simplistic model around Dumbo to a real world computer. So we say that Dumbo in the real world is actually a computer machine. We observe however that computer is a complex machine made up mostly from electronic components. Now the values in memory locations will actually contain binary digits or bits which are we used to represent numerical values or character strings or for that matter the picture element intensity or any other symbolic representation of information that we wish. The point that we are making here very subtly but importantly is that internal representation in an actual computer will be done using binary digits or bits. Note that we have not yet talked about binary representation or number systems that will follow immediately after this explanation. Secondly the instructions that need to be given have to be in a precise language called machine language. Now this machine language is a new concept which we are introducing. It may be useful to state here that machine language instructions since they are also to be stored in the same memory of the computer they will probably also be represented using some bits. Indeed it is bit patterns of different kind which represent different instructions for an actual computer based on the machine language defined for that computer. We further state that a modern computer is actually a machine which has evolved over decades of research and because of this research additional tools and techniques have been developed which permit us to instruct a modern computer in a human like language. Notice that earlier we have said machine language very early to Dumbo we had given instructions which looked like instructions in a human like language. We now connected up by saying that because of the evolution in technology and methodology and tools associated with modern computers it is possible for us to instruct computers using human like language. However since we have stated that modern computer can understand instructions only in machine language we now quickly add that there exists a tool called compiler which can translate these instructions in the machine language of the computer. Notice that when we use the word tool people might believe that it is like a gadget like any other machine. It is not necessary to explain that this tool is a software tool. Indeed at this stage we have not distinguished between software hardware and such thing. Notice it to say that there exists a tool which probably sits inside the computer. In our simplistic model we can call it an assistant Dumbo. So an assistant Dumbo which takes our instructions in a human like language and compiles them in the machine language for the benefit of the main Dumbo who will execute these instructions. Next we notice that the modern machine will exchange values with us in a form similar to us. That means we shall be using let us say a decimal notation or an exponential notation or a string notation with which we are familiar with in order to give input values and in order to see output values given by the machine. And therefore we state that the modern computer is capable of interacting with us using a notation which is familiar to us. Obviously modern computer would therefore be capable of converting the values that we give in decimal notation to an internal binary representation and vice versa. Exactly how does a modern computer do it? We shall explain later but we can hint that the compiler which generates machine instructions corresponding to our instructions in human like language is capable of inserting instructions for doing these conversions both ways. We then add that a special program called operating system controls the operations and interaction with us of any modern computer. We can state here that since this special program helps in operating the modern computer it is called operating system. We need not at this stage elaborate at all on what the operating system is or what the components of operating system are. These can be described in my opinion towards the middle or end of the course. However if the syllabus and the sequence of teaching so demands in your institutions you can actually talk about operating system briefly immediately after introducing the basic hardware and number representation in such things. I will try to put together a sequence of slides which will help you follow up this kind of sequence of teaching and I will send it across to you and briefly elaborate it in one of the sessions later. But in our opinion here the majority of teachers who have taught computer programming here in our opinion it is detrimental for proper understanding of modern programming concepts to introduce the notion of hardware operating systems binary representation etc. too early in the programming course. We further indicate that we interact with modern computer using special gadgets. Typically these are a keyboard using which we can type our instructions and our data values and a monitor which displays to us any value output by the computer. Students will not at all find this strange because these are the devices which they will see immediately in the lab and many of them would have actually seen and used a computer earlier. So this is perfectly fine to introduce the notion of a monitor and a keyboard without talking much about it. Do not forget that there will be some students in your class who would have never seen a computer in their lives and that is the reason why although the formal laboratory sessions where people will do actual programming may start slightly later in the subject teaching schedule that you have. It is my recommendation and we have found it extremely useful that in the very first week when the students come to your colleges they should be introduced to the computers in terms of showing them the monitor, the keyboard perhaps exposing them to the computing environment although they may not understand why they are typing certain commands for the operating system it is useful for them to have an exposure of that kind. This is primarily for students who have never seen a computer and believe me there will be some even in IIT in the class of 830 students I found about 58 students who had absolutely no inkling of what a computer is. They came from a village background where they had never seen a computer. The next point that we make about modern computer is that our interaction with the computer begins with the operating system. It is important to emphasize that things like login that we do or things like command typing that we do whether it is in Ubuntu or whether it is in Microsoft operating system or any other place we are actually neither writing a program nor executing a program I mean executing a program written by us but instead we are interacting with the operating system we are giving operating system certain commands in a language that is completely different from the programming language that we are going to study or which we want to emphasize in this subject. So we say that our interaction typically begins with the operating system and this interaction is either through text interface where the operating system shows us a command prompt note the dollar sign can be explained as a command prompt why prompt because whenever a dollar appears the operating system is prompting us to give a command to the computer or we could interact through a graphical window like interface please note when I use the word graphical window here I do not imply windows operating system of Microsoft graphical window is a generic term it is useful to state here for example that a graphical window interface is provided by most operating systems the one which we use is called Ubuntu there are many operating systems Ubuntu is a version of Linux which is a version of Unix these things can be stated without detailed explanation what is important is to emphasize that there are many operating systems that are available with modern computers this is important from the point of view of not those students who have never seen a computer but those students who have not only seen a computer but written programs on that computer I would like to emphasize again that a job of a teacher is not to teach to the average student but to every student in the class so just as we must take care of those who have no background in programming we must also challenge those who have a lot of programming background we know today that several students in 11th and 12th standard actually do a lot of computer program and therefore it is important to clarify concepts that they might have wrongly learned or inadequately learned while doing programming on their own through the schools one such concept I have found is that most of these students work on one environment typically that environment is a Microsoft environment there is nothing wrong with that environment it is a beautiful environment and people write programs using either turbo C or any other C compiler but they tend to believe many of them tend to believe that that is the only operating system that exists in the world it is therefore useful to emphasize right at the beginning that there are many operating systems one of which is open to which we shall be using there is a Microsoft operating system there is HP UX they are mainframe operating systems like ZOS and so on it may be useful to throw in a few names to indicate to the students that there are indeed many operating systems which are used at different places and different levels going further we now say we show an interaction with a C Dumbo or a Dumbo which is capable of running C programs observe that in the screen there is not a single mention of either a C program instruction or C program compilation but what we are showing is the interaction with the operating system most of you would of course be familiar with this it is possible for you to expand this interaction to show compilation of a C program which has been previously stored in computers desk notice that we have not introduced the disk per se but we can perhaps talk about file system directories, sub directories and files which modern computer is capable of supporting through a device called desk we may simply add that we shall have a detailed discussion on desk and the file system and so on later but effectively when we interact with modern computer today in the lab what we shall see is an operating system prompt and we can give several commands such as PWD to display the current directory or CD for changing directory or LS for listing files and so on here is a program for adding two numbers which we had seen in the first session in the previous session which has been rewritten this has been rewritten to permit simplification of input-output operations all my colleague teachers attending this workshop would have noticed that handling input and output in C is very clumsy there are very specific instructions for doing computations assignment for executing conditionally certain statements or for specifying iteration but when it comes to input-output C programming language does not have any instruction whatsoever this is because originally the C programming language was planned to be as close to the machine as possible and as easy for translating into machine instructions as possible and therefore the C language which was defined by Carnegie and Richie and other colleagues in Bell Laboratories did not have any input-output instructions the input output has always been traditionally performed in C and therefore in C++ using functions now at this juncture it is extremely difficult to convey to the students what we mean by functions so instead we can state that input and output is carried out by special instructions which require that the instruction be a single word instruction and followed by whatever input-output we want to do one at a time we shall put it in parenthesis consequently the instruction that our students will see will be something like put string get num i put string put num i etc what is this put num i or get num i well get num i is an abbreviation for getting an integer number put num i is an abbreviation for getting or putting out or displaying an integer number if we do not wish to confuse students with i or f which are integer or fraction or floating point numbers we can simply write this as get number put number instead of writing put string we can simply say put message we can even say read number write number we can simply say display number we can simply say display message why are these possible because what we are using as you would have observed we are using the hash defined command available as a pre-processing command for C compiler so notice that I am defining here get num i a as scanf %d and a for those of colleague teachers who are not very comfortable with C programming concepts of scanf and printf we shall have a separate session tomorrow on basic IO where I will clarify these things however since most of you would have taught C programming you would be familiar with these notions all that I am doing here is in my program I am actually hiding the uncomfortable function calls such as scanf and printf by writing hash defined macros so this get num i a will actually get replaced by scanf %d and a so whatever is the parameter that I give in get num i for example this value this entire line will get replaced by scanf and the value of a will be read it is very useful to try and see how all of us together attending this workshop can help better teaching of C programming input and output statements during the early days of teaching by simplifying such things this simplification does permit hiding scanf and printf detail notably the control strings such as %d it is extremely difficult at this stage to explain the notion of control %d %s %f etc etc because these are not natural thing these are artificially connived string expressions which have been defined traditionally and historically for using C input output functions they actually stand with us as millstones around necks most other programming languages have very decent English language like input output statements C does not have it however as I said I can use any choice of wording that I wish to define these macros and use them in my programs notice that if these three lines are visible to our students right at the beginning then they will still get confused wondering what is this because this line define get num i a scanf %d and a more confusing than just scanf so what we do is we have to use include statement in our program to say include stdio.h instead we could say an include statement which say my header file.h and in that we will include stdio.h and also other headers that we wish to define such that the students see a simplistic include statement even if they do not understand it they will routinely put it and go ahead but in their program they can use simplified input output through such defined nomenclature. Here is a program written to convert temperature from centigrade to Fahrenheit value we have seen that earlier in the last session and we discussed this we had used C in and C out notice that C in and C out are probably the best abbreviation that you can get for input output unfortunately these are actually operators by the way these are what you call elements of an object class and therefore they are far harder to explain in their complete details but they are much simple to use for initial students however we can put these abbreviations as I said here notice that this first slide is only the abbreviations and the general comments to indicate what the program does however this slide shows the complete program which says int main float C float F put string temperature in centigrade get num F C put string and put num F again people may get confused what is put num F and what was put num I maybe we can say instead of put num F we can say display fractional number or write fractional number similarly instead of get num F we can say get fractional number something which may be meaningful for students intuitively and which we can define using these macros is recommended for usage it is at this stage that you can proceed to describe to our students how integer numerical values and fractional numerical values are handled inside a modern computer through the C programming compile C programming language compiler for example now we can say that when we say int x in our program it results one location in memory for x to store integer values so x is now implicitly the name of a variable note that we have not been talking about the notion of a variable so far at all we are merely using x as a tag attached to a memory location which is indeed the correct definition of a variable the fact that that variable as a type is indicated by our saying int x so this explanation is quite often very good and sufficient int x results one location in memory for x to store integer value at this stage we may indicate that the maximum possible positive value could be 2 to the power 31-1 and minimum negative number would be minus 2 to the power 31-1 this presumes that we are talking about a 32 bit machine we can also state that on some computers which have covers with smaller size drawer such large numbers also cannot be put in instead the numbers will be plus 2 to the power 16 minus 1 and minus 2 to the power 16 minus we notice that when we say 2 to the power 31 it is almost equal to 2 into 10 to the power 9 so we relate a binary representation here to a decimal notation which people would be familiar with now this means that about 9 digit number can be stored that is the significance of 10 to the power 9 see our students will almost always think in terms of decimal numbers just as all of us do it is impossible for us to think in our minds in terms of binary numbers we are not computers we are human beings and we have been taught a decimal number system right from our childhood and therefore how many digits a number has would be naturally answered by all of us and our students in terms of decimal digits that is the significance of equating 2 to the power 31 to 2 to the power 2 into 10 to the power 9 because when we state this students can intuitively guess that the largest number which can be stored inside a machine would be a 9 digit number we proceed to state that C programming language permits us to define larger memory locations which can store larger values so how do we store larger number we shall use long integers by saying long x instead of index and this word long x can be related to our driver model by saying that we have a long driver or we have a wider driver or a larger driver so when we say long x we state that the maximum magnitude can be 2 to the power 63 minus 1 students will wonder where do this funny numbers like 63 and 31 come it is your choice to either state that 32 is the number of bits that a driver can hold or a 64 can be a number of bits which a larger driver can hold as a matter of fact those of you who have already discussed hardware earlier can relate our model with the actual computer by saying that if one driver holds 32 bits then we can allocate 2 drivers to hold a single number one part in one drawer another part in another drawer thereby indicating that the storage capacity of long x will be double the size of the storage capacity of ordinary int so sure we can state now that the real computer uses binary number system or base 2 representation and thus the value limits are expressed in powers of 2 it will be useful to indicate or 16 to suggest that it could be power of 2 or it could be power of 16 indeed on most computers as you would although when floating point representation is used the exponent is always treated to be an exponent of the base 16 rather than base 2 that permits you to represent very large and very small values more effectively so for the time being we will continue to believe that our Dumbo uses decimal values that is best representation and this is quite natural and logical because through the C programs that students write both the constant values that they put inside their programs as well as the values that they give as input and the values which they receive as output they will invariably see decibel numbers fractional or integer but they will see decibel numbers and therefore they will not take too much of convincing to assume that digital computers somehow can handle our decimal numbers that we give or we want to see into and from binary representation which will be internal to the computers so we conclude that our computer effectively does decimal arithmetic of for us however it does so with limitations the only limitation we have seen so far is the limitation and the number of digits that our number can have for example if I want to represent a 500 digit number we have no mechanism known at this juncture how to make computer represent and handle 500 digit numbers later on in this workshop and in your course it is useful to indicate what is known as a multi digit high precision arithmetic by which artificially you can store a very large number such as a number with 500 digits into an array rather than individual memory location but that will come later and in this workshop I will indicate through some examples how that can be done however basically we reiterate that the computer can effectively handle decimal arithmetic for us however it has limitations for integer numbers the limitation is the maximum number of digits that a number like this can have but we also have to indicate what is to be done with fractional numbers here we introduce the notion of floating point representation we already use the word float in conversion program from second degree centigrade to degree Fahrenheit this is perhaps time to explain what does that float wire means so we say that float wire results one location to store a number in floating point format we are not introduced the notion of a point or no student will ever understand or imagine why any number should be floating so this word floating point is an extremely artificial word which cannot be naturally understood by any student you will recall that when we always students and we are trying to understand programming this notion of floating point would have appeared very funny to us when we first heard it and this is what will be the natural reaction from all our students does not matter that is the reason why we have to explain why such funny term has been used so we now proceed to state that a floating point representation for a number or this format will have two components and these two components of the number are stored in the same location in two separate compartments so you can show a sort of compartmenting of our drawer one part stores one one part stores one component another part stores another component the part which is the first component is called mantissa and the other is called exponent very fortunately most students who have done 12 standard maths would be able to understand mantissa and exponent many of them would have heard and use these terms however there will be several who will again get confused and it is therefore important to explain to them what is mantissa and what is exponent so we say that a number value of this kind is taken as m into b to the power e this they will understand we now say that m is mantissa and e is exponent and b the capital B that we have shown here is some kind of a fixed base which we know and which the computer knows then we say a computer uses B base as two binary or 16 which is called extra decimal however for the purposes of our understanding and also our usage we shall continue to take the base B to be our usual 10 why because that is what we will use at our end when we supply a fractional value in a floating point representation we will use decimal base 10 if we get a value from computer we would expect the computer to convert that value in a decimal notation and give it to us so it is perfectly alright for us to say that while the computer may use base B as two or 16 as far as we are concerned the computer uses the base 10 however it is important to indicate some subtle problems that this conversion of base may end there but that may come at a later stage so here is what we emphasize to our students that no decimal point is actually stored by our computer however it is assumed to be the at the beginning of mantissa for example if a number is written as minus 4127 as the first component and 11 as the second component we emphasize here again that this is called mantissa and this is called exponent then we state that the computer will invariably take this to mean minus 0.4127 multiplied by 10 to the power 11 similarly if we write plus 1 9 4 6 2 and minus 21 as mantissa then it will always be seen as the computer to mean 0.19462 into 10 to the power 21 the reason why the point is called a floating is explained later we can write the first number for example as minus 0.4127 e 11 this notion this notation will be known to most of our students but to those who do not know this it should be explained that e stands for exponentiation operation e is not a base or something e merely is the notation used to separate out the mantissa part from the exponent part so whatever comes to the left of e in our writing is mantissa whatever comes to the right of e in our writing is the exponent and both mantissa and exponent can be individually positive or negative once this notation is explained and we tell them that when we write values in our program or on the terminal we always use decimal number notation and therefore the base for such representation is 10 and not to our 16 we further elaborate that this same number can be written in multiple ways for example I can write it as minus 0.04127 but increase the exponent by 1 to say e 12 all I could write it as minus 41.27 e 9 which will mean the number is minus 41.27 into 10 to the power 9 which is same as 0.4127 into 10 to the power 11 the computer uses this notation to internally store the number but since we can write the number in any one of these forms we say although both of them represent the same number and therefore we say that this representation is generally a floating point representation where a point can be made to float from the beginning somewhere in between right to the end in fact it is possible to write the whole number as minus 41.27000000 something e minus something of course that is artificial and that is not correct but it is just to emphasize that the decimal point can be written anywhere in the mantesa as long as the exponent value is correctly adjusted to represent the true value with this then the notion of floating point is made clear to people and then we say because we can use a floating point representation in our writing we want computer to have a similar representation and that is made available by the programming language through a data type called float. What it means is that when I designate a computer memory location or a drawer in a cupboard in our simplistic model to have a floating point value it essentially means that the computer can store in that location a mantesa and exponent and once it stores it it will always use what is known as a normalized mantesa which means that the decimal point for us and the binary or extra decimal point for the computer will always at the beginning of the significant digit of the mantesa. So it will never have point 000 something or it will never have something 0.0 whatever it will always have point some non-zero digit and then the mantesa is represented with the exponent adjusted correctly to represent whatever value we give it notice that even if we supply a value as minus 41.27E9 which is exactly the same value written slightly differently once the C program instruction is executed to take this value from us internally it will always be stored in this normalized form or its equivalent binary or extra decimal version. Now we come to the more important point that because we have a single drawer in which we are storing both the parts the mantesa part gets crowded and fewer digits can be stored in mantesa then what would have been possible had a single integer number been stored in the same drawer we can remark at this stage that ordinarily a single location can contain up to a 9 digit decimal number however when it comes to store the mantesa it can store mantesa of only about 7 decimal digits however the exponent can be between about minus 100 to plus 100 notice that this is possible because the bits which are used to store the mantesa portion are assumed to represent a power to base 16 and not a power to base 2 when a power to base 16 is expanded the power to base 10 it amounts to a very large power both negative and positive in terms of exponent again we indicate that just as we had a provision to store large integer values we can store large fractional values or floating point values as well large not in terms of the magnitude as indicated by the exponent but with better precision in short it is very important to convey to our students that there are two parts of a floating point number one is the precision which deals with how many digits can be represented of the number that we have the other is the exponent which represents the magnitude of the number very large or very small and we state now that when we say double z the mantesa representation capability in terms of precision increases to about 14 decibel digits indeed this is the reason why it is called the double because it has almost double the capacity in terms of digits so instead of 7 decimal digits you can represent about 14 decimal digits at this stage it is useful to indicate the kind of problems that you may have in doing computations with numbers represented using floating point and represented using binary base rather than a decimal base since computers offer limited precision the computations will lead to inaccuracies it is useful to indicate the inaccuracy through some examples for example when you add a very large floating point number to a very small floating point number the sum may be equal to the large floating point number only we have an example in one of the slides here which can be used as an illustration of this point what we state is special care must be taken to handle such round off errors and that there are there is a huge amount of research in what we call numerical computations which provides methodologies special techniques and algorithms to handle and minimize such errors in our programs a sample example can be given a very popular book called numerical recipes in sea originally this book was written as numerical recipes in Fortran then you have numerical recipes in sea and then you have numerical recipes in sea plus plus by the way those of you who have not seen these books I will request you to try and access these books and read them the probably the most excellent collection of techniques to handle numerical computations while minimizing errors and I am not talking about small time numerical computation just as finding roots of an equation or something of course roots of an equation of a very large linear system are covered but so are covered solution of differential equations partial differential equations series computations and so on and so on an explicit book which many of you will enjoy reading and actually using in your computational activities in summary I state that this is the statement made by Leopold Kronecker some of you might have heard of Kronecker delta it's a it's a mathematical function which we come across in impulse response computations in control systems and so on so he said God made natural numbers the rest in the work of man indicating that human beings have spied the life of ordinary humans by introducing fractions decimal numbers and so on but he also points out that man has extended God's work by making numerical computations far more meaningful to solve problems on the real life and he said God made natural numbers the rest in the work of man I have added this humans made fractions and decimal numbers the rest in the work of Dumbos and this is definitely detrimental to the computational process which human beings have evolved using fractions and decimal numbers because we face a whole lot of errors which need to be corrected by special techniques before going further I would I would like to just use this slide before breaking off for a small interaction and then having a break this is about what happens when very large and very small numbers are added this is just one example where round off error may lead to very hilarious consequences in floating point arithmetic if we use floating point arithmetic using a computer to calculate Avogadro number here is a line which is I am showing out of sequence which says the value of W and Avogadro will differ in the 23rd digit what is the significance of this let us look at the remaining lines of this slide we define float w and float y y is equal to 1.5 then we define Avogadro as 6.023 10 to the power 23 for those of you who recall their physics lessons from the college days we will remember that Avogadro number is actually 6.023 into 10 to the power 23 it is an extremely large number 10 to the power 23 is a very large number so actually there is nothing like 6.023 it is not a fractional number the actual number is 6 0 2 3 0 0 0 0 0 0 so on till you become a tire of counting and that is the Avogadro number what is being illustrated in this small example is what would happen if to such an Avogadro number I had a value 1.5 so here we say W is equal to Avogadro plus y in actual practice if we were to add these two numbers you know what would happen the result in human terms would be if you take the Avogadro number and expand it to all the digits then I will have 6 0 2 3 0 0 0 0 0 0 0 here to which I will add 1.5 and therefore the result would be 6 0 2 3 0 0 0 0 0 0 1.5 which means that the number W and the number Avogadro will differ in the 23rd digit unfortunately the machine has no mechanism to store these 23 digits and therefore even we know that when we say Avogadro plus y the value of W will be different from y as far as our Dumbo computer is concerned when we make this statement W is equal to Avogadro plus y what we will have is a value of W which is actually since floating point stores 7 digit of Mantissa all digits beyond this are ignored and therefore W is equal to Avogadro now this is indeed funny we know that W is different from Avogadro but if we make the computer compute these it will not be different at all you will notice that we had some part of the lab assignment yesterday to illustrate this point namely the limitation of the storage we are not emphasize computations and the loss of precision to this extent but this is something to be kept in mind and perhaps you may casual up additional lab exercises to indicate to your students how careful they have to be because the loss of precision due to round off errors this is clearly a round off error Avogadro plus y actually in even our floating point notation will be 6.023000015 e to the power 23 however since all those digits will be forgotten only 7 digits of Mantissa will be stored you will essentially get the same value as Avogadro incidentally you might want to tell your students what would happen if I mix the arithmetic operations this is also the time where you can introduce the notion of arithmetic operations for example we can tell that the computer converts from float to int and vice versa as needed automatically so we might have defined values which are floating point or values which are integer but when we mix them in arithmetic operation they will automatically be converted as desired however it is useful to indicate some pitfalls which may happen for example if we are defined int x equal to 10 and float y equal to 6.5 then operation x equal to y will result in 6.5 to be rounded down since x will be given 6 it is useful to indicate that while the location for y had the capability to contain a fractional number in a floating point representation the location for x being defined as int can store only integer type values and therefore so x is equal to y will result in rounding off 360 by x an integer result will be calculated because x is integer and the value written here 360 is integer however if I write the same value as 360.0 indicating to the computer that I imply a floating point value rather than an integer value then when a floating point value is divided by an integer value the result is floating result I leave it to you to think about what will happen when 360 by y is done the result is floating although 360 is integer actually y is floating point so this way we can introduce the notion of mixed arithmetic to our students and how does the computer handle mixed arithmetic it will be useful at this juncture to define the arithmetic operators and their precedence for example people would have guessed already that star would mean multiplication because we have indicated that in our representation of floating point operation however they would not immediately understand the notion of this percent symbol at all as an operator it is useful therefore to indicate that we have star slash percent to indicate module operation plus and minus we can indicate the precedence of evaluation in a complex expression by saying star and slash have higher precedence than plus and minus star and slash have equal precedence but they are evaluated left to right and similarly plus and minus and x is equal to m percent n means m modulo n is calculated so if m is 10 n is 4 m modulo n is actually remainder of what happens when you divide 10 by 4 so if you divide 10 by 4 you will get 2 as a remainder and therefore remainder is calculated here the modulo operator has the same precedence as star and slash an interesting aspect about modulo can be explicitly stated this is often missed out in the early teaching that if both m and n are positive the modulo remainder calculated is positive if both m and n are negative then the modulo remainder calculated is negative however if m is positive and n is negative or m is negative and n is positive curiously the C programming language does not define what should be the sign of the remainder it is left to be implementation dependent it is interesting to run a program containing such a modulo calculation on different compilers and see exactly what you get as the sign of the remainder I will leave it to you as an exercise and we emphasize here that if we do not like the precedence in an expression naturally defined by C we can override it by using brackets which are put around any portion of the expression to override the default precedence of the operators we will take a short break from lecturing here