 Hello friends, I am Sanjay Gupta. I welcome you on Sanjay Gupta Tech School. So in this video, I am going to explain how you can print table of a number with the help of C programming. So let's take a example. So let's say number is 5 and we want to print table of this number, right? So I want to print table like this 5, 10, 15, 20 and so on and last digit will be 15, right? So this is one example. So first I will tell you how we can print this with the help of C program. Then I will convert that program so that we can print output like this, right? So this will be the number whose table we want to print. These are the terms with which we need to multiply it like 5 into 1, 5, 5 into 2 and so this we study in our first or second class or maybe previous to that. So it is written like that and its outcome is after equals to sign so 5, 10, 15 and so on. So we need to take a number. Number can be anything. For example, I took 5 but it can be anything. So you need to write a common program so that whatever number is provided by the user that will be printed in form of table, right? So now I am going to start writing a program in C programming. So focus on that. So inside main, I am going to use these variables. So I have two variables declared first is n, second is i. And I am going to use to receive input from the user and I am going to use to iterate the loop so that we can print table in this format. So now after this variable declaration, I am going to use printf and enter a number. So this message will be displayed on output screen. Then we need to write scanf so that we can receive the input from the user. So input will be stored inside n variable. So n is having a number whose table we want to print now. So now after this scanf we need to implement the loop. So to implement the loop, we need to identify three parts. First is initialization, second is termination condition and third is incremental addition. So now identify in each table that is related to a particular number, we need to print only 10 terms. So if table is of 5, we need to print 10 numbers. If table is of 5, let's say table is related to number 7. So again for 7, we need to print 10 digits. So it means every time a loop will repeat 10 times. So this way we can identify its initial value, it will be 1 and the loop will repeat 10 times. So its condition will be i rather than equals to 10. And inside this loop, sorry for this increment part, I am using i++ so that it will be always incremented by 1. So inside this loop, we need to put the logic so that these terms will be printed on the output screen. So you can do two things. First, you can directly print the calculated result or you can store that calculated result in a variable and then you can print it. I am going to use both the things. So first I am going to print it directly. So see it carefully. Inside this small loop, I am using this print up statement which will print a digit in form of a person D. That is a diesel and the outcome of that person D will be n multiplied by i. So our input n is 5. So n will become fixed always. If it is 5, so it will remain 5 throughout the program. If it is 7, so it will remain 7 throughout the program. So every time i will be multiplied with 5 for any other number. Now see first time i is 1. So this will be multiplied with 1. So it will print 5. Then i++ i will become 2. So next time 5 will be multiplied with 2. So it will print 10 in place of this. Then i++ i will become 3. So next time 5 will multiply with 3. So this way 5 will be multiplied with 1 to 10 each digits and this outcome will be printed. Now suppose n is 7. So at this place we need to put 7 and it will be multiplied with 1, 10, 2, then 3 and so on. So the table of 7 will be printed. Now there is another way. You can use one more variable let's say s. And before print f we can use this n multiplied by i and semicolon. And in place of n into i we can put s. So what we are doing? We are first calculating n into i. We are assigning that into s and then we are putting s here. But what is the drawback? We are unnecessary using a variable that is occupying the pattern. So always try to use less variables in your program so that you get same memory. So this is not a best practice. You need to remove this variable and here use this thing. So this way I hope you understood how we can print this. Now you might be thinking how we can print this format with the help of this formula. So now I am going to modify this printf statement so that you can understand how this will be printed. So I erase that printf. Now I am going to implement new printf statement. So here you can see 3 digits I need to print. So this is 5 always or you can say n. So I have to print n here. Then in place of 1, 2, 3 I can place value of i and here I can place value of n multiplied by i. So now I am going to print this. So you can just print this statement inside printf. So I am going to do that. So printf backslash n. So first I need to print 5. So I am putting %d because %d will be replaced with a value of variable. Then I am putting multiplied sign that you can type directly to the keyboard. It can be either x or it can be as far as whatever you want. Then again %d because we want to print value of i then equals to and again %d sign. So 3 %d's are available and I am closing this double tools and I am putting a formula. So now I need to print n then i and then n into i and then close this printf with parameter and sign. So now see carefully this n will be printed here. This i will be printed here and this n into n its value will be printed here. So let's say n is 7 and we need to print table of 7. So i is 1, condition is 2. So control will move to this statement. So n is 7. So 7 will be printed here. So it will print 7 then it will print multiplied then i value it is 1 then equals to then n into i. So 7 into 1 so it will print 7 then i plus plus i will become 2. So next time n is 7 then i became 2 and its outcome is printed through this n into i. So n is 7 i is 2 so it will print 14. So this way it will be 10 times and this kind of format will be printed in front of you. So implement this program in your compiler. Maybe you are using transparency or daisly clusters or any other. So implement this and you can print both scenarios with the help of this explanation that I explained in this video. So I hope you understood whatever I explained in this video. If you want to watch more programming related videos you can open my channel go to playlist. So there are various programming related playlist are available. So I uploaded more than 1000 videos. So you can watch programming related videos. So I uploaded C, C++, Java, Python, data structure and Salesforce related videos. So do follow my YouTube channel because it contains a variety of videos related to programming and don't feel afraid of programming because it is very easy. And if you have any query you can email me you can text me on my WhatsApp number so that you can discuss the programming. So I hope you understood whatever I explained in this video. Thank you for watching this video.