 Hello everyone, my name is Andrew Thangaraj and I am one of the co-ordinators for NPTEL at IIT Madras. In this short video, I am going to describe to you how to answer programming questions in the certification exam. So, the software that has been developed by TCS has some unique and interesting features for you to be able to enter your code and also do some limited debugging based on public test case input. I want to show you that. The main reason is that you might be used to using an integrated development environment with an inbuilt debugger. While the certification exams portal is not as powerful as integrated development environment, it has all the rudimentary pieces necessary to be able to type in your code and debug it and submit it for successful completion. So, I want to take a few minutes of your time and record this short video to show you how to do this. Let us get started. So, the first screen that you will see when you come to the exam hall is this place where you have to enter your application number and your password. So, let us go ahead and do that. So, this is a dummy candidate for whom I am entering. You will be of course entering for your own candidate name here. So, once I do that, there is some basic information I have to look at and say I confirm. Once I confirm the exam software tells me that my exam time has started and there are some instructions here which you might want to read, but I am going to skip. So, this is the next page and you can see that there are some instructions that are specific to the programming examination. So, you might see the number of questions that are going to be asked and the marks for each question. So, you might want to read this in some detail. After you are done reading this, you can first agree to the conditions which is here. I have clicked on understood understanding all the terms and conditions and then you are ready to click on I am ready to begin. So, if you do that your exam will start. So, let us click on that and my exam has started and you can see on the top right there, there is the time left indication. So, that tells you how much time is left for your exam. So, you might want to keep an eye on that so that you are within time and a typical question will look like this. So, it has some two or three parts in the screen. The first part to the left is the description of the exam question itself. So, the question number is there. There is some text here on the left side which describes the question. The question tells you for instance here that given a positive integer as input, check whether it is a palindrome or not. So, it tells you what the input to the program will be and what is the output that is expected. And then on the right here, you have a part where you have to type in your actual program. So, it says here type your code here in C language. So, you have to do that in this part, you have to type in your question in C. Once you have typed in your question, there are two options down on the left. The first option is to compile and the next option is to submit the code which will actually execute the code and show you some partial results. So, this is the first question. There are as you can see four questions, I am sorry, there are four questions in this test. So, let us see, you might want to for instance see the other questions also if you like. So, if you click on next, you go to the next question. This is the second question. And once again you see the same kind of structure here. There is the question text on the top left and there is an editor window where you have to type in your code. And then there are these two buttons, one for compile, one for submit. So, I am going to take this program here and start to type some code to show you how this thing is done. So, you can read the question if you like, it says given the coefficients of a polynomial, you have to find the coefficients of the derivative. So, that is the question. It is quite a simple thing to do. So, let us go down and read through the question. So, typically you will see there is this scroll bars. So, this question has a vertical score scroll bar, you have to scroll down and see all the text of the question. So, some questions may also have a horizontal scroll bar. You might have to scroll horizontally depending on how much text is there, you might have to do that. So, once you do that, you will read the question. So, the first task is to read the question, make sure you read and understand the question really, really well, and then you can start typing it. So, I am going to start typing the code here. So, let us type the code now. So, I am beginning to type and while you are typing, you might want to observe a couple of things. So, for instance, if I type some line like this, let us say in n comma i comma j. So, let us say I type this and one of the unique, one of the things about this portal is this programming interface. I am sorry, I keep saying portal. What I mean really is programming interface. What I mean by this, one of the limitations of this programming interface is you cannot do cut and paste. So, you cannot really select any text and copy and paste. You cannot select a bunch of lines and delete. So, you cannot do that. I know it is a bit frustrating sometimes, but many of our programs are small. So, hopefully your editing is not so intense. So, I have done that and then I know my input is first line of my input is the degree of the polynomial. So, take care and remember one thing when typically you might have been taught before any scanf, you have to print something, printf, enter a number and then you enter a scanf. In our programming questions, you should not print anything unnecessary. Only thing you have to print is the answer. Whatever is asked in the question to be printed, you print. Other things you do not print at all. Just use a scanf, that is good enough. So, you get in the number and then you can do a return 0 if you like. So, you can see what I have done in this program. So, let us say this code has been typed in. Let us see what has been done here. I am reading the degree and then I am reading all the, I am declaring the size for the coefficients and allocating a begin of array and then I start reading one after the other. Once I read the ith coefficient, I simply printf i times a of i. So, that is a simple logic for the derivative. So, now that I have typed in the code, you might want to do either compile or submit code. I would just suggest submit code. So, when you press submit code, it also does the compilation as a part of it and why do you want to compile separately? You might as well do submit code. So, even though the compile button is there, I would just suggest press submit code. So, I am going to press submit code now. Let us do that. So, immediately there is a display saying what is happening. It says code execution is in progress. Meanwhile, you can attempt the next question. Revisit to check the execution status. So, typically when you do the submit code, you can expect to get the result in about 15 to 30 seconds. So, you might wonder in this day and age of advanced computation capabilities, why such a small program takes such a long time to compile and execute etc. So, it is not unheard of. So, there is a reason for it. The reason is execution does not happen immediately. Things go to the server and it comes back etc. Then most of it is because of security concerns. So, we are doing an exam and we wanted to be foolproof against security, I mean any violation of any kind. So, to keep the security, we have to have an architecture like that. So, that is done. But when I submitted the code, there was an error. It says an error occurred while executing the code time limit exceeded. So, this time limit exceeded basically means some runtime error happened and things did not work correctly. So, this could be for a variety of reasons. I do not know what reason it could be. So, let us look at it once again. So, this is the reason. So, you can see go in and see. I want to run this loop from n to 0, but then I am doing i++ which is a very bad idea. So, I should be doing i-minus. So, let us do that. So, if we change this hopefully it is fixed and let us submit code again and see what happens. Once again code execution is in progress and this is going to be a little bit frustrating to you. Let me apologize in advance for it. We are trying to reduce that, but it is not going to be that easy as it turns out to fit into a secure framework of that we have right now. So, the compilation will take time everybody you every time you submit code. So, please be patient and be ready for this delay. There you go. Execution was successful and your code has passed 10 out of 10 test cases. So, it says test as so I guess there is a spelling mistake here. This is going to be changed hopefully soon it says your code has passed 10 out of 10 test cases says execution is successful and it displays five test cases. There were five test cases for which the inputs as well as the outputs are shown and then there is a result which says pass, pass, pass, pass, pass. Is it okay? So, but then where are the other five test cases because it says 10 out of 10 test cases my code passed only five test cases are shown here. So, it turns out these five test cases are the public test cases and they are given here to help you debug. Help you debug your code make sure everything is okay. The remaining five are private test cases on which the actual scoring will happen and these private test cases are not revealed to you. They are not shown to you they are used only for the scoring. Only the public test cases are shown to you so that you can use them for debugging. So, in case this one of the public test cases fail you can go in and look at what happened. So, right now the inputs are given expected output is given and the result it says is pass which means they expected output match the actual output of the program. Now this is not enough for debugging. For debugging what you really want is you want to see the actual output that was obtained when this code was run. Can you do that? Yes, it turns out you can do it and this is very important. Notice what I am going to do. I am going to take my cursor and hover around this pass. I am hovering my cursor around this pass and what this shows when I hover around the pass so of course I am hovering again it comes up. When you hover you see the actual obtained output from your code. You see a new box comes up when I go over the pass and you can see the obtained output and you can see that is 2104 and that matched with my expected output. Now if I hover around the second pass once again you see the obtained output is 61 it matched with the expected output. So now using this method I have the input as well as the output that I got from the actual program. Both of them are seen here and in a rudimentary way you can use this for debugging. Once again it is not as good as a IDE with an inbuilt debugger but one can use this in a rudimentary way for debugging. For instance in case let us say something was wrong here. I do not know what was happening something went wrong it did not work out maybe I want to print some intermediate result. Maybe I do not want to print the actual result I want to print the intermediate result. So in that case what will happen first of all is since you are printing some intermediate results and remember our programming tests are evaluated by test cases. So you should not print anything that is not needed. You should only print what is needed. If you print anything that is not needed your test cases are going to fail but nevertheless you can print some intermediate values and check what is happening. Just to see whether something is wrong or not. In all cases this may not work but in at least some limited cases you will get some feedback on what is happening. So maybe here I will print f i. So if I do this so maybe in my loop I want to see how i is getting incremented. Maybe there was some bug I do not know what is happening I want to debug that. So for that one useful information might be to see how i is getting incremented. So when this happens yeah so let everything else remain the same let us just run this code with one additional print of statement maybe which I can use for debugging. So let us submit code again. Again you have to wait for a little while to see what happens. So you see immediately all my results are fail. Of course I expected that because I was typing something which really did not need to be typed in. So it is good to my results are going to fail but I can use this for debugging. How do I do that? You can go and look at the result. So you see that everything that I printed is actually showing up in obtained output. What am I printing? I am printing the value of i before I print i into a of i. So you see here that first output I get is 3 followed by 21. Then I get 2 followed by 0. Then I get 1 followed by 4. Then I get a 0. So you can see the value of i is getting printed here. So in this way you can see some intermediate outputs from your program in the obtained output space. So you come here and hover around this fail. You will see with your mouse if you hover around this fail you will see the entire obtained output. Everything that you used printf for in your program will get shown here. So in this way you can do some limited debugging. Now once again I have to tell you this is not as great as having an integrated debugger but it is possible to see the actual output of the code and do some limited debugging. And since the programs are not that big one can use this. So that was a short video on how to type in your code. Some of the unusual things involved in the typing in of your code and then how to submit the code for execution and how to interpret your results and then how to modify your code to print some intermediate values and how to see the obtained output, the actual output of your printf statements and this is useful in debugging. So once you do all this you should be able to submit it and you should be able to see all the results and see how many public test cases pass, how many private test cases pass, how many marks you will get in your code. So you can actually do a complete programming question answer similar to the way that you would have done in your course portal or in other places. So I hope this video helps you in understanding the exam environment for programming and hopefully you can use this for doing some debugging and submitting your code correctly and getting full marks for all the best.