 Hello, and welcome to NPTEL course on an introduction to programming through C++. I am Abhiram Ranade and in this lecture I am going to talk about medium size programs. So here is the goal of this lecture and the next. So we are going to develop some medium size programs. So this will require us to put together the different things that we have learned and in the process we will also get some ideas about how medium sized course should be organized. And along with that we will also see different kinds of computer applications. The first medium size program that we are going to talk about will build upon the marks display sequence of programs we have talked about. So this is going to be an enhanced version of it. So in this case the program is expected to read data from two files. The first file which I am going to call rn file contains lines each having the following. So first on each line there is the roll number and then there is the name of the student with the given roll number. And for simplicity we are going to assume that the name does not contain any spaces but in real life we would have to handle names with spaces as well but we are not going to bring that in right now. Then there is another file called the rsm file and this contains lines and each of these lines will begin with a roll number then there will be a subject code and again that subject code will not contain spaces that is our assumption. And following that there will be a number which will denote the marks obtained by the student whose roll number is given on that line in the subject whose code is given on the line. So this is the data that our program will read. You will note that I have chosen the names rn file and rsm file with some purpose. So rn file is called rn file because it has two fields roll number and name and so the first letters of these are r and m so we call all that data as residing in the rn file. And similarly roll number subject marks whose first letters are rs and m so that data will constitute the rsm file. Now our program must read these two files and load up the data that is in these files and after that the program is expected to respond to commands from the keyboard. So what are these commands? Well the commands are the following until and the commands have to be executed until the user types a command to shut down the program. So until the user types the command which requires shutdown the program will have to execute all the other commands that the user types. So one command could be that look tell me the marks obtained by this given student in this given subject. So the student may specify the roll number or maybe the student will specify the name but we want the marks of the given subject to be printed out. Then we might want the rank of a given student to be printed. Now what is the rank? Well for the rank we are going to calculate the average marks obtained by the student in all the subjects that the student has taken. So the student who has the highest average marks will have rank 1, the student who has the second highest average marks will have rank 2 and so on. So let me make a few remarks. So first of all it is clear that this is harder than the max display programs we have, problems we have studied earlier. However by no means is this the hardest possible version. If you look at what might be needed in real life things are a lot more complicated. So for example you may have students from many years. So they may have two students from different years may have the same name or for that matter two students for the same year might have the same name. And of course we already said that students names may have spaces inside them. Then there could be subjects of different types. So for example there could be compulsory subjects, there could be elective subjects and we may ask give me the rank in the compulsory subjects or give me a rank in the elective subjects. And yeah so there could be more complex queries and if we are doing this in a program that is deployed then how fast we respond is going to be important. So if this is a part of an information system, so a student comes up or a teacher comes up or whoever comes up to your terminal and types in the command that person expects to get the response reasonably fast if at all possible. And therefore speed is going to be important if the program is deployed for actual use. So we are not going to be looking at all of these issues but we will maybe touch upon some a little bit. And this is a really important issue which we will definitely not touch upon. The data may be too large to fit in the main memory of your computer. So if you have a huge university with lots of students over lots of years, lots of subjects then the data can be large and the data may not fit in the memory. And then you would have to worry about if the command requires data from a certain portion of the disk how do you get it. But these are issues that we are not going to deal with. Before we go on to our program and our program is simple as compared to what might be needed in real life though it is complicated, more complicated than what we have seen so far. So I just want to point out that there are many choices in how we might implement the program that we have set ourselves up for. So there could be a very simple algorithm and this might be based on how you would naively solve the problem manually. So we will try and mimic what you might do if you had these files say as notebooks and somebody came to you and asked the questions. But of course even here there is an issue if you are clever then you may solve the problem in one way and if you are not so clever you may solve the problem in another way. So we will look at some simple ideas first. Then once we understand what exactly we need to do we can try to be cleverer and then we will think about and we will talk a little bit about how we can speed up the program using say sorting and binary search which we have already studied and we have already seen that binary search can be much faster than going through data in a linear fashion. And then we will talk about faster and elegant methods which are based on maps. So here is an outline of this lecture. So we will begin by designing a format for the commands. We have discussed what kinds of commands we might need but now we will specifically design what exactly is the user is required to type in order to issue a certain command. So after that we will look at a program based on somewhat naive manual algorithm. We will look at its code and then we will discuss possible improvements and then we will design more sophisticated programs. We will also look at their code. So that brings us to the end of this segment. So let me just review what we have discussed. So we have discussed the new marks display problem and next we are going to talk about the program inspired by a manual algorithm but before that we will take a quick break.