Transcript for:
Introduction to Programming Basics

Hey everyone, good evening. My name is Vishwadeep and I welcome you all on Unacademy Computer Science channel for unlimited learning. Today we are going to continue the programming basics and more specifically today we are going to learn what is a string and how to access it using the pointer plus we are going to see what is aliasing. And third thing we will be seeing is functions. Let's see how we can go ahead and get along today. Before we start the session, let me introduce myself for those members who don't know about me. My name is Vishwadeep Gauthier and I'm working as a channel leader for this YouTube channel. I work as a plus educator on an academy platform also. And this is my profile. Guys, if you have the target to learn, we have the content for you, the strategies. for you and everything for you so that you can continue your learning. The courses, strategies, machine learning, puzzles, interview preparation and everything you have here on this channel, just explore the playlist and video sections of this channel. You will enjoy a lot. You will learn a lot. Apart from that, you will have lots of sessions on Unacademy, free special classes also. These are absolutely free. You'll have to just create your account on Unacademy learner app or unacademy.com and you'll have to just follow. my profile in GATE ESE category so that you can follow my all the special classes. Previously taken special classes here you can access plus you can take my all the upcoming live free classes also and those classes are so interactive. Polls feature is there. You can download the lectures. There are so many features are there. Enjoy those features and enjoy the learning unlimitedly. If you have the target of GATE exam preparation then you can do that. As of now, you will not understand that your GATE exam preparation should have what and should have not what. For that, you need, of course, some experts who can tell you that you are doing this as wrong and this as correct. You should have some kind of learning in such a way that one time you put efforts for one topic and one learning and after that you will just get the perfect understanding of the topic so that you can solve the tough new. and very very different type of questions in gate exam just because a small mistake answer is wrong another small mistake in another topic answer is wrong and such kind of multiple mistakes can make your result from 60 marks to just 40 marks or lesser than that also. So how exactly you can have such preparation which is error free which is mistake free and which is so efficient we provide you on unacademy plus. You'll be getting live classes, weekly tests, daily practice problems, structured courses, unlimited access of the different, different batches, plus quizzes every weekend between the courses. And you'll be having learning in such a way that you can enjoy the best learning with the best educators, guidance of educator along with the courses. If you want that, sir, we just want to consume the topics. Nothing else we want. We want somebody to work for us as a personal basis and we will just prepare and understand and practice. Nothing else we will do. Then you should go for iconic subscription. In iconic subscription, you will get all the benefits of plus and a personal coach, a personal coach who will be working on you and your preparation and your performance on one on one basis so that the personal coach can prepare your preparation strategy. customize the study plan, can track your performance, you will get a study booster session, personalized test analysis and everything personally you will be getting which can help you concentrating on your preparation rather than just thinking what to do, what next to do nothing else. Nothing else you'll have to think. Plus, you'll be getting extra doubt clearing educators. This is, of course, very beneficial when you have lots of doubts. And preparation study material also will be there. So, you have multiple durations plan plus an iconic. Whichever duration plan you want to select, select. And ultimately, use this code BD10. So that you can get 10% instant discount plus my personal guidance plus my team's support and an offer. Offer is if you take 12 months subscription, 3 months extra you'll be getting. Why? This will be needed just because just now whoever has passed gate 22, those fellas are now preparing for interviews, for admission in IITs and those fellas are preparing for PGEE type exam of IIIT Bangalore etc. Now, how they will prepare after GATE exam is completed? They will either prepare from free sources or they'll prepare from PLUS. If you will be preparing from PLUS, of course, it will be benefited. So for next two, three months, if you will have extra extended subscription, of course, it will help you preparing for other thing. If you are getting 57 marks, let's say 61, 62 marks. With that 62 marks, you can enter into IASC after cracking an interview. You can enter into really top college. any top college with some interview. For that, you'll have to prepare your courses which you have learned for the gate preparation and that is what these particular sessions will be needed for. So 24 plus 4 months subscription, you'll be getting extra subscription added into your account immediately and these offers are only up to 25th of Feb. New batches also started for gate 23 droppers, gate 24 and gate 23 regular students. So you can join these batches. You can see Top educators of country are going to teach you the best courses possible. Are you studying from an academy? Studying or teaching? Sab log jaante hai aapko. Achha, yaar mujhe nahi pata hai ki sab log jaante hai toh kam se kam apne aapko introduce karna sahi rehta hai. Aapko bhi kahi nahi kahi pehli baar pata chala hoga aise hi session se ki mai kaun hoon. Toh aise bohot saare log jo mujhe dekhte hai, unhe samajh me aajata hai ki mai kaun hoon. Thank you for teaching OS and COA. That's it. I'm teaching data structure also and most probably DBMS also this year. Chalo, start kare. This is the regular question. Every time same to same question, same to same slide. Every time asking same question. And you'll have to answer. Ready? Session ko like kar dena. Agar pasand aaye, maza aaye to. And then let's go. Let's go, let's go, let's go. First of all, the session will be starting with the string. What is a string? First of all, Let me talk about arrays. Yesterday, I have explained about array. Yes or no? You understood? Did you understand? Did you understand the array? Tell me quickly. Everything about your array, you understood? Okay, one thing, I just want to talk about arrays. How to initialize an array? Initialization of array means... In an array, you want to give some initial values. So to initialize an array, what you'll have to write is like this. Let's say you have an integer array of size 5. You want to initialize it, then equal to, now multiple values are there in the array. You cannot write single value, you'll have to write multiple values. Why? Array has multiple values. So what you'll have to write? You'll have to write those 5 values in the curly braces and semicolon. So let's say if you are writing 2, 6, 9, 5 and 4, what happens? An array is created on the index 0, 1, 2, 3, 4. These will be the indexes you will be having in the array. 5 size array index starts from 0. Now what happens? The first element will be 2. Second element index number 1 will have element 6, 9, 5. and 4. So if you access a of 2 you will access value 9 or this particular value. So this is what the array initialization is. So if sir you are saying that integer array can be initialized then character array also can be initialized. Yes. If you are saying sir that you can initialize integer array then you can initialize character array also. Absolutely. Instead of integer type character integer and value integer instead of that you make value character that's it let's see so if you have a character type array let's say ch Array size is 5. Now, you will have to have 5 characters. Okay. If you don't know about this, then let me tell you one thing, dear students. Character value will be represented always enclosed in the single quote. If you want to take any character value, like this integer value was 269. If you want to write character value like this, So let's write it in single quote. Let's write it in single quote. Okay, so what you will write? You will write first let's say I have written H E L L O. So five characters I have written. Five characters I have written. What happens? An array will be created. Zero, one, two, three, four. So I have written H E L O. So what you will write? An array will be created. These will be the indexes. First index is capital H. Next index value is E. Next is L. Next is L. Next is O. Aise aapka ye array ban jayega. Batao samaj mein aayi baat yes ki no? Did you understand this yes or no? Okay. Now one more thing is there. If you are initializing any array. Let's say like this way. And. Even if you don't give the size, there will not be any error. If you don't give the size, there will not be any error. Why there will not be any error? Just because you are initializing. So when you initialize the array and if you don't provide the size here, what your system will do? Your system will automatically take the default size. Default size means how many elements you are initializing? Five. automatically size 5 will be taken. How many characters here? 5 automatically CH will be taken as size 5. Like what happens is, you go to watch a movie. Right? There is a lot of crowd in the movie. Too much rush is there. So whenever you reach to the counter, the person will ask how many members, how many tickets. You will say 5 tickets and the person will give 5 tickets. But let's say the theater is fully open. Nobody is there. Everybody and nobody is there. You are going. Nobody is there in the queue, etc. You are going and five members. The person is seeing giving you directly five tickets. Yell EJ sir five tickets. Why? Just because nobody is there in the theater at all. No any crowd. The person can see you guys are five people. You will need five tickets automatically. What happens in this case? What happens in this case? automatically size 5 will be taken. Now you will say, sir, this will be very hectic. This is so hectic to write such kind of one, one, one, one single character and single quote. Who will write so many single quotes? Five characters and single quote. To write means type it down. Of course, it's a hectic process. Not so handy process. So instead of that, they have given another option. They have given another option. You can define your array similarly like this. Instead of writing this each single character separated by comma and enclosed in single character or single quote, you can write every single character along in double quote. But There will be a huge huge difference from here to here. Bahut bada difference a jayega yaha se yaha me. Or what will be that difference? The difference will be this is a normal character array and this will become string. Aisa kya kar diya sir? The thing is when you are making like this way a character array, fine. I understand that. index number 0 taken as capital H implicitly first next one is E index number 1 is E index number 2 is L index number 3 is L index number 4 is O but apart from that one more character will be added implicitly here one more character will be added implicitly and its name is null character. What is the name? Null character. And that null character will be represented by backslash 0. This is a single character only backslash 0. So what happens in this case when you make this a null character automatically will be added in your character set character array. And this time it will not be 5. It will be 6 as the actual size of the array taken. 5 index last one. So the implicit size of the array, how much will we take? Size 6. Why? 5 for the character, 1 for the null character. Now, why did we add this null character? We added the null character so that it can denote that the string has started from here and ended here. The null character is taken just because to inform, to specify to the system that our string will end here. Our string has ended here. Because when we read the string, whenever we read the string, at that time, sorry, what happens? The string will be read by a single statement. We put percentage s and read the string. In the first one, the compiler will not insert null. It will not, of course. Because you have given single single character. It will do here. And this becomes string. Because you are having null character added in the end. Okay. Did you understand? Now if I say this same thing. If I am saying the same thing. Array name stores what? You remember yesterday I told you. Array name is a pointer. Only single name array name only is a pointer which stores the base address of the array. Remember that the same thing, same thing, same thing, same thing we can do. What? Same thing we can do. And that is what? Like this. So either you will make a string like that way, this way. Or you will make it like that. Did you understand? Why we are doing this? You know what happens. You know what happens. First of all, H. Then E. Then L. Then O. Then NULL CHARACTER. This will be a string created. What happens? This is a character array created. There will be a pointer p. That particular pointer p will store the address of the base address here. Base address. A pointer p will store the base address here. You can make string like this way. You can make string like that. So the first element's address will be stored in pointer p here in ch here. Simple. We will not go into more detail, size, etc. etc. string, string, this, that, just because we don't need it for data structure purpose. Okay, for data structure purpose, we don't need much. We don't need it much. Okay, so we'll just understand one thing that, Sir, can we create a gate by watching an academy lecture which is available on YouTube? Ankit Singh ji, yes, you can do it. Now, this... It depends on you. It is dependent totally on you that how good you are in problem solving and finding out that this is the material which I want to learn and this is the material which I want to go for. If you can understand by yourself, yes, you can do that. So we will not do much of these string, etc. We don't need much of this. But just we wanted to understand that what is a string. Now if... You want to access entire string in a single statement. Let's say you want to print that complete string which is pointed by P. What will you write? Tell me the statement quickly. If you want to print that string which is starting from P pointer and is starting. This whole string. So what will you write? Tell me quickly. What will be the printf statement you will write? A single statement. See, usually to access entire character array or any array. you will have to write a loop that first you will access index 0 then 1 then 2 then 3 then 4 then 5. Usually you write a loop actually. You write a loop to access the entire array. But here you don't have to write the loop. If you are accessing the string, you will have to write a single statement and you can print entire string. How? Tell me quickly, how will you write? What will be the statement? Printf. What will I write in front of printf? Tell me quickly. Either you can use some functions or you can utilize a character specifier, string specifier, format specifier, percentage S. What you will write? Percentage S comma P. That's it. Starting from address P, there is a string printed. When you will do this. String will be printed till what time? Till what? Until you get the very first backslash 0. Till you don't get the first backslash 0, you will print the entire string. Starting from P pointer, you will print the entire string. So what will you do? You will print hello here. Did you understand? Let's go. Itna bhot hai string ke liye, data structure ke liye. Mujhe lagta nahi ki issse zyada kuch use hoga. Next thing we will be discussing is aliasing. And what is aliasing? Achha. Why I am laughing? Just because I remember my childhood also. You will remember your college time and etc. etc. also. Everybody, whoever is listening current lecture is having another second name given by your friends. Yes, and that is so secret name. Only your friends are calling you with that name. Having? Is there any such name? Everyone has one such name that your friends have given you separately. Isn't it? The nickname that your friends give you is very special. Isn't there any such name? Yes or no? Tell me. Yes. Yes. Is there any? Yes. happens it like that way yes so in the program also when you write the programs you might provide some identifier multiple names you may specifier an identifier with multiple names right happens same thing happens let's say there is a variable you want to give another name to that variable See what happens when you go for more practical results. When you go for more practical results or more practical implementations, one thing can be known as some name for you, but some other name for somebody else. Like it's very simple thing. Let's say you go to a shop. You are purchasing something. So from that shop, From that shop, on your perspective, you are buying something. Yes, so for your perspective, that item is that item which you are purchasing. But for the perspective of shopkeeper, the same item is sale item or selling item. So, ek item aap ke liye hai purchase item, that fellow is having that as sale item. So, now what happens? If we have two different programs, one for customer, one for seller, then definitely those two programs should refer these single item into different names. Why? Just because practicality I'll have to understand. So when you implement multiple or implement different, different kind of, you know, practical scenarios, what happens? What happens? You just provide a variable name. In one function, name of a variable or in one particular program, a variable name is this. Another program, another function, the variable, same variable is having some other name. Like I am having my name with you all is Vishwadeep sir. Fine, but for my friends, my name is VD. Same person, yes, but two different places. Name is two different thing. Right? So what happens? What happens that if you want to provide or if you want to give multiple names to the same variable that is called as aliasing. In English word also, you say, right, Shah Rukh Khan alias as the King Khan or Badshah of the Bollywood. You call it like that way? Yes. Sachin Tendulkar alias Master Blaster. It happens. Yes. How you give the aliasing or how you make the aliasing. It's very simple thing. There is a very specific syntax for it. Let's say I have made an integer variable a with value 5. I have defined an integer variable a with value 5. So in the RAM memory, a variable is created with value a, name a value 5. Cool. Definitely some base address should also be there. Let's say base address is 200 for this integer value in the memory. I want to give the same variable another name. I want to give this variable another name. What will we do? Let's give another name in this way. Integer m%x is equal to a. This is a very specific syntax boss. This is a very specific syntax. Right? This is how we write syntax. The new name you want to write, left side and right side variable name. Okay? If you write like this way, another variable created and the name of the variable, no. No any new variable created. Only another reference to that same variable a is created. Another name to that same variable a is created. If you will write here X plus plus and then you write A plus plus, you will try to print a value of A or in fact, you will try to print value of X. What happens to the values? A value 5. X is also 5. Same to same. You will say COA I want to study from Vishwadeep sir or COA I want to study from VD sir. Same to same thing just because two different names but person is same to same. So what happens if you are printing value of A, A is increased and increased. It becomes 6 and then 7. It will print 7. It will print 7. This is aliasing. A or X just two different names of the same memory location, same variable. That is called as aliasing. Like the session. Sorry. Is this aliasing clear? Clear. Now, why is this aliasing used? When you learn the functions, in the functions, when you call a function, you can have three different possibilities. One, you call by value. Second, you call by reference through aliasing. And third, you call by address and catch it in the pointer. I am teaching you this aliasing because there was a question in GATE in recursion and it was using this aliasing concept. So this aliasing concept is present in some of the compilers. In some of the compilers only it is present. In fact, mostly C++ compiler is having this one. But We are learning it just because there was a question in gate. Right? Okay. Let's go. Next thing is functions. But this we will do tomorrow. Why? Just because today I am having some other work. I will have to close this particular session little early. So this function we will do tomorrow. Functions we will learn tomorrow and tomorrow that will be the end. So tomorrow we will finish this basics. And after that, tomorrow is the last class. We will discuss the functions. And after that, we will start data structure. As soon as we can do that. We will start data structure. Okay. So see programming basics tomorrow will be the last class. We'll talk about functions and its calling and how you call, what is the meaning of function call, how that function call impact the different, different, you know, programming paradism. And then after that, we will start the data structure immediately. Not tomorrow, of course, but in the next session, whenever it will be possible. I will announce in a special session that how we can start data structure from where, when, and what will be the timing, etc. So data structure will be starting so that whatever these basics we have learned, using those basics, we can continue that data structure and we can enjoy learning and understanding just because you won't have any problem of understanding any kind of algorithm or C programming basics because of that. So timing and all for that, I will come live for one day and we'll discuss with you all that these are the timing available at what time we should have it. And based on that, we will announce that. Data structure will start from this date and this is the timing, etc. Do we need to learn C++ also? No. For gate? No. Okay, fine. So data structure we will start once tomorrow this particular class is over. After that, as soon as possible, we will try to start it so that you guys can have the kickstart of the gate preparation. Okay. How to get internship? For that, you need to prove that you have skill set. You will have to prove that you have skill set through the competitive programming and different competitions these companies are conducting. Okay. Anybody wants to have the class PDFs of our previous lectures? Want to have the links of our lectures? and want to know what are the next future plans we are going to have offers etc etc from the team then you just join this telegram channel anyone here whoever is preparing for gate very seriously and want to join unacademy plus or iconic join it very soon so that you start the next class next course very very efficiently and you That particular thing on plus or iconic, whichever subscription you will take, use this code VDeep10 so that you get 10% instant discount plus my personal guidance, plus my team support, plus this offer. What is the offer? If you take 12 months subscription, three months extra will be added into your profile. And if you take subscription for 24 months, then you will get four months extra added into your profile. And this offer is only up to 25th of Feb, only two days. now onward. So take the subscription and enjoy your best quality learning. A new batch is started from today. Yes, my dear friend, new batch started from today. Batch F for Ascend and Evolve. For Gate 23 and 24, new batches started today. If you want to take subscription for an Academy Plus with more discount, you have this offer. Offer is what? You just participate for gate combat gate combat is our scholarship test this sunday 11 a.m you are going to have for 60 minutes you will be having 20 questions to solve if you can solve these questions quickly and if you can get the rank in top then you will be getting up to 100 discount how to enroll for this within the video's description section link is given or in the web browser you just search in the search engine on academy gate combat you will get a link as soon as you get the link use the code vdeep10 to unlock this scholarship test remember sunday 11 am you are going to have this test plus apart from the test and scholarship in that test if you perform well or even if you don't perform well but if you are participating you will stand a chance to win a macbook Apple iPad, Samsung phone, Samsung watch and Amazon vouchers. So look at this. If you want to win these prizes, then participate. Just because 500 lucky participants will win. these gift vouchers okay if you like the video enjoyed the video please like the session subscribe the channel turn on the notification share the details of this particular video and all the channel content to all of your friends junior senior everywhere you can of course pay us back with your small efforts so that so many people who are striving who are actually having a craving to have the quality learning can contact or can connect with us. Thank you so much for joining. Once again, happy learning. See you in the next session. Bye-bye.