 So, good morning everybody. This is practically the last session from my side. On the subsequent days as I told you, you will have to make brief presentations telling everybody on what your team proposes to do for two weeks after the workshop. And of course, everybody would like to meet members of all the teams from all the remote centers. Today I have decided not only to expand on our understanding of structure, but to actually give try and give a an explanation, which would be simple enough for first year students to appreciate. I noticed that because of multiple problems yesterday, because the assignment was not loaded on Moodle for quite some time, most people were unable to submit their assignments. I am therefore, not giving any new assignment for the lab today. However, I would expect people to complete the assignment namely, creating a direct access file to store records, which were given to you in the form of CS 101 mid semester examination. I got some queries yesterday from which I deciphered that the program which I had discussed did not make it very clear to people as to how records can be directly accessed in a file. So, what I have decided is I have rewritten that example completely with additional commands on the style in which I presented the truck balancing problem. I will be discussing that there have been a lot of queries from the participants. I would be coming back to you with those queries, but not necessarily with the answers. I would instead raise a query here and request any participant from any center to answer it. I realized that this workshop was fast turning into some kind of a class, where a teacher or his representatives who are the center coordinators are essentially appearing to deliver something and the participants are taking it. As I told you right at the beginning, the objective of this workshop is to create and sustain a collaborative group of people. As I mentioned earlier, all of you are the first set of collaborators. Now, in a collaborative environment, it never happens that a large number of people raise queries and only few people are required to answer them. Everyone must feel encouraged to attempt to answer a query raised by anyone. That indeed is the principle of most open source communities across the world. With respect to CC++, you would have seen several forums on the web, where in a question is raised by somebody, answer is given by someone and the question answer is classified based on the topic to which that question pertains and the whole material becomes available for everyone. Roughly speaking, in the context of first year education of computer programming, that is the kind of framework which we wish to create. And rather than wait for our subject portal to be launched in the month of October as planned, I would start in the spirit of that web portal, I would like to start the activity as an initial measure from this workshop itself. Consequently, I have decided not to answer any query myself. It does not mean that the queries will remain unanswered. But to begin with, I will pose these queries to all participants and I will expect somebody to provide an answer. As I always say, an answer need not be correct or perfect, but there must be an attempt to look at the problem and different opinions should be heard. Needless to add, me and my team will complete all answers and will put them on to the workshop model. In fact, I am keeping a deadline of two weeks for my team as well. So, by the time you submit your two week assignments to your co-ordinators and to us on the Moodle, we will also publish complete answers to queries that you have raised. These will also include answers given by some of you with of course, due credentials. So, please keep that in mind while you plan your activities for two weeks after the workshop. So, in this session, I have proposed to discuss the struct data type in C and indicate the notion of an abstract data type and how that notion leads to the subsequent notion of classes and objects and so on. We can therefore relate to the development of C plus plus and Java. It may be a rather crude comparison, but fundamentally that is a right comparison when we talk about abstract data types. We will have some examples of struct variables arranged and we will have another sample problem which is the same problem that we discussed yesterday, namely creation of a direct access file and updating of the records through random access. I will very briefly mention unions, but I will only describe what a union is, but I will not give any example. I will expect some of you to construct an appropriate example of union for the actual usage. In the second part, under the miscellaneous topics as I mentioned, I will essentially recite the important queries that have been raised by all the participants and expect you to answer these queries. I will make some announcements and we will of course have a lot of interaction in the second session. By the way, I hope all of you have clickers with you. Yesterday I wanted to conduct a quiz. It is an important quiz. It is not related to any technical feature of C programming language, but it is related to a teaching paragraph, that question. I will raise it after about 15 minutes before starting with the example of direct access file, but after completing the explanation for the notion of structure variables. So, in another 20 minutes time perhaps, I would request center coordinators to ensure that their receivers or their hardware is switched on and their receivers are connected in place. I request all the participants to keep the clickers with them as of now. Please do not switch them on. As you all know, they have a property of going back to sleep in precisely 5 minutes after you switch them on. So, do not switch them on. Even if you have, let it go back to sleep. I will tell you when to switch on those clickers. So, right now we continue with our discussion on the structure data type. So, what are structures in C? First and foremost, a struct definition does not define any variable nor any storage is allocated. You might find this curious. So, a definition of a structure is not equivalent of definition of anything equivalent to a variable or array or even the group of bytes that the structure is supposedly representing. What it does then? It rather defines a new type just as we have a type of value in, type of value care. Similarly, the type of value struct something. So, what we are defining is actually a new type. Just as we use all native types in float care, etcetera, after this is defined, we can use this as a type. To understand this notion clearly, let us revisit some well-known terms that we use in C program in the context of type zone. Another float, suppose I just say the word float. I am not talking about float A, B, C, float X, Y, Z, float M, 10 or something like that. Not a declaration of variable or an array. Just the word float. What does it convey? This word conveys to us the way a structure of four bytes is formed will look like later. Notice that a float we have said always that float occupies four bytes, 32 bits, out of which some bits are reserved for mentisa, some bits are reserved for exponent and that once you represent the number in a normalized mentisa and exponent fashion, then arithmetic operations on the floating point numbers stored in that location in that particular way can be carried out by the computer. That is the notion of the word float. So, observe that the word float alone does not talk anything about the actual memory allocation or for that matter the name of a variable or an array anything. That is why we say float is a type. I have tried to explain this diagrammatically. So, here is a query. Our computer wonders what does float mean? Then the computer recognizes that float means that it is a type and any variable of this type will have to be allocated four bytes of memory. That is the first impression the computer has when computer gets to see the word float. The internal representation will have mantisa and exponent and then the computer says I will have to do arithmetic operations on values of such variables. So, this then is the understanding of the word float. That is why we say float is a type. Now, when we later on go ahead and in our program describe variables. Suppose we write in our program float x comma y equal to 23.1.4 semicolon. So, what it does? It is essentially as we all know it declares a variable x to hold a type of float type of value and the value is undefined at this moment and it also declares variable y which again will hold a floating point type of value, but this time there is an initial value supplied 23.14. In fact, this value or any other value could out come out of a later assignment or what. Now, when we declare variables like this, it is at that time that the locations for each of these two variables are actually allocated. So, by simply saying float variables and arrays do not pop up. That is why float is a description of a type. Now, when we make these declarations, you now look at what our C program or the C compiler does. C compiler has already known the meaning of float and this is the meaning I will repeat. For the computer the meaning of float is any variable of this type will have to be allocated 4 bytes of memory. The internal representation will have M n t sign exponent and I will have to do arithmetic operations on values of such variable. So, suppose I had said only float x, what the compiler would have done is it will have allocated 4 bytes called it x that is the name of the variable and it would have left the value undefined. It would not know because we are not assigning. If we on the other hand execute a statement float x comma y equal to 23.14 executing a statement meaning this statement is made as a definitive part in our program. The moment compiler reads this statement it is at this time that the storage is allocated for x and y and the values are put in. If any, there is an initial value for y no initial value for x nothing is put in x something is put in y which is exactly this value, but in the internal format to represent that I have merely tried to show it as a normalize mantissa 0.2314 followed by the digit 2. This is an external representation of the value. All of us know that internally this would be represented in some binary or hexadecimal form, but the net net only when this definition of variables or initialization of variable is done at that time memory is allocated. Till then there is no memory allocation. Memory could be allocated to simple variables to arrays only one at a time many times whatever one and of course after this when my program is translated if that program contains an expression involving floating point variables x and y then these values will be used. If there is an a further assignment the assignment will happen here etcetera all of that we know. It is in this context I would like you to look at the concept of a structure. So in an analogous manner when we say struct new type int a float y, care c h, closing blasts. This means that a new type is being defined which is called new type note the possible confusion unlike when we say the word float or int or care there is no variable that is seeable there. Therefore that is a concept and we understand that is a concept of a type and the attendant implications of that type is that the storage may be 4 bytes or 1 byte for character whatever whatever and the type of values that are put in etcetera that is understood by that type and only when we declare a variable or an array then the storage is allocated. Unlike the term float however the term struct new type appears to be associated with some declarations right at the beginning. So consequently our first year students may think that the storage is being allocated to a y c h etcetera etcetera that is where we need to tell them that that is not the case. When I say struct new type although the structure itself is being defined in terms of three members the structure still remains a notional concept like a type. So all that this declaration indicates to our computer is that a new type is being defined this type has three members one of them will be integer type another will be float type and third will be care type. So essentially it is defining how many members that structure will have and what would be the type of individual members naturally these types have to be the ones which are already known. So care is known float is known int is known and therefore we have used available types there could be many members five members ten members arrays whatever. Now if this is a new type then if variables are declared to be of this new type whenever they are declared allocation will have to be made for each of the three components. Since this will require four bytes this will require one byte as and when the allocation is made the allocation will have to be made for seventeen bytes and further these seventeen bytes together will not represent a character array or in such thing it will represent a collection of three independent components or elements one component is integer another is float third is what you call care. Again I have tried to explain this diagrammatically you might find it useful to explain this concept to first year students. So I have taken the same logic what does the word struct new type mean. So here is the compiler thinking struct new type. So I now notice that any variable of this type will have to be allocated seventeen bytes of memory there will be three components each of the indicated standard type and I will have to do appropriate operations on each of the three components now. So there is no more just floating point operation or integer. In fact different types of operations may have to be done on different elements depending upon the native type of each individual. But notice once again that if I say struct new type with the definition that was given there no storage is allocated because this is merely definition of a type. Now in my program after giving this definition of struct if I say struct new type where where is the name of a variable. Just as I could have said int where float where care where I am saying struct new type where. Then the compiler looks at struct new type where it now understands that a variable where is being defined of the new type. And the new type is not an individual thing but it is a structure consequently in terms of what we saw earlier about the interpretation of declaration of our integer and floating point variables explicitly. Here when I give the struct new type where now the computer will create a storage for this variable where and how it will create a storage it knows where has three components. How does it know it from the definition of the new type? Therefore it will allocate space for components or elements or members of this particular type. So there will be a where dot a where dot y where dot c h. Where dot a will be an integer number where dot y will be a floating point number where dot c h will be a character. Although the space physically looks to be of the same size as a and y we know that it is not so. It will the last one will occupy only one byte. And once I define these variables that is what this variable then each individual member will now start behaving as if they were individual variables of the corresponding type. However together they represent a collection of values which totally is where and where is nothing therefore but in a structure of the type new type. I can do assignment operations where dot a is equal to 58 where dot y equal to 23.14 where dot c h is equal to w. So after declaring where I can do assignments I can calculate whatever values expression evaluation etcetera as per normal thing. Notice the way so once I make these such assignments what I will see now is that the machine has actually allocated these values to the corresponding locations the integer value 58 goes and sits in the first four bytes 0.2314 e2 go and sit in the next four bytes w which is a character goes and sits in the next one byte where dot c h. It is also important to note and to tell our first year students that unlike individual variables and arrays which are even though they are declared in a certain sequence the storage need not be allocated contiguously that is not so which structure structures in this respect are like arrays. Just as all elements of the array must be allocated contiguous space one after another exactly in the same fashion all members or components or elements of structure must be allocated memory consecutively. So consequently there is a notion of a size of a structure the size of this structure is four bytes plus four bytes plus one and we can validate this by writing some program and executing I shall now indicate exactly that. So here is the structure definition of student info type you will remember this definition from yesterday's discussion I am saying here struct student info type this struct student info type has one two three four five members or five elements the first one is a character array of thirty elements of course thirty one positions because you need a backslash zero as per the c string care is a string of eight characters hostel is an integer number marks is an array of five elements each of which is a float grade is a string of two characters which hold the character string. So what we have done here now student info type is a new type this by the way is called an abstract data type by abstract because it does not exist originally as part of the sea language definition. So you do not have what you call you have int float in the same way care etc as a native type any type which I am artificially defining is not a native type and therefore it is an abstract data type. So you might have heard the word ADT being used by students in a slightly confused fashion the correct way to explain to them is this is a mechanism to define a new type to which certain variables and arrays could belong and here is an example struck student info type s comma s list thousand struck info type star p. So what we are doing we are declaring a variable called s which is of this type notice that s now is no more a simple variable just one value it is not one value it is rather a collection of value and what are the collection of values the collection of values represented by s which is a variable of the new abstract data type is s dot name s dot role s dot hostel s dot marks s dot grade all of these together constitute s. This is still bigger s list thousand is an array of structures each element of s list so s list 0 s list 1 s list 2 etc each element is actually a composition of all corresponding things together there will be a size of this structure which will be equivalent to the total number of bytes that need to be allocated consecutively in order to represent all the individual elements and their values just as I can declare a pointer of type int pointer of type care pointer of type float to point to memory location of a variable on an array which contains that type of value in exactly the same fashion I am permitted to declare a pointer of type struct student info type naturally p cannot be assigned the address of a normal integer or float variable or something it must be assigned an address of one of the structures which have been defined as per this structure type here are some examples so when I say s dot name 0 equal to n notice that name is a character string so the 0th element of name is being assigned one character value n but name is not a standalone character string it is a part of s in fact if I have five structures defined s p t q r then each of them will have an array name each of them will have a hostel number this is how I refer to individual elements of the structure so s dot hostel equal to 12 we will make an assignment to that for part of the hostel which is part of s variable and s variable is a structure similarly I can take the structure variable s find its address the and operator works even for structures and assign it to p once I do that I can refer to any element using p unfortunately unlike the normal case where if I have assigned a pointer say p t r to an integer variable star p t r means its value here it is not like that in order to refer to the element pointed to by pointer p we use a special symbol hyphen followed by greater than so p hyphen greater than so together we will call this arrow notice that it looks like an arrow it is not a single symbol it is it is made up with minus sign and a greater than so p arrow hostel will mean the hostel which is pointed to by the pointer p which points to that structure now you can see a series of print statements what they execute I suggest that you might just copy these statements put them on to your machine in inside a dummy program and execute them you will be able to see what happens actually so for example this print statement will print the hostel name this print statement will print size of the structure because I am saying size of s size of is a operator of a function which works not only on integers and other types but it also are abstract size of marks mark is a component so I can say size of s dot marks I can find out size of s dot marks that will be printed separately size of grade will be size of s dot grade naturally grade which is a three element array should show the size of three bytes size of p itself pointer you will find that this pointer link itself that size will turn out to be four bytes which is exactly the same as pointers of any type so pointer themselves have four bytes representation but what they point to could mean a larger group of components I hope this kind of explanation you will find easier to use with your first year students so just to roll back and consolidate to our students we emphasize that a structure definition is not a definition of arrays or variables in the conventional sense but it is a definition of a new type just as the word float or in convey something to the compiler the word structure struct something which is a structure definition also conveys something similar that if and when we have arrays and variables of this new type are declared at that time the storage to be allocated will have to be the sum total of storage of all individual members of that structure and that individual members can be represented for any declared structure variable s by saying s dot member 1 s dot member 2 s dot member 3 etc. Further there is a notion of pointer to this new data type which can be declared in exactly the same fashion as we declare pointers for integer float or whatever the only difference is in normal cases star p or star q would mean the value which is associated with that particular pointer in case of pointers for structure the representation is not a single value the structure is a collection of values as I said collection of members or elements individual member or element is pointed to by an arrow symbol p arrow hostile by the way p arrow hostile is exactly same as s dot hostile because p is pointing to s. So, wherever a pointer is pointing to that structure variables member is what is being meant here this is perhaps a slightly better way than what I have found in many books and explaining the notion of structure data type. Let me also conclude this portion by reminding you of what we said what I said earlier the abstract data type permits us to define something of a new type which did not exist it will have its own behavior pattern in this particular case for example what is the behavior of the structure what you call a student type student info type. So, this structure student info type the behavior is it has roll number it has hostile it has marks it has grade etcetera and that normal operations pertaining to the individual types of elements can be done on these when I declare a variable of that type info type I am bringing into existence a new object which has characteristics not as per those defined in the native type like int or something but characteristics as described by the elements of the structure very very loosely you can say that a structure type definition is like definition of a class and the declaration of individual variables of that structure is equivalent of instantiating objects of that particular class of course the similarity ends here because in object oriented programming languages as many of you would have definitely studied the classes in objects have not only data representation but they also have methods along with in this case there are no methods but the concept is similar the ability to define something new something abstract and to give it meet in terms of the ability to process components of course as per the standard rules with this I will now proceed to discuss the problem we had briefly mentioned yesterday which is this is an additional explanation while referencing while referring to any member of a structure s we use dot s dot member while referring to that member using a structure pointer we use a hyphen followed by a greater than sign so p arrow member I like to call this arrow this slide is nothing but consolidating whatever we just saw in the previous example this is how references are made by a pointer or this is how members of the structure are written structure variables are written at this juncture I would like to hold for some time and go over to the quiz as I promised this is a question asking you how will you teach basic IO to first year students so now while you read this question I request all of you to switch on your clickers to switch on your clickers you should press s t button if it does not show indication of coming alive press reset and then press s t button again please do not just touch the button you press it properly just like you will press a button on the remote of a tv it is exactly like that please press it forcefully similarly later on remember to forcefully press your answers okay I presume all your clickers have started so let us quickly in a less than a minute go through this space it is very simple basically it is not asking for a technical answer as I told you earlier it is asking for your opinion so when you go back or when you when you will teach the basic IO to first year students what will be your preferred approach a to use scan f and print f but to use only simple formats b to use simplified functions through hash defines as was shown in some of the workshop examples so that you use those name function like read num or read int or read etc etc some some other simplified we are doing c to use seen and see out in the initial lectures although seen and see out are part of the object oriented c plus plus language family they are integrated in compilers like gcc and without any loss of generality we can use them and d explain the complete scan f print f functionality and use these from the beginning so these are the four choices a use scan f print f but simple format b use simplified functions as you had seen in some of the workshop examples c to use seen and see out in the initial lectures till you discuss scan f and print f or d explain the complete scan f print f functionality and use these from the beginning now please press your answer your time starts now so within the next two minutes please ponder about it it is by the way I understand that this is not an easy question to answer the some of you might have equal preferences for more than one of these but you are required to do force ranking that means you have to decide a b c or d this is the purpose is merely to get your opinion from you so we have one more minute let me switch on now to so I hope the question is well understood a is use simplified simple format scan f print f b is use specially defined simple functions c is to use seen and see out and d is to use complete functionality of scan f and print f we are approaching the closure of the time let me switch over to the our receiver machine here which will collect your so there are about 30 seconds remaining you have to click on choices a b c d this interface as you see if I had prepared a quiz well in time and had fed the quiz to our software here then a b c and d would have shown you the actual choices which you see on the quiz unfortunately I have switched off the quiz so only the a view people may be able to look at the quiz here but what is coming as a video is actually they can also see this yes anyway but you know the answers so ok the time is up I hope you have pressed hard do not press anything now it would not matter now we will be collecting responses because at the end of the clicker time the response would be collected we have very few centers where responses have come back from maybe either there is a problem in local collection or there is a problem in transferring those values again I will request send the files by f t p is a request to the course coordinators send the request send the assembled files by f t p our primary objective is to ascertain how many clickers are working and if they are not working why they are not working so here we have got 54 plus 25 plus 30 so it barely about 110 responses I am glad to have asked this question because I now know that most of you would prefer to use complete scan f and print f and I can understand why because if your university syllabus requires you to start using it right from day one you hardly have a choice but to explain this properly and start using it I will keep that in mind while preparing the final material for our web portal so that that material could be used directly by you at a later stage I am going to revisit the student database problem that I had briefly explained yesterday I realized that the confusion which was reported by many of the participants was caused by the fact that I simply plunged into explaining a program which itself was ill written what I have done now is I have added explanations of the kind that we saw when I discussed the truck load balancing problem you will agree that such explanations are useful for our students to understand things more clearly in fact learning from this experience joint experience of ours I would suggest that all of you when you prepare your lecture notes or lecture materials before discussing a program in the class it would be worthwhile to add a few transparencies explicitly to describe a the problem that you are solving and b what exactly that program is supposed to do I would consider this preliminary explanation to be as vital as the program itself because in the absence of it there could be non clarity as we saw happening yesterday so here is the problem statement again some students have registered for an elective subject we are given following data for registered students entered into a text file batch input file dot txt so notice there is a clarity here these are not just some arbitrary values what they are is shown these contain name role number and hostel for each student so notice the pattern number of students whose data is given and in each record or each line of the text file the name of the student the role number and the hostel there are six students you can notice that these are arbitrary values because no role number is 2222222 etc in fact if you ask me these are extremely bad example any example of data that we give should not contain arbitrary values if we are describing a problem the data value should pertain to that problem notice for example the data that I gave you for the assignment contained the actual role numbers actual names actual batch course etc of the students registered now you may not have access to the actual names and such thing but if you construct any artificial example of data please construct it in a more realistic fashion what I have constructed here is a very bad way of course I can claim that I borrowed this from another colleague of mine who had used this example previously does not wash because if I am borrowing something it is my responsibility to modify it appropriate in the final version that will go incidentally on the on the portal all of these things will be taken care of but anyway as far as our understanding of the problem is concerned this will do so we proceed ahead by noticing that a batch file batch input file dot txt a file name this is given to us this file contains seven lines of data first line has just the value six and the subsequent lines have each one the name of a student the role number of his or his or her role number and his or her hostel this information for every student is given what exactly do you want to do the teacher says that he will be conducting five different types of evaluations and based on the marks obtained in these five valuations a later grade such as a a a b b b etc will be awarded to each student that is the plan of the teacher what does the teacher want teacher wants to create a file in which to store all the relevant data for students such as role number name hostile marks in each of the five valuations and the final grade of all so that is the desire teacher wants a file in which the records of all the students are mentored and in each record for a student the teacher wants the following information to be recorded namely role number name hostile marks in each of the five valuations the final grade of all we notice now that the data file that was given to us by the teacher contained only name role number and hostile so that is what is clarified in the next paragraph initially the marks and grade information will not be available because it does not exist at the beginning of the semester when student joins your course they have only role number name and hostile information they do not have mark because there are no marks you are not conducted to be examined yet and therefore you also cannot give any grade value grade will be allocated at the allotted at the end of the semester so this is sensible but this is stated here explicitly so that the programmer knows what to write now the programmer understands that he will have to create a file okay in which to store this data but initially so he must make provision to store this much data but the actual data value initially that will be available will be only this now teacher wishes to get a set of programs written by us which will do the following first the program should create a database file which can hold all the relevant information second at the beginning of the semester records for students are created with information available at that point in time so the record may be this big that is created and returned to the desk however the information may be only one portion subsequently when the semester goes on what will happen teacher will conduct evaluations test one test two test three whatever whatever when teacher conducts evaluation the teacher should be able to update the record for that student by inserting the evaluated marks for that test so what do we understand at any point in time the teacher may want us to open the file teacher will supply us one roll number and teacher will supply us a test number saying this I am giving marks for second test and the teacher will supply us marks our responsibility is to go to the file read the record of that roll number and modify the contents of the specific marks for that specific test eventually of course we expect the teacher would also like to insert the grade in the similar fashion but this is what the teacher wants us right now to do additionally the teacher says please ensure that I am able to directly read the data for a student and update that record what is worried about is that if you write a program which will start reading every record from the beginning and then it will find the desired record by comparing the roll number it may take too long notice that for six records or sixty records or six thousand records nothing of that sort is going to happen you can actually read the whole file sequentially compare the given roll number and find out that record but what if you have sixty thousand records what if you have six lakh records let's imagine this is a problem of a higher secondary examination of a state where five six twenty thirty lakh students might be up here take joint attendance examination of IITs where four lakh students appear take AIEE examinations where NITs admit candidates may be I do not know about fifteen lakh students may be up here so if you have those many students and those many marks and if some query comes that update the marks of this particular student you certainly cannot afford to do a sequential search on the disk that is why the problem states the program is required to be able to directly read the rate now it is pointed out who is pointing out so I should have stated it I am a programmer you are the teacher you asked me to do this and I am pointing out to you that boss direct access to a record is possible only if the position of that record relative to the beginning of the file is known we are now talking in the context of positioning a pointer on the disk seeking that position and making a read statement there and we know that such a position this pointer is not like a pointer in our program for integer or something is a file position so this position has to be known we survey the beginning of the file so if I know the record number I know what is the position for example first record will start at the base point so in fact if somebody gives me a roll number I cannot directly access the file as things are stored or as things are planned to be stored so now let us say the teacher agrees to allocate an artificial serial number to each student using which his or her record should be fetched from the database file all that the student teacher will want is this is alright but first when you create a database file you may print out you may print out which will show me serial number for each student then whenever I have to update I will of course give you roll number this that I will also give you that serial number and then ensure that you can read that data directly at that particular record using whatever file statements that you have so this is the explanation it is with this explanation that we now can start writing a program please note the clarifications program should be directly able to read the data for a student and update the record direct access is not possible as things stand with roll number in fact that would be an extension that we should keep in mind teacher agrees to allocate an artificial serial number it is this using this serial number that the record should be fetched directly from the database so now we decide to write two programs this is our decision first program will create the database file and will also store the available information for each registered student at that time that is where we write a program which will create a file and it will insert in that file the records that we have got as a matter of creating file is merely when I open a file for output the file gets created and if I have got the input data limited as it is I should use that to create records in that file we have to remember one thing the input information is only about roll number name and hostel so we will have to artificially assign say zero to marks some star star or some such artificial value to grade and then write the whole record for a student secondly a second program will be returned which will assume that this file has been created the second program is to be executed whenever a teacher wants to update marks for a student so this program will be written to update one record of a given student who will be identified by a unique serial number thirdly we observe that since sensitive data values like marks and grades are involved programs should provide output for verification at each stage where I have changed somebody's mark it should not so happen that my teacher tells me serial number 4 and I type 14 and let's say that the student has got 10 out of 10 so serial number 14 gets 10 out of 10 and serial number 4 still continues to have zero such mistakes are indeed possible so we notice that being sensitive data we should prepare a program which will keep providing proper output for verification since that will be required very often we decide that we will write a function to print data of any student this is wrong I originally suggest thought that I will read and print the data but this function I then decided to write purely as a print function so some calling program main program will pass the information about one student to this printing routine it will just print all the values that's the purpose what have we achieved by the preceding three or four slides one we have defined the problem clearly and which means we have understood the problem here we have made certain assumptions that even though I want to create a direct access file I will not be directly able to access it using roll number because roll numbers could come in any arbitrary order in that in that file so the first record is of one roll number second record may be of low roll number third record may be of higher roll number it is not guaranteed to be sorted so I cannot use roll number in fact even if it were to be sorted it is not very easy to see how given a roll number I can directly go to a particular position in that file so we say we create the notion of an artificial serial number secondly we have articulated what we have thought and understood thirdly we have translated our understanding of the problem into some kind of a programming specification we have said we will write two programs the first program will create database and load it with the initial data that is available the second program will help us update anyone individual students records for one test mark where the test number is specified marks are specified etc.