0:00 C programming language is considered as the mother of all programming languages present in the software industry. Anywhere you go, C programming language is the most basic and very important aspect which the recruiters are looking for. Hi, this is John from programming knowledge and welcome to this video tutorial series where you will learn how to go about programming in C language. In this tutorial, we will discuss mostly the important parts of C programming language. So these are the topics that are included in our C programming language tutorial series. So firstly we're going to discuss the history of C and then to be followed by the installation of C. So I'm going to guide you through all the steps needed to start about programming in C programming language to be followed by data types and variables. Of course, we're going to discuss the importance of data types and variables in C and to be followed by C tokens to be followed by pre-processor directives and of course we're going to 1:02 learn the how to write our first program in C programming language and of course to be followed by control structures. So as we all know if you are coming from other programming language you already have knowledge on control structures. So we're going to discuss that right here. And then of course loops. We're going to discuss loops and then pointers and to be followed by functions. And then we're going to learn about uh escape sequence in C. And after that one will be the data structures. And of course we're going to discuss strings followed by structures and union to be followed by memory allocation and lastly is the sorting algorithms. So we're going to discuss that also in this particular tutorial series. So now let's talk about the history of C language. So history of C language is interesting to 2:02 know. Here we are going to discuss a brief history of the C language. C programming language was developed in 1972 by Dennis Richie at Bell Laboratories of AT&T or American Telephone and Telegraph located in the USA. Dennis Richie is known as the founder of the C language. It was developed to overcome the problems of previous languages such as B, BCPL and other languages. Initially C language was developed to be used in Unix operating system. It inherits many feature of previous languages such as B and BCPL. C was originally first implemented on the DEC PDP11 computer. So PDP11 is a series of 16-bit mini computers sold by digital equipment corporation from 1970 into the 1990s. C programming language is known for its flexibility and versatility allowing maximum control with minimal commands. 3:05 So now let's talk about the features of C language. C programming language is the widely used language and it provides many features that we're going to discuss in this particular video. Number one, it is simple. C is a simple language in a sense that it provides a structured approach to break the problems into parts. Number two, machine independent or portable. So unlike assembly language, C programs can be executed on different machines with some machine specific changes. Therefore, C is a machine independent language. Three, mid-level programming language. Although C is intended to do a low-level programming, it is used to develop system applications such as kernel, driver and others. It also supports the features of high programming language. That is why it is known as midlevel language. Number four, structured programming language. C is a structured 4:06 programming language in a sense that we can break the program into parts using functions. So it is easy to understand and modify. Functions also provide code reusability. Number five, rich library. C language provides a lot of built-in functions that make the development faster. Number six, memory management. It supports the feature of dynamic memory allocation. In C language, we can freely allocate the memory at any time by calling the free function. Number seven, speed. The compilation time and execution time of C language is fast since there are lesser built-in functions and hence the lesser overhead. Number eight, pointer. C provides the feature of pointers. We can directly interact with the memory by using the pointers. We can use pointers for memory structures, functions, array and others. Number nine, recursion. 5:07 In C, we can call the function within the function. It provides code reusability for every function. Recursion enables us to use the approach of backtracking. Number 10, extensible. C language is extensible because it can easily adapt new features. Now that we're done talking about the features and history of C programming language, we can now go to the installation of C in Windows operating system. Now there are multiple ways we can install C programming language in our computer system. So the most basic way is to install Torus in our computer system. Also, if you're familiar with the Eclipse IDE, you can directly download GCC compiler and include C nature to our Eclipse IDE and continue working on executing C programs. As I've said guys, there are multiple ways of installing C program into our computer system. And 6:09 one way of doing it is to install to uh Turbo C++ or you can use the Eclipse IDE and then uh include the GCC compiler and also you can do it online. There are uh there are many platforms that can help you develop C program online and then one way of doing it al is also um installing code blocks. So if you go to your browser and try to search for codelocks and then this is the first link that you will get and it will redirect you to codelocks.org and codelocks is an IDE that will help us to write programs especially for C C++ and forran ID. The good thing about CodeBelocks is it is a crossplatform and open source, meaning we can use it freely to develop our C programs. So the first thing that we're going to need guys is to download this of course in 7:11 order for us to install and start writing our C programs. So there are two options here. We can download it from this link and of course we can also download it from this particular uh link here. So let's just try this one the upper one and then there are options to download the binary release. We can download the source code and we can also retrieve source code from SVN. Okay, the first thing that we're going to need now is to download the binarial release. Okay, you click on that and here we can see that we can install it on Windows XP, Vista, Windows 7, Windows 8 and Windows 10 and we can install it also in Linux operating system be it 32 or 64bit and also we can use it on Mac OSX and because we're using Windows operating system for now. So let's just 8:12 click on that and then here we can see all the options or all the links that we can download the uh code blocks. We can download only the setup. We can only or we can also download the nonadmin no setup and then we can also code blocks with this MingW setup. So if you want you can download this particular one codelocks and then the current version is 17.1 mingwash- setup.xesa and then we can download it from source forge or fossub. So try that and then let's just wait for the download to complete in order for us to install this particular IDE and then after installation of course we can write our first program in C programming language. So currently it is 86.2 2 MB and then 9:13 we're just going to wait for a few seconds for the download to complete. And I think it won't take that much time. And we're halfway there. There you go. So, we can just install this particular IDE. So, click on this and yes. Next, I agree. And then we don't want to touch anything here. If you are an advanced user, you can try to modify the installation. But for now, since we're beginners, let's try to click on next and then install. This is the destination folder. And then install. 10:17 So there you go. Installation is complete. So do you want to run code blocks now? Of course. Yes. So G and use GCC compiler has been detected. So that's okay. and file associations. We are being asked here if we want to associate C and C++ files for this particular IDE. So, uh yes, associate code blocks with C or C++ files and then okay. So, there you have it. We now have the installation of code blocks. And so for this particular video guys, we're going to talk about our first um program or C program. So basically we also discuss how to install codelocks and here you can see I'm using code blocks to create our C program. Okay. So 11:17 here we have the basic basic program or basic C program. Okay. And before that we or I'm going to show you how to create project here in codelocks uh IDE. So the first thing that we're going to need is to create a project. So instead of using this particular um file test C we're going to close that and then create our new project. So let's go to file and then new and then there's an option here for creating our project. So basically all we have to do is uh select here a type of application that we want. So so for example we're going to just create a basic application or basic say program. So let's try to find that here in this options. So we're going to select the first one 12:17 which is the console application because uh we're going to start with a very basic application. So go and then next. So it should be C. Project title will be programming knowledge tutorials and then let's just uh select the actual directory to you uh directory to use. So let's just say the documents and then we're going to um create a new file here or a new directory C projects then okay and then next and then we don't want to mess around here. So just basically finish the wizard for now. So finish. So we have here our project uh programming knowledge tutorials and we have here the sources and by default uh it created 13:21 this particular file main. C. So as you can see we have here some parts or pre-populated code for us. So we have the very basic structure of a basic C application. So if you try to run this, let's just uh let's just try to run this first before we go any further with our tutorial. So let's just run and then it it uh it will ask to build our project. So of course yes and then there you go. You can see here uh the hello world text. So basically what this program is doing is just printing hello world string or text into our uh monitor or this particular console. So uh press any key to continue or you can just close this particular uh command prompt. Okay. So 14:23 uh let's uh if you want to make the text or the code bigger, you can just control scroll by using your keyboard and your mouse of course. So I'm just going to make it bigger so that you will uh you will be able to see what what I am doing here with our project. So first I'm going to discuss first the parts of this particular program or basic program of C. So basically we have the lines uh one and two. So basically it is the like import statement of this particular program. So it is basically uh saying that we need this files and we need to include this in our new program or new file uh main C. So we have here the include and then stddio.h and include std 15:23 uh liib.h. So basically these are header files. Okay. So these are files and we need uh functions from those files. So so for example we have here the functions print f here. So this particular function is inside or can be found in stddio.h file. Okay. And here we also have the uh int main as you can see here. So the int main is the main function. This is the entry point of every program in C language. So in normal terms, it it is basically the entrance and every time we run our project, it will try to find the main function of our uh pro project. So it should have like one main function for in in order for us to run our uh 16:26 program. So int main. So basically it says that the return type is an int. And then everything uh inside this curly braces open and close curly braces is part of this particular function main. And we have two lines here. So print f and then uh semicolon and then return zero and then semicolon. So these are the lines of our uh int main function. So in order to terminate a line you need to add semicolon at the end of that particular line. So just like this here and of course uh just like uh right after this return zero. So now I'm going to explain what this function does. So the print f is a function used to print data on the console. So basically we're just telling our program to output hello world and then um it should return zero. So return 17:31 zero statement uh it means that the return execution status of this particular program and the zero value is used for successful execution and one for unsuccessful execution. So let's try to run this again. Anyway, you can just uh run or build and run your project or you can just uh run it by pressing this particular run button. Okay. So, as you can see here, we have this particular um string or output hello world. And if you try to add a new line for our program, print f. And then uh everything that we want to display it should be inside the double quotes. Okay. C programming is awesome. Okay. 18:32 And then of course we need to end this uh end this particular line by adding the semicolon at the end and then save. We can just build and run. So as you can see here, hello world and then C programming is awesome. So notice that we have added this particular character here back slashn. So we're just telling the program to add another line or to go to a new line after printing the hello world or the hello world uh string this one. And let's try this also for this particular second line. and build and run. Okay. So as you can see after uh printing the C programming is awesome it added a new line here which you can see as a space between C programming awesome text and process return zero. So uh 19:32 there are others uh there are other text or other keywords also for this. Instead of using um slash or back slash n you can use back slash t for tab or for tubbing. So let's try that. Save and then build and run. So as you can see there is a significant space between programming word and the word is. So this will come in handy if you're trying to work with like uh tabular data. So uh back slasht will be uh like very useful for you because it will format the columns for you and uh as I've said it will be a great help. So the next uh thing that we want to talk about is the order of execution in every C program. So basically if we have like four lines 20:34 here to print something in our screen like this. So as I've said in C program it is executing in order line by line. So this will be the first one or the first line to be executed and then the second line to be executed. The third line to be executed and the fourth line to be executed. So so for example try to make this two and then three or I mean three and then four. Let's try to build and run this. So we have the output as um hello world, hello two, hello number three and hello number four. So basically all the statements are executed in order line by line. So say so for example we have or 21:36 we want to draw something in the screen. So like we want to draw a triangle. So here and then another one here and then another one just to show you the uh sequence of execution of this particular C program. So right here another um slash and then here and maybe here and another one another line or vertical line and also here and we need to add the new line or line break for this uh print statement. And we can make this or add like the 22:41 underscore. And let's try to build and run this. And you can see we have the triangle displayed in our screen. And that means that the lines has been printed or has been executed in order line per line. So if we try to make changes and instead of placing it here uh let's place it before printing the first line. So the output will be like this a funky looking shape. That's because we execute the first statement to have like the forward slash the underscore and then the vertical. And that's why we have an output like this. So just bear in mind that in every program it is executing line per line. Okay. So now let's try to discuss placeholders. Okay. Placeholders for different uh data 23:43 types. So there are in programming there are types or data types that we want to work with. So for example string we have characters we have integer we have float and other uh data types. So for example you want to display string you just have like say hello world and this is this is a string. Let's just remove this. Okay save and run and build. So we now have like the output of our uh program world. This is a string. But if you want to try or if you want to print a number so for example 32. So let's try this run and build. And as you can see 24:44 we have um returned -1073 481 or 18 and 1 n. So basically what this means is that there's uh something wrong with our program because as I've said before zero should be the standard or the return if the program uh runs smoothly or there's no pro uh there's no problem while running our program. So basically here we have negative. So it means we have problems right and we can see here that um note expected constant char but argument is of type int as you can see here. So uh basically we cannot directly display number by using this. So we can uh use placehold uh placeholder for that. So this will be for our placeholder. So instead of using directly 32 here we 25:46 can say percent and then d. So d is for integer. So if you want to display integer you might want to uh use the percent d placeholder and then inside this print f statement you need to add the comma and then of course the value that you want to be printed. So percent d and then comma and then the actual value that you want to be printed. So let's try that build and print or uh build and run. And as you can see here, process return zero. And then we have here the value 32. So let's try this one more time. Back slashn build and run. And here we can see uh we can see clearly what is happening here. So hello world. This is a string and the 26:47 value 32. So that's the purpose of percent D is a placeholder for an integer value. Another one we have for large integer. So for example there are like a very large number or very large integer. The keyword for that or the placeholder for that is LD which stands for large integer. Okay. So say for example we have like um very big integer right here. Okay. So that's the placeholder percent LD. And then of course we also have for decimal values or float values. So for example you want to say 32.5 or yeah 30 32.5. This is for again decimal 27:48 or float value. Okay, let's just say float value here. So percent f percent d for integer percent ld for large integer percent f for float number and another one for large float. Okay. So this will be for large float and then another one for so for example you want to display a character in uh you want to display like letter A. So the placeholder for that is percent C and then the actual value that should be uh type in inside the single code characters. So this will be for a char or character 28:48 and then another one is for the string. So for example you want to display hello world this is a string and then uh you want to display that you can also use percent s for the placeholder for that. So you can say hello from print f. Okay. So this will be for our string. So basically string is just a a series of characters meaning uh string is just composed of several characters. So for example this one h e l l o and f r o from and so on. So you you get the idea but basically all these placeholders can be used to display different values or different types of values. the integer large integer float large float character and string. So let's try 29:49 to display this and maybe add the backslash n here and here also here here and here. So um build and run. There you go. You can see here the output of our program and we did not specify directly the values of this um figures. So instead we're using print f and then the placeholder. So for example percent d for integer, percent d for large integer and so on. And in this tutorial guys I want to talk to you guys about variables in C. Now, when we're using C programming language, a lot of times we're going to be dealing with data. So, there's going to be different data values or different information that we're going to want to keep track and use inside of our programs. And 30:50 sometimes it can be difficult to maintain and keep track of all that data and that's where variables come in. So basically variable is essentially a container where we can store different pieces of information. So different data values we could sort of things like numbers or text or characters. And these variables make it a lot easier for us to keep track and manage all the data in our C program. So I'm going to show you guys basically how variables work or how variables can be useful and how we can use them in our C programs. But down here I have a very basic program. So I'm basically just printing out a little story. So it says there once was a man named Mike. He was 50 years old. He really liked the name Mike but did not like being 50. So this is a simple program. We're just printing out a bunch of different lines 31:50 of text. And then when I run this program, you'll see we print out the actual story. So over here we have the actual uh story. And this is great. Okay. But let's say that I'm reading through my story and I'm reading through my program and I'm thinking to myself, hm, I think I want to change the character's name. So instead of calling the character Mike, why don't we call him like John in order to make that change? So I'm going to have to look through my entire program and find every place where we mention the character's name. So right here is one. So change it to John. And remember, keep looking here. And there is another one. So we'll change this to John. Right? So 32:51 I had to manually go through and change every instance of the character's name to John. So let's say that's okay. That's uh that sounds pretty good. But maybe I'm thinking I want to make the character a little bit younger. So instead of like 50 years old. So let's change it to maybe 30. 30 years old instead of 50 years old. Okay. We're going to change here. He was 30 years old. and also in here the last line of our story. So that's 30 instead of 50. If I was to run this program then all that information will be updated and we'll now have new story. Okay. So here's the problem though. I'm dealing with a very short story. So I mean this is four lines. We only mention the character's age and name only twice. 33:53 But imagine if I have uh if I was writing out a huge C program that had hundreds of lines in the story. So story had hundreds of lines and maybe we mention a character's uh name hundreds of times. They're mentioned their age hundreds of times. And if we wanted to change the character's uh age or name, I would have to go through and manually change it every single location. And that would take forever and it would be a huge drag for us to change all the instances of the name of our character and also for our uh for the age of our character. So basically that's not a good way for us to manage and maintain the data for our programs. Okay. Uh basically we have two pieces of data that we're working with and consistently in this program. The character's age and the character's name. What I want to show you guys now is how we can use variables to better keep 34:53 track I mean manage these pieces of information. So remember a variable is basically just a container where we can store some data. So I want to create two variables which will store the character's name and the character's age. And I'll show you guys how this can make our program a lot easier to manage up here before the print statement. I'm just going to make a new line and I'm going I'm going to come over here and I'm going to create a variable. Now whenever we create a variable in C, we have to give C a couple of couple pieces of information. The first thing we have to tell C is that what type of information we want this variable to store. Now, I'm going to get into the different data types that we can represent and see more in the next tutorial. But for now, just know that there's a bunch of different types of data that we can store and see can see. We can store things like numbers, characters, we can store text, we can 35:55 store decimal numbers, all sort of uh all sorts of stuff like that. In our case, I'm going to store the character's name and the character's uh age. Basically, just a collection of characters. So in order to create this variable, the first thing that I have to tell C that I want to create a variable that's going to store some characters. And to do that, I'm just going to type out char here just like that. And basically uh telling C we're going to store characters in in uh inside of this variable. So after we type out try, I want to type the name of the variable that I want to create. Remember that a variable is a container and it's a good idea for us to give these containers descriptive names and those names will basically let us know what that variable is in storing inside of it. So I'm going to call this uh character name. 36:56 Now what I want to do is basically I want to store multiple characters. So over here we're telling C that uh I want to store a character but in C we can also store instead of just like uh instead of just storing like one single character we can store a bunch of characters and that would be kind of like you know a name. So there's like four characters in here. So, in order for us to store a bunch of characters inside of this particular variable after we type the character variable name, we're going to have to make an open and close square brackets. And that's going to tell C that we want to store a bunch of characters inside of this part uh particular variable. So, char character name open and close square brackets. Um uh I'm going to set this equal to something. So I I am essentially assigning a value to this particular variable. And I'm just going to make an open close quotation marks. 37:59 So equals and then quotation marks. And inside of here, we're going to type out the value that we want to store. So in my case, I'm just going to store the character's name, which is uh John. And then as always in C, we're going to have to end this off with a semicolon. So all right. Uh basically what I did here was I created a variable and I told C that I want to store in the variable I wanted to store a character and I give this variable a name character name and then I use this open and close square brackets to tell C that I wanted to store a bunch of characters not just one. Now, what we can do is we can make another variable to store the character's age. So, in this case, we're going to do something similar, but we're going to want to store a number. And there's a bunch of different ways that we can store numbers in C, but for 39:01 our purposes, we're storing age. So, we're going to use something called an integer. And an integer is basically just a whole number. So, I'm just going to type out int here. Int. And that basically stands for integer. And now we're going to give this name. So I'm going to call this character age. And I'm going to uh set this equal to a number. So in our story, the age is 35. So I'm just going to type out 35 there. And now we can again end this off with a semicolon. So I have here two variables. This one storing the character name and this one is for our age. Now the question becomes how we can use this inside our program. Well, basically what we can do is we can print them out 40:02 alongside with uh with this text and we can actually use this print f function in order to do that. So I'm going to show you guys how to do this and then we're going to talk about it. So basically I'm going to go over here and as you can see we have here the character name which is John. Okay. So we can replace this with percent s. So percent s is basically a placeholder. So after this um we're going to add comma here and then we're going to add the character name variable. So basically we're telling C that we're going to print this particular text and percent s is just a placeholder that will uh auto uh automatically be replaced by the value of our variable character name. So we have uh the first instance of the character name and 41:03 then right here we also have we also need to replace this with percent s and then odd comma and then character name because we want to replace that with our uh value of our variable character name which is John. And of course like here we also need to replace this with the actual value of our character age. So what we can do here is just we can add percent d. So percent d is also a placeholder for printing the integer. Uh so this is like integer integer character age equals 35 and then percent d and then we're going to add comma here. So and then character h the same thing here character age and then we're going to 42:04 replace this with percent d a placeholder for integer. So if we try to run our program so let's do that build and run and we will uh we should have the so we have a process return so I think we have something or we have an error with our program so let's try to debug this so warning format s expects per argument type of character but argument element two has type int. That's basically because we didn't add the uh square brackets there. So build and run. So there you go. Uh we have now the output. There one uh there once was a man named John. He was 35 years old. He really liked the name John but did not like being 35. And of course every time you can if you want to change something 43:05 with this story. So, so for example, instead of John, we will say Michael and we can change also the age like 40 and then um exit that and then build and run. So, as you can see here, we now have the updated um story. So, Michael and then 40 years old. So the good thing about variable is that we can reuse this into our entire program. So we have every time we have changes here all the variables or all the value should be reflected in our uh the rest on our program. So in in our case we have updated all the values for our story. And in this video guys, we're going to talk about variables. And of course, we will have a deeper um discussion on how to declare, 44:07 initialize, and assign values to our variables. So basically guys, like most programming languages, C uses and processes variables. And in C variables are just like human readable names for the computer's memory addresses used by a running program. So basically guys the advantage of using variable is it is making our life easier to store read and change the data within the computer's memory by allowing the or by allowing us to associate easy to remember labels for that particular memory addresses. So at first uh it is easier to imagine that variables uh are just uh placeholders for values much like in mathematics. So you can think of a variable as uh as being 45:07 equivalent to its assigned value. So say for example if you have a variable that is I and then initialize or set equal to say for example four. So by that you can say that I + 1 will be equal to five. So there you go. So uh now let's talk about how to declare a certain variable in our C program. So basically all we have to do guys say so for example if we try to declare an int or say for example int and then some number okay and then you have to end it with a semicolon that uh signifies that it is the end of this particular line. So this statement 46:08 uh tells the compiler to create a variable called some number and associate it with a memory location on the computer. So we we're also telling the compiler that the type of data that will be stored at that address and in this case it is the int. We have to remember also that in C we must specify the type of data that a variable will store because it will tell the computer like how much the total memory to set aside for that particular um variable or set of data something like that. Now you can also uh declare multivariables in one statement. Just say for example int n1 and then you have like n2 and then n3 and then end it with a semicolon to signify that it is the end of this particular line. So that's basically how 47:09 to declare a variable. So you can do it like this and if you have like multiple variables to declare you can just do it like this for as long as it is the same type. Okay. So int n1 and then n2 and n3. So we're just telling the compiler to declare this particular variable and all of this variable um the type is int. Okay. And of course you can uh assign a value to that particular variable later on using a statement like so for example sum some number equals to three. Okay. So basically this is the declaration of our variable sum number but is this is the assigning of value. So we're just basically assigning value three to our variable sum number. So the assignment of a value to 48:10 a variable is called initialization. So we're just basically initializing the value of this variable some number equal to three or something like that. And of course you can just maybe you you can uh declare initialize and assign value at the or in one line or something in the same time. So int equals to four something like that. So you can declare the v uh value or the variable and then assign value to that particular value uh variable. So okay and of course you can assign variables to the value of another variable. So it means say for example n1 you can assign the value of age into this by just using the variable age something like that or you have to modify it with like add 10. Okay so age 49:11 and then plus 10 or something like that. And if you want to display this, all you have to do is use the function print f and then you can uh say the age is percent d and as you can remember this is the placeholder for int. So percent d and then you have to specify the variable. So for example n1. So let's try this. Add semicolon to this. So compile and run. So the age is 14. So that's because the n1 now holds the value of age plus the value 10. So it makes it 14. Okay. And of course you can assign multiple variables to the same value with one assignment. So, so for example, n1, n2 and n3, you can assign it like this. 50:16 So, I'm just showing you guys how to assign values to this particular variable. So, say for example, n1 equals n_sub_2= n3 and this should equal to um 8. Okay. So, let's try this. and and as you can see the value is 8. Okay. But if you try to display also n2 and n3 it will get also the value eight. So you can uh assign multiple variables to the same value with uh one statement. So now I'm going to talk about naming the variables because there uh in naming or I mean in C we have to remember that there are naming rules that we have to follow. So one of the rules that we have to remember is that 51:18 um the variable name must not start with a digit. So basically you can you cannot say int and then one age. You cannot do that because as a general rule you cannot start your variable name with a digit. Okay. And of course the second one is spaces not allowed in names. So you can't say int and then a space my aid. You can't do that because that's not allowed in C. and uh dollar sign not allowed. So or any special characters for that matter. So uh only 52:18 letters, digits and of course semicolon allowed in our variable name. And of course the last one will be the uh reserve keywords. You can't use reserve keywords. So that's basically so for example you you want to name a variable int main something like that you can't use this variable name because this is a reserved keyword meaning it is a primary keyword used by C as you can see here. So now let's talk about the four major uh four basic data types in C. So there are four basic data types in C. That's um int and then we have char or characters and 53:20 then float and then we have the double type. Okay. So int is a type that stores integers in the form of whole numbers. So any number that is whole. So you can um say it like int equals um 10 or maybe 11 um 20 for as long as it is a whole number. So it should be a whole number between 2 billion147,400 68 or 648 something. So negative and that's inclusive um positive for 200 uh 2 billion 54:25 um 147,483,647. So that's the um length of the int if you want to use this particular uh type int. So that's the in should be between that number or those numbers. So the next one is the char type. So char is just a series of character or a single character. So the first the the way of declaring a character or a char is you have to use char keyword and then so for example letter one equals a. There you go. You have to enclose it with single quote and it signifies that it is a single character or something like that. And of course you can have like a series of characters. So for 55:26 example like what we have previously char and then character name and then you have to use the uh square brackets for that motor and uh so for example John okay so that's basically how to declare or how to use the char keyword okay and the next one is float. So basically float is a short for floating point and it stores um representations of real numbers both integer and non- integer values and the way on how to declare that is by using uh the keyword float and then maybe you can um declare it as uh 56:27 but float pi = 3.14 something like that. So you can declare your float values by using uh that keyword float and then followed by the keyword or the variable name which is for example in this case the pi which is 34. Okay. And of course we can use also the uh data type double if you want. So double is so for example um salary equals 10,000 10,000 something like that. And basically if you want to use double all you have to do is use this key uh keyword double and then the name of your variable name. in this case salary and then declare or initialize it with a double value something like that. Okay. 57:31 And if you have any doubts to the amount of memory actual uh actually used by any variable you can use that the size of operator to find out for sure. So you can like uh use the keyword size of and then um the variable age. Okay. So so for example for that um you can get the actual amount of memory allocated in that particular variable. And in this video guys, we're going to talk about the scope of a variable and of course we're going to talk about the operators in C and how we can use them. So let's go ahead and talk about the scope of a variable. So basically a scope is a region of the program and the scope of variable refers 58:32 to the area of the program where the variables can be accessed after its declaration. So basically in the C program we have like three um different um scope or different location that we can declare our variables. So the first one is inside a function or a block. So we have the the first one will be the um local variable. Here we go. we can declare um a variable inside our function. The second one uh the second one will be the global variable. Okay. And of course we can also um declare a variable inside the function parameter. So function parameters. Okay. So that's all the area that we can like declare the variables and set the 59:34 values to it. So but basically we do have like only the two that is um most common although we are most of the time um setting the function parameters and declaring variables to it like uh almost every function but yeah the most common way of you know declaring a variable is the local and global uh local and global variable. So again when we say global or local variable it is a a variable that is declared inside a particular function or a block of function. So a variables that are declared within the function block and can be used only within the function is called local variable. So uh this is how we can um implement this in our C program. So for example in here 1:00:35 we're going to declare by the way guys this is a um comment and the way to make comment in C program is by using the double slash. So this means this is this is a single line comment and of course we do have the um slash and then the asteris and then asteris and then forward slash. So this is multi-line comment. So we can like add comments in between these lines and uh this double uh double slash will be the single line comment. Okay. So I hope you um get the idea of this comments and basically guys these comments can will not be interpreted by our C program. Okay. So as I've said we're going to discuss or we're going to declare a local variable here local variable definition 1:01:37 and initialization initialization right there. I'm just going to remove this single line comment. Okay. So in uh the the way to declare a variable in C is like int or this is the type of information that we want to save. So int and then so for example the variable name is x and we can do it like this y and then z. So basically what we're doing here is declaring three variables of int type. Okay. So this is the variable definition. And of course we can uh initialize it by saying um x= to 10. Okay. x= to 10 and y = um x + 5. And then we can also say z 1:02:40 equals y variable + 1. Okay. So that's how we can um declare a variable and initialize the value into the variable. So this is the definition int xyz and then of course the actual initial uh initialization which is uh right here x = to 10 y = x + 5 and then z = y + 1. Okay. So of course you can always print this. So for example print print f and then value of uh so for example z equals percent d remember d is just the placeholder for our um integer value. So the value of z equals the c variable. 1:03:43 Okay. And then save. And of course you can compile and or build and run your C program. So let's try that. Okay. So we need to uh add the same column at the end of the line to mark that it is ending in this particular line. So build and run. And there you go. The value of Z equals 16 because we set the X equals to 10. and then dy = to x + 5 and of course z = um y + 1 that will result to 16. Okay, so that's how you declare and initialize a local variable. Now let's go on with the global variable or global scope of of a variable. So variables that are declared outside of a function can and can be accessed inside the function is called global variables. So so for 1:04:46 example you want to declare a global variable all you have to do is before the int main function. Okay right here we can declare the um global variable. Okay. And we can declare it like int. And then we have like the semicolon at the end of the declaration. Okay. Int age and then semicolon. So global variable initialization. So after the um after defining a local variable the system or the compiler won't uh initialize the value or any value to our local variable. So we have to initialize it by by ourselves like this. So if you try to define the variables 1:05:47 right here it won't have any initialize or initial value. So we have to declare it like this. x = to 10, y = x + 5, z = uh y + 1. But uh global variables get initialized automatically by the computer um or as uh by the compiler and um so for example if we declare the the variable type as int then the initial default value will be zero. Okay, remember you have to remember that. So the difference between global and local variable is um whenever we declare the variable in our local um scope, it won't get any initial value. So we have to initialize it by oursel. But the global variable is initialized by default uh depending on the type of value that we 1:06:49 have saved in our variable. So for example int int then it will uh default or initial default value will be zero and if char so for example char t so the default value will be um single quote and then back slash um zero and then back slash I I mean single quote um of course when we say float load m. So the initial value of that is equal to zero. When we say double the initial value of that is also zero. And when we say pointer uh the initial value of this is equal to uh null. Okay. So you have to remember that whenever you declare a global 1:07:52 variable there is a default value for our variables. Okay. So as I've said um global variables can be accessed inside our main function or any function. So because this is a global variable right in this video guys we're going to talk about the input and output in C programming language before we dive in into um operators and how we can use operators in C programming language. So basically we can use the function print f to display something in our screen just like what we have uh before. So print f and then we can say hello world. Okay. And then uh we can build and run this program and we can get the hello world string right here. Um we use the print f function for that. And now we're going to talk about the input because 1:08:52 we're we're trying to focus on the input because we're already familiar with the output side of say programming. So we have used the print f to output something in our screen. And then of course in order for us to ask input from the user we're going to use the scan f function. Okay. So the way to use um scanf function we can say here we can ask for a particular number. So please enter a number. Okay. And then we can um add the escape character here for a new line. And we can declare a variable here. So, so for example, int a and then we can um get the value from the user by using the scan f function and then uh format specifier for our int variable or int 1:09:53 value and comma and then of course um the n symbol and the name of our of our variable a. So basically what this means is that we're taking the address of variable A and then assigned a value to that address um whatever the the user has inputed. Okay. So and then we're going to end this with a semicolon and let's try this uh let's try to display the value that uh comes from the user. Okay. So number the number is um percent d format specifier for our uh int value and then comma and then and then the name of our variable which is a okay and then semicolon. So uh remember to end every time or end every line with 1:10:58 a semicolon. Okay. And then we can build and run this application. So there you go. Uh the program try uh is trying to prompt us to input a number. So so for example number five. So number five is or the number is column and then the value five which is coming from the user itself. Okay. And now we can actually um ask two numbers in the same line by using also the scanf function. So in here we have like uh ask for a single number. But what we can do is we can ask for um two numbers just like uh please enter any two numbers. Okay. And then we're just going to use the 1:11:58 same function percent um scan f and then percent d percent another percent d because we're asking two numbers. And then in here we can say uh n symbol and then the value or the variable b which we will uh declare here on the top. Okay, b and then we can declare another variable c and we can add the values or the numbers coming from the user. So um the number or the value C or the variable C we can assign a value to that which is the total of the two numbers A and B. So that will be C equals A + B. So what we're doing here is that we're assign 1:13:00 we're just assigning the value of the total of A and B into our C variable. Okay. So the total the total number is and then percent D and of course the value of our C. Okay, which is again the total of our variables A and B. Okay, so save this and then we can uh build and run our application. So please enter any two numbers for example um one and two. So the total number is three. Okay. So again like five and um three. So the total is eight. Okay. So as you 1:14:03 can see we are getting the two numbers five and three and then we're displaying the total which is eight. Okay. So basically that's how you can ask or you know input something into our program because our program right now is asking for a uh for an input from our user. Okay. And that's where we can you know uh apply the operators in our C program and we have different operators or type of oper uh operators in C. So C programming language offers various types of operators having different functioning capabilities. So the first one is the um arithmetic operators. So we have used the addition operator 1:15:05 right there by you know assigning the value of a + b into c. Okay. And then we also have the relational relational operators. Okay, let me resize this so you can clear uh clearly see it. Arithmetic operators and then we have relational operators and the third one will be logical operators. The fourth one is assignment operators and fifth one will be increment increment and decrement operators. I'm just going to list it here so you can see all the type of operators in our C programming language. So decrement operators and then we also have the 1:16:08 conditional conditional uh operator. We also have bitwise operators and then we have special um operators. So these are all the types of operators that we can use inside our C programming language. And of course the first one is arithmetic. So arithmetic operators include um it includes addition of of course the symbol for that is the plus right and then we also have subtraction symbol for that is dash. We also have multiplication and we can use the asterisk for that to multiply two numbers in our inside our C program. And then of course we do have the division which is the forward sl uh forward slash symbol. And of course we 1:17:09 have the modulo and we can use the percent sign to um like operate by using modulus. Okay. Now uh let's talk about the operators or arithmetic operators. So for example you know uh addition. So we can also like um int b equals um a minus b. Okay. And then we can like have of course not we cannot redeclare it uh the b because we already declared it there. So we can say it d= a minus b and then we can see uh e and then um a * b and of course we can have the division 1:18:14 and we're going to have like um use the float or we can use the double for that. double um f= 1 or a divided by b. Okay, so these are the all arithmetic operators that we can use inside our C program. So basically you can add, you can subtract, you can multiply and you can um divide two numbers inside your um C program. So um so for example, we're going to test this. Okay. So int d int uh equals a minus b. Okay. So we can display the total number is percent D and then the difference 1:19:15 difference of the two numbers the difference uh the difference is of course we're going to use the different or the variable D for the uh difference and then we can use another one which is the product. The product is percent um d and the next one is the quotient. Okay, the quotient of two numbers is of course the uh variable f and then we can use the format specifier which is lf okay and then of course the variable f something like this so let's run our 1:20:17 program okay and we can enter two variables here or two numbers which is for example five and three. Okay. So the difference or the total number is the total number is eight. The difference is two and we need to format this so we can see clearly. So we can add percent or I mean back slashn for each line the difference the quotient and of course we need to have the product the product is percent d and then of course the variable e. Okay. So again run our program build and run and then five and then three. So the total is 8 or 5 + 3 is 8 and then the difference is 5 - 2 or 5 - 3 is 2 and 1:21:19 then the product is um 15 5 * 3 is 15 and then the quotient is uh 1. Okay. So there's only number or there's only one three and the value five. Okay. And in this video guys, we're going to talk about how to use increment and decrement operators in a C program. And later on, if you still have time, we're going to discuss or we're going to uh start discussing relational operators and how we can use inside or how we can use it inside our C program. Okay. So basically guys increment and decrement operators are um useful operators and it is generally used to minimize the calculation. So um let me show you an example. So in order to increment a value inside a C program we do it like this plus plus 1:22:20 and then the name of the variable. Let me do it here so you can see it clearly. Plus plus and then the variable. Okay, plus and then the variable. So it means that x = x + 1. Okay, remember plus + x means x = uh x + 1. And of course in the same manner when we say minus - x it means that x = x -1. Okay. So this is how you increment and decrement a value inside a c program. But there is also a way um it is called the postfix. It is postfix because we place the 1:23:20 operator or the plus symbol after the variable x++. But it it also means that um x = x + 1. And of course when we say x - still it means x = x -1. Okay. So you get the idea. This is how you increment and decrement um inside a C program. Okay. Now, uh there's a difference or a slight difference between having plus+ X instead of X++ or - - X instead of uh X - okay. So, I'm going to show you that in a simple program. So basically what we're going to do here is we will have a two variable. So two variable which is a which is 1:24:22 equal to five and then b which is equal to five also. So I'm going to show you the effect of postfix and prefix. Okay. So again this one is the prefix. Okay. And then this is postfix. Okay. So let's comment this out. So I'm going to show you the effect of postfix and prefix in this particular example. So int a equals 5 and b equals 5 also. And then um in here we set we set the value of a and b equal to five. Okay. So basically what we can do right now is 1:25:23 print and decrement decrement each time. Okay. And then uh we can use the variable a for our post fix. Use a for postfix and use b or variable b for prefix. Okay. So we can do this by u using the print f method and then um uh back slash n and then percent d. Okay. and then percent d because we're we're having to display or we we're going to display both the value of a and b. Okay. So we're going to use the postfix here a 1:26:25 minus minus and then this one is four - b. So again this is postfix and this is prefix and then they are set uh or or the value of these two variables are set uh a = to 5 and b equals to 5 and then we can end this with a semicolon. And of course we can do the same. Can do the same. We can do another one. And uh one 2 3 4 5 six. There are six lines. So we we only need five. And I'm going to um show you and demonstrate what is the effect of postfix and prefix. So for you to understand here we have taken the value of a and then of course 1:27:26 taken the value of b and then we apply postfix and prefix. So if you try to run this build and run as you can see the value is 5 4 3 2 1 and the value of B is 4 3 2 1 0. So it means that if we use the prefix okay which is the case here minus min - b so it automatically um uh decrease the value of our variable by one whereas here uh it displays the value of a still five and then later on four and then in the third line three the fourth line two and the fifth line is uh one. Okay. And then 1:28:28 of course in the prefix it decrease the value by one and then four 3 2 1 and zero. Okay. So that's how you uh do it the increment and decrement in a C program. And this is quite useful if you know if you are working with for loops which we will discuss later on in this particular series. Okay. Now let's move on to the next operator which is the relational operators. If we have increment and decrement we also have the relational operators. Relational operators. So basically there are like 1 2 3 4 5 six six um relational operators and uh the the first one is equal equal. Okay so basically we're just checking if 1:29:31 something is equal to or a variable is equal to some variable. Okay. Is equal to and then we have the um exclamation point and then equal. So it means is not equal. So basically uh by this we're just checking if a certain value is not equal to another value. And then of course we do have the greater than. Okay, greater than. And then we have less than. And then of course we have the greater than or equal to. So greater than greater than or equal to and less than or equal to. 1:30:35 Okay. So basically um we're just checking the relationship or like the relation between two values if it is equal if it is not equal if it is greater than less than or these two comparison or relation relational operator um greater than or equal to or less than or equal to a certain value. Okay. And then of course um we can use this especially in a if statement in and we're going to discuss that later on in this particular series. So basically if you want to check if something is equal or not equal or greater than we can use the relational operators. So we have to remember this. This is one of the most important concept in programming. So the relational operators okay and in 1:31:38 this video guys we're going to discuss about the uh logical operators and of course the assignment operators. So previously we have discussed this relational operators. So we have like six relational operators. The equal or checking if a value is equal to some value also and then not equal. We have also greater than, less than. And then we also have greater than or equal to and we also have less than or equal to some value. So this is quite useful guys if you are using the control statement in C. Say for example if statement and then you want to check if a certain value is um equal or not equal to some value. So for example if um a variable x is equal equal to two. So basically we're just checking if this particular 1:32:39 variable or the value of this x is equal to two or we can reverse that. we can check if this particular variable uh variable is not equal to two. And of course you can use other um operation or operators like greater than um less than or you could also double check for greater than or equal to or less than or equal to. So basically guys this operators is like just checking the relationship or if the certain value is greater than another value or it it is equal to another value. Okay. Now let's move on to the next one which is the assignment operators. So basically guys there are a lot of uh assignment operators in CA programming language. Okay. So the first one will be the equal sign. Okay, this is one of the most uh common assignment operators in C 1:33:43 programming. So for example, you want to assign. So as I've said guys, this is for assignment operators. Assignment operators. Okay. So basically this is useful if you want to uh set a value to a variable. Okay. So for example x and then if you want to make this like five or the value of x is equal to five you can do that by using this particular assignment operator equal symbol. Okay that's easy. And the second one is um plus equal. So we have this also plus equal and then um it basically means guys that it increments the value and then assign it to the um the variable. Okay. So so for example you want to make this like x and then plus equal to two. So basically let's try this. Um 1:34:46 we can remove this code right here. we can uh use the increment then assign. So basically like we set a value for x we set it to five and then we can have it like x plus and then equals to three and then we can use the print f function and we can display the result further. So, so for example, um the value is the uh format specifier and then of course the comma and then the x variable. Okay. And then semicolon at the end of this line. Save this and then compile and build or build and run our application. 1:35:46 So basically as you can see here the value is 8. So this is the doing of the plus equals to three. So bas uh basically what it means that it add three to the variable x and then of course it the result of that is assigned to variable x also. Okay. So this is basically uh just incrementing the value of our var uh variable. And of course we also have the x minus um equals to for example one. Okay. So basically it is the complete opposite of this one because this is for incrementing and this is for decrement. Okay. And of course we do have other operators for this particular um topic which is the assignment operators. Uh we also have x for example times or 1:36:47 multiply equal to two. You can also do that. And basically the division also. Okay. You can do also the modulo part modulo symbol and then equal and then so for example two and there are others for example um percent or I mean x and then and um n symbol and equal uh symbol and then of course the value that you want to assign. So this is basically bit uh bitwise and um assign assignment. So we're not going to use that for now. So basically our our currently concern is this operations. We can have the increment. Uh the first one is equal and then of course the 1:37:48 increment the decrement and then multiply uh multiplication then assign. And we also have divide and assign. you also have modulo and assign. So that's basically how the assignment operators work. So the last um thing that we want to discuss here is all about the logical operators. So logical operators provides um three uh mechanism that we can test more than one condition to make a particular decision. So these are the um and symbol. So meaning it is uh logical and okay logical and uh let me show you that later on what uh what this means logical and and of course we also have this bar bar and this is uh logical operator or 1:38:50 logical or and then of course we have the negation or not symbol. Okay, so logical or and then this is and and of course logical not. Okay, so let me show you how this works. This three logical operators. Now let's try to use the logical operators. So for example, the first one the logical and operator. So we have here variable x which is set to eight or the value is eight and then we can check if this particular value is or the part uh particular value uh variable x is um greater than five. So we can do that by using the if statement and then x is it less than or greater than five. So if x is greater than five then we can um display 1:39:51 uh something in our in our screen or output something. So we can do print f and of course the value is greater than greater than five. Okay. So we could uh build and run this and see the output of our program. And of course it's going to uh display uh the value is greater than five. Okay. So what if the value is four. Okay. So obviously there will be no output because uh this the condition right here uh turns to be false because the actual value of x is now uh four. So no statement has been executed for this particular program. Now we can use logical operators and in this particular scenario. So for example, we want to check that the value of x should be um 1:40:53 greater than five but less than 10. Okay. So we could check if the variable x is greater than five but less than 10. And we can do that by uh using the logical n operator. So double amp% and x and then less than 10. Okay, we could do that. And of course um if we try to um run this still there's no output because the value of x is four. So we can try six here. Build and run our application. So the value is greater than five and we should add here that the value is less than 1:41:55 10. Okay, build and run our application. So the value is greater than five and it is less than 10. Now what if it is 11? So obviously it's going to display nothing in our screen because the conditions of this particular statements is not met. Okay. So that's how you can use the logical and operator. And of course when we say and um basically it means that it should be the both of this statement or both of these condition should be true in order for this statement to be executed. Okay. And you can also use the logical operator or in this particular scenario. So it doesn't matter if the um x is greater than five or x is less than 1:42:57 10. Um it should you know execute the statement that we have here. Okay. So for example we run this. Okay. So we have the value is greater than five and less than 10. and we can try like 20 or maybe uh use the value 20 in our x. So let's try this. Save and then build and run. Okay. And as you can see we still have or we still get the output. The value is greater than five and less than 10. That's because this particular statement here returns true. So it doesn't matter if this particular statement here is false. So as long as there's a true uh returns either of this statement. So there there should be statement printed 1:43:59 or executed inside this particular if statement. In this video guys, I'm going to show you and teach you how to use um if statements in C programming language. So I think from the previous video we have like touched the basic usage of if statement. So we have tried if statement with the logical operators. So the and the um relational operators the you know greater than less than or less than or equal to and other relational operators. Okay. But in this particular video guys I'm going to go deeper with the if statement and how we can apply um if statement in our C program. And of course guys I want to show you the practical approach on how to uh how you can implement if statement in a C program. So basically guys um if statements in C is used to control the 1:45:01 program flow based on some conditions. So it is used to execute some statement code block if the expression is evaluated to true. So otherwise uh it will get skipped and we will try to uh implement a simple or basic program um utilizing the if statement. So actually guys there are four different types of if statement in C. So these are you know simple if statement. We also have if else statement. We also have nested if else statement and we also have else if ladder in C programming language. But for now let's just focus on the simple if statement. So basically the structure of if statement is just like this. So we have this particular format or basic format of if statement 1:46:03 in C. We have if keyword and then open and close parenthesis and then inside of this open and close parenthesis is the test expression. Okay. Or the condition. And then of course uh we should you know uh add curly braces open and close curly braces. And then of course the statement to execute whenever the test expression or condition is met or in this particular case if this particular condition is evaluated into true. Okay. So now let's try to implement a practical approach of an if statement. So say for example you are developing a program or a software for a particular bar. Okay. And then that particular bar only accepts customers that are over 18 years old. 1:47:04 And those customers that are below 18 years old are are not allowed to enter the establishment or the bar itself. And we can create a very simple program for that. And our program will accept the age of the customer. and then it will evaluate the age and it will display a message based on that particular age. So the first thing that we're going to declare here is the variable age which has the type of int and of course we need to display something on to the screen that says uh to input a number that pertains to the age of the um customer. So in order for us to do that we need to use the method print f and then in here we can say enter the customer's the customer or enter the age of the customer. Okay then we can add colon and then 1:48:06 space so we can have like the space for our um input age. Now we have this output and we need something to uh accept a number from our user. So we can use the method. I think we already used this before the scan f right. So in here we need to specify the format specifier for our H which is um uh percent D which uh which pertains to the values that are of type ink. Okay. And then of course uh after this we need to add the comma and of course the variable age. And of course we need to end this line with a semicolon. But the proper way of doing this is to add an a person a person symbol. Okay. So basically what we're doing here is just 1:49:08 we're getting the address of age and assigned value of that particular address uh using the value that has been inputed by the user. Okay. And of course we can now apply our if statement with this particular age. So the first thing that we're going to check if the age is greater than 18. Okay. So we can just copy and paste this age variable and then we can add the um logical operator greater than. So basically what we're doing here is to check if the age is greater than 18. Okay. So there you go. And then of course the statements statements to execute if condition is true. Okay. So basically 1:50:08 what we can do here is to print um the age the age is greater then 18. Okay. And basically it uh it says or it means that the customer can enter the premises or the bar itself. Okay. And of course we can also check if um the user or the age of the customer is equal to 18. Okay, we could also check that by using the logical operator or the relational operator equals uh equal equal symbol. So this is just um testing the age if it is equal to the value 18. So the first one is we're testing the value age if it is greater 1:51:09 than 18 and the second one if it is equal to 18 and then of course we need to uh display the corresponding uh output. So the age is equal to 18. Okay. And then of course we can add another one for this. So we can just copy and paste. For this one, we need to check if the age is less than 18. So this is another logical operator that we have discussed from the previous videos. Okay. So greater than, equal and then of course less than uh 18 and of course we can output here like minor is not allowed. Okay, that's because the age of the customer is less than 18 and the general rule when it comes to bar is minors are not allowed. 1:52:10 So basically what we're doing here is very simple program for that particular bar. Okay. Now we can try to run our program. We can just you know um build. Okay. And then we can run our program and we have we can enter the age of the customer. So for example the age of the customer is 18. So the age is equal to 18. Okay. So as you can see this is the only um output or this uh this is the only statement that has been executed the age equal to 18 because the other one uh the other condition is not being met or not evaluated to true. Okay, because uh the age is equal to 18 and of course this is um greater than 18 and of course this is 1:53:11 less than 18. So we can try another one. So for example the age is um 19. So the age is greater than 18. And of course again this is the only uh statement that that has been executed because it uh the condition evaluated to true. This is evaluated to false because the age is not equal to 18 and this one is evaluated to false also because uh the age is not less than 18. Okay. So you can try this one more time to check for so for example the age of the customer is 16. So the output is the minor is not allowed. Okay that's the practical way of using if statement in C programming 1:54:14 language. In this video guys, we're going to talk about if else statements and of course we're going to uh discuss also the nested if else statements in C programming language. Now uh from the previous video we have created a simple um application. So we have assumed to create an application for a bar or establishment and then that particular program will ask for the age of the customer that is trying to enter the premises of the bar. And of course we ask for the age, right? And we check for the age. If it is greater than 18, then we display the age is greater than 18. And if the age is equal to 18 and we also display the age is equal to 18. But um in case that the age is less than 18 then we print that minor is not allowed. 1:55:14 So basically guys this is a good um program but we can you know upgrade this. This is not uh when it comes to code readability and um code maintainability. This is not a good practice when it comes to um you know checking a variable or a certain value of a variable. So now let's just remove this lines. Okay. And of course we have this first condition if and then we check for the age of the customer which is you know 18. So if the age is greater than 18 we display um the age is greater than 18. So I uh as I've said we can take this further by uh adding else statement right here. So basically the if else statements in C is also used to control the program flow 1:56:16 based on some condition. And the only difference is it uh used to execute some statement code block if the expression is evaluated to true. So it it will try to execute this particular um statement if this particular condition is true. Otherwise it will try to execute the statement of this particular else code block. Okay. So in here we can try to display print f the age is less than or equal to 18. Okay. So as you can see um if we try to u evaluate this so if age is greater than 18 so so for example you have like 19 or you inputed 19 then 1:57:18 of course automatically it will execute the statement that the age is greater than 18 right now basically if we try to input 18 so 18 is not greater than 18 so it will try to um execute the code block or the code or the statements inside this else code block because the condition right here returns false. Okay, because um 18 is not greater than 18 and uh there you go. It returns false. Okay. Now we can also add another condition right here. So for example, we want to check if the uh age is um equal to 18. Okay, we can check if the age is greater than 18. And of course we can also check if the user or the age is equal to 15. And then otherwise it's it 1:58:20 is less than 18. And uh we can add another l statement right here. But for now, let's just you know add the uh another condition or condition evaluation test expression if the user or the age is equal to 18. Okay. So basically this particular statement um if this particular condition right here is false then it will try to evaluate one more time with this particular condition is the age equal to 18. So if that particular age is equal to 18 then we can display the age is equal to 18 right there. But in case if the age is less than 18, we can also um add the else statement right here and we 1:59:24 can display that the age is less than 18. Okay. So as you can see we have you know implemented a practical implementation of if else statement and we can add you know the first if um condition and then we can add another condition else if and then we can test this condition right here. Otherwise if these two conditions are returning false then we can you know execute the statements in this particular else block. Okay. So we can try this. We can run our program uh build and run. So let's try first the possibilities. So for example the customer or the enter the age of customer for example 25. So the age is greater than 18. So let's 2:00:24 try to run uh this once again and we can try to input 18. So the age is equal to 18. Okay. So this particular condition right here returns true. Now we can also try to uh input the value which is you know less than 18. So for example 16 and then of course the age is less than 18. Okay. So as you can see in this particular example there will be only one um block of code that will be executed. So, so for example this one if this will uh return true the age is greater than 18 then it will execute this statement right here or inside this ifs uh block then it will ignore the other um like the else if and the else. Now if it will return false then it will try to 2:01:25 evaluate the expression inside here and if it is true or it will return true then it will execute this statement and ignore the else. If all of this statements or conditions here will return false then the else statement will be executed. Okay. and it will you know try to print the age is less than 18. Now there are cases that we need to check also. For example, inside this uh if statement we want to check if um the age is less than 25. Okay, less than 25. uh although we have like the age is greater than 18, we want to check also if the age is um less than 25. So we could add also um if statement right here. So this is 2:02:26 like what we called nested if else statements. Okay, nested if else statements. So we can also check here if age is less than 25. Okay. And then we can uh display here print f. And then the age is um greater than 18 but less than 25. Right? Less than 25. And of course we can also add else statement here or else if like for example else if the age is greater than 25 2:03:28 then we can say here print f the age is greater than 18 and greater than 25. So there are cases that you want to check this you know um if you want to like in the future you want to implement an application and you will try to check the values and somewhere in your code you need to check uh like the value age here and also you could also check if the value is less than 25 or greater than 25. So it is very useful when it comes to programming this particular nested if else statement. So let's try to run this. And before that I'm just going to add a uh backslash n right here so that we will have a new line 2:04:30 after this particular code execution. So let's try to build and run our app first and try to input a value that is over 18. So for example 23. So the age is greater than 18 and there's another statement that has been executed right here. The age is greater than 18 but less than 25. We can also you know run this once again and input 26. So the age is greater than 18 and there's also a statement here the age is greater than 18 and um greater than 25. Okay. And uh that's how you use the if else statement or um yeah if else statements in C. And then of course if you have like many conditions that you want to check so you can also add um 2:05:33 another conditions right here. Okay. And then another condition and um otherwise if there uh if these conditions are not met then you can uh display or execute the statement inside this else code block. Okay. Now, uh the nested if else statement requires only one if. Okay. So, you can't use like uh two ifs here because it will try to separate the uh chain of if else if you use another if. So what you can do is uh one if and then else if else if and also one else statement. So it doesn't matter how many else if statement that you can add. Okay, for as long as it is like has 2:06:34 one if and has one uh else statement. Okay. And in this video guys, we're going to learn how to use turnary operators in C. So basically guys, the turnary operator is used to execute code based on the result of a binary condition. So when we say turnary operators, it is used to execute um code based on binary condition. Okay. and it takes in a binary condition as input and uh which makes it similar to an if else control flow block. So so for example guys from our uh previous tutorial we have discussed how to use if else statement. Okay. So we have this kind of structure. So for example, we want to use this structure or code to get the maximum uh 2:07:40 two values or two um variables. So if you want to like return the max value, all you have to do is compare the two uh variables A and B. So for example if a is greater than b then of course a or max will be assigned to a otherwise the max number will be the value of variable b. Okay. So the turnary operator guys instead of using if else like this this is too long for a simple you know uh checking of value condition. So the binary or turnary operator uh uses only single line or we can use the turnary operators in a single line and uh it returns a value so behaving uh 2:08:42 similar to a function. Okay. So let's try to see the syntax of the turnary operators in C. So basically the syntax is like this that um result and then binary condition and then you have to add the question mark and then you have like the value when the binary condition is true otherwise the value of uh you know value to be returned if the binary condition is false. So we have to take note guys that the turnary cannot be used to execute code. So it must be either uh return in the function or set equal to a variable. So you cannot use this something like this. So you cannot leave your turnary operator like this. So it should be equal to or 2:09:45 be set equal to a variable. Okay, something like this. or you can use it as a return in a particular function. Okay. So let's try to implement a turnary operator. So for example, you want to check the max value. So the long version is this. If a is greater than b then assign the value of a to the max and then otherwise assign the value of b to the max variable. So as I've said we can you know make this a little shorter by using the turnary operators. So in order for us to do that, we just need to um so for example get the variable max and then the binary condition is a is a greater than b. Okay. So we can add the question 2:10:47 mark. There you go. Question mark and then the value to be returned if the binary condition is true. So of course if a is greater than b then the max value is a right otherwise the value is b or the return or the max value is the value of variable b. As I've said guys um this is the um explanation of conditional or turnary operators. in C. So we have this variable and then we have the expression or the condition and then you have to add the question mark and then the value if true. So it will return the resultant value into the variable and it will assign this value 2:11:48 to this variable. Otherwise uh if the expression is false then the resultant value of uh you know the false then it will be returned as the value of the variable that we have added. Okay. So we can check this right now. We can remove this. This is um the long version and we can try to print this display the result the max value is and then format specifier which is we're using int. So percent b and then of course the max variable. Okay. Uh let's just remove this. So clean and build or build and run our application. So let's try this. Uh 2:12:52 oh um we don't have like the value for a and b. So let's try to assign values to this uh variable. So for example, a equ= 15 and b = 16. Okay. So clean and build our application and um we'll try to uh get the output. So the max value is 16. Okay. So we have here uh the B variable 16. So that's the uh value of max variable that is being assigned because this particular um condition returns false. So that's why the value of B variable is being assigned to the max variable. So we can 2:13:55 also try this uh with the other um you know if the a is greater than b so like um 20 so obviously a is greater than b so let's try this exit this for now and then build and run our application. So let's try this. So there you go. The max value is 20. So this condition um returns true because a which is the value is 20 and that's greater than b because b is the value is 16. So it returns the value of a. So like this. So it ignores the second part which is the B because it returns true. And then 2:14:57 of course after uh after evaluation the value of A is being assigned to the max variable that we have here. So it printed out that the max value is percent D and then which is 20. So let's try uh let's try this one more time. just so you can see the output. So the max value is 20. Okay. So this is quite useful if we only want to um check a certain value. So like if you're planning to use if else then you might want to uh use the turnary operators which is like this. So it will just save you um time. it will save you of code space and I think it's clear rather than using the if and else 2:15:57 statement. So this is pretty straightforward when it comes to checking the value and assigning the value to the max variable. Okay. So you just have to remember that it cannot be used to execute code. you just have to set this equal to a variable or you can use this as a return value of a function. Okay. And in this video guys, we're going to talk about the C go to statement. Okay. So, so far we have discussed the if statements and how it is used in C to control statement execution based on some conditions or decisions. Now the flow of execution also depends on other statements which are not based on conditions that can you know control the flow. And of course C supports a unique form of a statement that is you know go to go to statement 2:16:59 uh which is used to branch unconditionally within a program from one point to another point inside our C program. So although this is not a good habit to use you know go-to statement in C but there may be some situations where we can use the go-to statement and it might be you know desirable to to make use of the capability of the go-to statement. So the go-to statement is used by programmers to you know change the sequence of execution of EC program by shifting the control to a different part of the same program. So I think I have mentioned this before in our you know tutorial series that the execution of a C program is sequential you know uh like if you have statements from line six here 7 and 8 and 9. So it will try to execute from line 6 7 8 9 10 2:18:05 sequentially. Okay. But you know we have this uh goto statement to control that particular flow. We can go to the a certain point of our program by using the go-to statement. So basically this basic syntax of goto statement is like this. We have uh this particular syntax of our goto statement. So we have this keyword goto and um label. Okay. And then of course we need to add label at some point in our program. Okay. And of course the long version of this syntax is like this. Let me show you uh real quick. So we have like a few lines and then we have the uh the label and then we have the statement. Okay. And every time the program meets or found the goto statement, so it will 2:19:05 try to find the label that has been specified in this particular line. So go to label and then it will skip the lines or statements between or other you know other statements and it will go directly to the label and it will execute the um statements below the label. in our C program. Now we can um implement this and of course guys it can also be used to this is a forward uh jump in our program because we have specified the go to statement and then it forwarded to the label uh statements below. Okay. But it could be also the backward jump of a program. So for example after exec uh execution of some lines it will jump into this particular um label. So after execution it will jump 2:20:05 to this uh label. That's why it is called the backward jump in our uh C program. So for example if you have like no other label available here. So it will jump the program execution from here and then go back to line nine. So that's how the backward jump inside our C program. So let me just uh clarify this uh it is called backward if you know the go to label is here and then it will try to jump on top or the lines before that uh go to label and it will uh execute all the statements under this. Okay. And it is called forward jump if the label is here. So after this or after execution of this line it will try to go to this particular um line label and it will execute the 2:21:06 statements under this partic uh particular label. So now let's try this and let's just build a practical or simple implementation of this goto statement. So let's just remove this and then we can try to ask for an age just like what we have from the previous video and then we can try to add the label. So for example G and this will be uh the label name. Okay. And then of course we have a statement under this particular label. So print f. So so for example we will try to execute this if the um age is 18. So like you are eligible or something. Okay. Then we can try to add the new line here. And then of course we can try to 2:22:08 add another label. So another label name and we can print um you are not eligible. Okay. Something like this. And we can also add the new line here. Okay. And then of course we do have the statement to ask for the age. So enter your age. Okay. And then semicolon and then we can use the scan f function to get the actual value from the user. So percent d which is the format specifier again and then percent and the variable name which is age. And of course we can have the condition right here like um if the variable age is greater than or equal to 18 then um we can use the statement go to 2:23:13 uh the label G. Okay. And else we can go to the label S. Okay. Now as you can probably observe here we are using if else but we don't have the curly braces right. So you can do the if and else statement like this without the curly braces because we don't we only have one line in this particular or after the condition we have only one line and al also uh else we only have one line but if you have like five lines here you have to add the curly braces. Okay. So in C programming it like understood if there's like one line to execute. So there's no need to use the curly braces. Okay. Now we can try to run this and see how it works. So for example build and run our 2:24:14 application and try to evaluate and see how this particular program works. So basically uh it uh executed line G and line S right. So you are eligible and you are not eligible. Now if we try to go or input number 18 right here. So it will try to uh execute again the line 9 10 um 11 and of course it's going to you know ask for the age again right so it starts from this particular line 9 which is the uh label uh G because we have specified if the age is greater than or equal to 18 then it will try to go to label G. Now if you try to go to our input 16, 2:25:16 so it will try to go to label or yeah line 11 which has the label S, right? And it will just display you are not eligible and it it did not execute the statement from line 9 or line 10. it directly uh go to 11 uh line or line 11 which has the label s and then it printed out the um statement you are not eligible and also uh it also adds the or I mean asked the age again and then it uh asks for the uh input from the user. Okay, we can try this one more time. So for example 15. So it's going to uh execute all the lines starting from line 11 with the label uh 2:26:17 name s. Okay. So guys um as I've mentioned uh earlier that the the goto statement is a unique form of statement. Okay. And sometimes uh it is not advisable to use go to statement in your C program. But there are situations or conditions that you might want to use this particular go-to statement. So for example um if the you uh if you want to skip some of the lines in your program. So let's try that. Okay. So like for example you have statements like this print f and then this is the end of the program. Okay. And then 2:27:17 um we can go like instead of using S we can add a label here E and then it will execute you know um E instead of S. So basically uh after this condition returns false then it will execute this and it will call the label e and then execute that this is the end of our program. So let's try that uh execute or exit our program first and then build and run. So let's try to input first 18. So it's going to you know um execute from line 9 until line 15 and then if if we try to input 10 then it's going to 2:28:20 say this is the end of the program. Okay. So I think um that's all there is to it in this tutorial guys and I hope that's clear on how to use the goto statement in C. So again this is quite useful in some situations and in this video guys we're going to talk about loops in C programming. So sometimes it is necessary for the program to execute the statement several times and C loops execute a block of commands in a specified number of times until a condition is met. So in this video tutorial you will learn um about all the the looping statements of C programming and along with their use. So as you can see computer is the most um suitable machine to perform repetitive task and it can tirelessly do a task tens of thousands of times. Okay. And basically like every 2:29:21 programming language has this particular feature to instruct to do such repetitive task with the help of certain form of statements. So that's why we have this loops and then of course guys in C uh the C programming language supports like three types of loops. So we're going to discuss first uh while loops. Okay. So we have while loops, we have do while and of course we also have the for loops. Okay. So we're going to dissect each type of loop so that we could you know better understand how it works and uh how we can use these loops in in a certain situation. So basically guys when we say loop I'm just going to show you a simple flowchart. So we have here a simple flow uh flowchart that describes the uh nature of loop or loops 2:30:23 in general. So we have like start and then we can declare a counter or a variable counter and then our program will try to evaluate the condition and then if the condition is you know returns true it could um execute statements and then increment the counter and then uh again evaluate the condition. If the like for example the increment counter is equal or you know greater than something and then execute statements uh increment counter and then uh evaluate condition and lastly uh if the condition is met then it will stop the execution of that particular loop. So basically guys a loop is just you know doing or executing repetitive statements inside our C program. So there are like um control statements we have uh 2:31:23 statements that we can use. So we have uh break we can have like um continue and then of course we have the go to statement that we have discussed previously in our video tutorial series. Okay. So as I've uh as I've said uh we will discuss first the while loops in C programming. Okay. So see while loops statement allows to repeatedly run the same block of code until a condition is met. And of course while loop is the most basic loop in C programming. And while uh while loop has one condition and it contains uh or it executes as long as the condition is true and then the condition of the loop is tested before the body of the loop is executed. So uh the syntax for our while loop is like 2:32:25 this. So we have the keyword while and then uh a condition. So like a test expression and then if this condition is like true then it will try to uh execute the statements inside this particular while loop. Okay. Now we have like we can have a very simple application for this. So for example we will try to implement this. Okay. So we can declare like a variable. So int n= 1 and then times = 5 and then of course we can declare the while loop for our program like this 2:33:25 and then open and close parenthesis and then we can say n is less than or equal to times. Okay. So we have to add the curly braces for that and then inside this curly braces uh these are the statements that will be executed if this particular condition is true. Okay. So it will try to print like C while loops and then we can add the percent or yeah percent D which is the format specifier for our int variable and then we can display the n. Okay. And then of course we can we can increment the v uh the value of n by using the increment that we have discussed before which is n ++. So 2:34:26 basically this is just you know uh basically saying n= n + 1. Okay. Uh I think uh we have already discussed that the n++ increment in our video uh previous videos. Okay. Now we have set the value n equals to 1. Okay. And then we have set the number of times the loop should be executed. So that's basically five. Uh there should be five execution. And then we uh added the while statement and then check the condition if n is less than or equal to times then uh execute this statements right here. So we can try to check this build and run our application and try to see the output of our program and I'm going to you know slowly explain to you what happens in this particular 2:35:28 program. So you can see the output uh uh right here cy loops one c y loops two and then three four and five. and after uh five it no longer executed because it you know ended the loop. Okay. So uh I'm going to explain to you how we got this output. So first thing as I've said we declare n equals to 1. So in this condition 1 is less than or equal to five which is the value of times. So basically and of course it is true that 1 is less than or equal to 5. So that's why it executed this particular statement see loops and then it displays the value one right here. Okay. And then it incremented the value n. So now the n 2:36:30 becomes two. Okay. And then it will uh go here in our condition once again. So 2 is less than or equal to 5. So that's true because obviously 2 is less than or equal to five. So that's uh it executes this statement right here. Cy loops and then the value of our n which is two. Again it incremented the n variable. So uh the n now becomes three. So after that one uh we will go back here in the condition is three equals or I mean less than or equal to five. So that's true because three is equal to or I mean less than to five. So that's why it uh printed the uh output right here. Cy loops and then the value of our n equals to three. And now after 2:37:32 that it incremented another time the n and the n becomes four now and it go back to the condition is four less than five. So basically four is less than five obviously. So that's why it printed out this cy loops and then uh four the value of our n and again incremented added one to the n variable and then the n now becomes five and then go back here in the condition is five less than or equal to five. So it uh it return uh true again because five is equal to five. So it printed out C while loops and then the value of of our n which is five. Now it incremented another time the n variable and now the the n variable becomes six and it will go 2:38:34 directly here in our condition is six less than or equal to five. So it returns false because six is not less than or not even equal to five. That's why it uh ended the loop and it never executed the uh this particular statements right here once again because six is not less than or equal to five which is the value of our times variable. So in this video guys we're going to discuss another type of loop which is the dowhile. So from the previous tutorial we already have discussed the while loop. Okay. And then we implemented a simple iteration program where we could see the value of the variable each of the iteration of our while loop. Now the difference between while loop and dowhile is that the while loop will try to evaluate first the condition and then if this 2:39:34 condition is you know return true then it will execute the statement inside this particular while loop. Whereas when we are trying to use the dowh loop then the statements inside the loop will you know execute at least once before the condition is being evaluated. So the syntax for that is like this. We'll just remove this for now all the lines of the while loop from the previous tutorial. Okay. So this is the format or basic format of the dowhile statement or dowhile loop in C. So basically we have the do keyword and then open and close curly braces and then the statements or group of statements. Okay. Now after the curly braces then it will uh have this the while keyword and then open and 2:40:36 close parenthesis with the condition inside it. So as I've said earlier guys that this particular loop will try to execute at least once before the condition is being evaluated. Okay. So as you can see if you want to like execute first some statements before you could evaluate the condition. So so the dow loop is the way to go. So we will try to create another program guys showcasing how this particular dowh statement or dowh loop looks like or how it works. So basically guys we could um initialize some variables here. So for example the n so int n equals 1 and then we could also uh declare another variable which is times. So basically what we are doing here or 2:41:36 what we're declaring here is two variables for our uh do while and the n uh represents the number or I mean the value of the iteration or the value of the variable each iteration and then of course the times is the number of times the loop should execute. Okay. Now inside our do while or do statement, we could add a print f statement here and then could say c do while loops and then the format specifier percent d back slash n and of course uh the n variable. one. Okay, so we have this uh print f statement. So basically what what we're trying here is we're trying to display the value of n every 2:42:41 um you know execution of this particular statements. Okay. And in here below this print f statement we could increment the n by you know uh using this statement n equals n + 1 or you could simply use the n++ version of this particular statement. So n= n + 1. So again every iteration we would try to increment the value of our n + 1 and then inside here um the while and then open close parenthesis we could add the condition. So for our condition you could add the n and then less than or equal to the number of times we want this while loop or dowh while to be you know executed. Okay. So I think that's all for this um 2:43:45 dow while statement. So we could try to run our program and then uh build and run and see how this particular program works. Okay. So basically guys I will try to explain it to you how this or how we got this um output. So from the initial um value of rn we have uh executed the do statement right here. So we printed out like the value is c do y loops then percent t and then the value of our n is 1. Okay. So after this iteration we um increment the value of our n by one. So that's n equals n + 2. Okay? Or I mean 1 n + 1 and then the semicolon 2:44:48 and then of course we will try to evaluate this in our condition. So 2 is less than or equal to times which is five. So of course 2 is less than five. So that makes sense and then it will try to um execute the statements inside the uh this curly braces. Okay. Then print f c do while loops and then of course it will try to to output the value two. Okay. After this the n will be incremented again by one. So n= n + 1. So the value now or the end value now becomes um three and then evaluate it in our uh open and close parenthesis. So three less than or equal to five. So obviously 3 is less than five. So it will try to implement or execute 2:45:50 again the statement inside our cur braces and then display three. This will be the line uh three and then of course it will increment again the value n and it the n becomes four now and then uh evaluated once again is four less than or equal to 5. So um basically four is uh you know less than five. So it will execute the statement print f again display the value four and then um increment again the n uh it becomes five and then after that it will try to evaluate the statement is less or n is less than equal to 5. So we have set now the value to five. So five is equal to five. So it will try to uh execute the 2:46:52 statement once again. And the the five value now becomes or the end value now becomes six because we try to increment it here. So six will be evaluated inside our while statement. Then six is less than or equal to five. So that's basically not true because of course obviously six cannot be less than or cannot even be equal to five. So that's why it will try to end the loop because the condition returns false already. Okay, so that's how the dowhile statement works. And guys, make sure that um there's like infinite um end of your loop because there are cases that you know the condition will not be evaluated uh into false at some point in our program. So that will make it like the 2:47:54 infinite loop. So the concept of infinite uh infinite loop. So be careful to place a uh condition here that will try to or like will be evaluated false at some point in our program because you don't want to have the infinite loop because uh the program will run infinitely and you don't want that it would you know consume the memory of your computer. So that's why you you need to be um careful with the infinite loop. So make sure again to add a condition that will be evaluated as false at some point in your program. And in this video guys we're going to discuss another type of loop which is uh for loop. So from the previous tutorials we have like um discussed already what is while loop, what is dowhile and how it can be used in our C programming or C programs. So 2:48:56 as I've said guys in this video we're going to discuss for loops and of course we're going to describe the syntax of for loops. Okay. So the syntax for for loops guys is like this. I'm going I'm going to copy and paste this here. So we have here the four keyword and then we have the open and close parenthesis in which we have we can you know there uh there are like three um statements that are available for us. So the first one is the init or initialize and then the second um statement is the condition and the third one is increment or it could be also decrement. Okay. So this three statements inside this open and close parenthesis is separated by semicolon. Okay. And of course guys each 2:49:59 of this um statement plays you know a big role in our for loop. Okay. Now we can try to implement our very simple for loop. So for example let's um declare a variable for our for loop. Um inside the initialize statement. We could you know um initialize a a variable right here. Like for example, int x equals 0. So we could do that here. We could initialize our variable into something like zero or it could be one if you want to start uh one. So basically guys, it is uh the same as declaring the variable here. So int x0. So you could also do that here. um initialize the value to x. So uh this two is just the same. So basically we're 2:51:00 just declaring the variable and setting the initial value. So for example zero or one. Now the second statement for this particular uh for loop um we could you know uh add the condition. So the condition is something like this. We could check if the x variable is less than or equal to five just like what we have from the y loop and do y loop. So we're checking if the value of the variable is less than or equal to 5. And of course the last part or the last statement for this particular open and close parenthesis for loop. You could you know add the increment or it could be the decrement depending on the initialize the condition of course in your for loop. So for example we want for now is to increment. So you could actually do this like this x= 2:52:03 x + 1 inside the for loop and then of course guys the statements inside the curly braces. So the statements you know you could execute statements right here. So for example print f the value of x colon and then the um format specifier percent dlash n to uh have a new line then specify our variable x and then end this off with a semicolon just like this. So guys, basically what we're trying is to display the value of the variable x each iteration of this particular loop. So we could, you know, build and run this application and see how it works. Now we have this um output. The value is one, the value is two, the value is three, the value is 2:53:05 four and five. So guys, I'm going to explain to you how we come up with this uh output. So at first guys, you know, we declare the uh variable x and initialize the value into one. So now the value for our x is one. Okay. So value of rx is one. Um one. Okay. And then um let me write first is equal or x is equal or less than or equal to 5 and then uh increment. Okay. So, so for example at the first iteration of this for loop we have initialized the value into one or yeah the value of x into one and then we try 2:54:06 to evaluate the statement is x is less than or equal to 5. So of course x is less than uh five since the value of x equals to 5. So this returns uh true. Then it will um execute the statement uh the value the value of x it should be x right there is one. Okay. And after this after execution of this particular statement it will increment the value of our x. So at the second iteration it will be two. Okay. So of course two is less than five. So that's basically the um condition will return true. And then of course it will display the value of x is 2:55:09 2 and then another iteration three. So 3 is less than or equal to 5 right and obviously the three is less than 25. So basically uh it will return true and then display this statement and um until the x will become six. Okay, six and then it will evaluate is 6 less than or equal to 5. So basically this is false and then it will terminate the loop or it will end the loop itself. So that's how we got this um output. The value is 1 2 3 4 and five. So this 2:56:10 particular output guys is incremented. So the value of our x is increment like 1 2 3 4 and five. But anyway guys we could you know make it like 5 4 3 2 1 and we will initialize our variable x uh differently. So for example let's try to revise our um for loop and we will start from five. Okay. So the initial value of our x is equal to 5 and of course we will check if so for example is x is greater than or equal to 1. So now we're doing the reverse of the increment and of course guys you can you know add the increment statement just like this x = x -1 and of course you can use the post increment that we have discussed from earlier videos in this particular uh 2:57:13 series. So you could do it like this x - and then we could you know display the value of our x. Okay. So let's try this once again and build and run our application and of course we're going to get the reverse output. Okay. So we have here the initial value five and then four and then three and then two and then one. Okay. So guys, of course, you can always try to, you know, add another for loop inside this loop. So as what we have from the previous tutorial, so you have like the nested if and else statement. And of course guys, you could al uh you could also have nested for loops or nested while loops in your program. So for example like this you could you know um add another for loop here. So for example int y 2:58:16 um is we will set the initial value to one. Okay initial value into one and then we could um try to evaluate the statement. Say for example, is y um less than or equal to x? Something like this. And then we could add the increment y ++. Okay. And then open and cur uh open and close curly braces. And then of course we could display the value of our x and y. So the value of X for example percent D and value of Y is something like this. The value of X is percent D and then the value of Y is 2:59:18 percent D again. Okay. And then we could also specify the value of our Y. Okay. So we could you know build and run our application and of course we will get this particular output. So the value of x from uh initial value of our x is five right. So it will try to run five times and then it will try to display one two and uh one 2 3 four and five for our value of our y. Okay. And then of course we have the um four and then we also have three and then we also have one and uh two and one. So you could do that guys. As I've said you can do um nested for loops or nested loops in your C program. So you could 3:00:21 increment you could use decrement inside your loops. Okay. So, and guys, if you want to practice more about using loops, you could, you know, try to print different patterns. For example, you want to print a rectangle or um triangle, you could uh display uh inverted triangle by using the um aster symbol. So, you could do that by using your loops. And in this video guys, we're going to discuss how we can use switch multiple selection statement inside our C program. So from the previous tutorials guys, we have learned how to use if. We also have learned how to use if else and of course how to use the nested if else statement inside our C program. Now, occasionally there will be an algorithm that you know will contain a series of decisions in which a variable or expression is tested separately and the output or the 3:01:23 statement or the actions that could be taken depends on the series of decisions. This is what we called multiple selection and Z provides the switch multiple selection statement to handle such decision making. So now let's try to look at the basic syntax of switch statement. So the switch statement guys starts with the keyword switch and then open close parenthesis and open close curly braces and inside this open close parenthesis is the variable. So variable of interest. So the output guys or the statements that are executed depends on the value of this particular variable here. So we have here switch statement or switch keyword and then open close parenthesis and then the variable or expression and then of course open close parenthesis and inside this open close parenthesis 3:02:24 guys are the case label. Okay. So, so for example, you want to check for the value of one and then it should be followed by the break keyword which means that it signifies the end of this particular case one. Okay. And then you could you know add several case label here. So for example case two and then you could add the break statement. You could also add another case label three and then the break statement. Um, and of course you need to add the default case. So the default case guys will serve or will be executed if there's no case label that satisfies the v uh the value of our variable or expression. So say for example we have here 1 2 and three and the input is four. So it's going to you know uh 3:03:24 execute the default value or the default uh statement default case. Now you could inside this particular case we could execute some statements. So for example you have chosen case one. So we could end this with a semicolon. So we could do the same for the other cases. So like this. So in this particular case you have chosen case two and you have chosen three and the default is you haven't you have not chosen from the uh values one and two and three. So one two 3:04:25 you have not chosen a value in one 2 3. Okay. So we could try this guys and of course we need to add a variable here. So int input and then we could you know uh scan f or ask the input from the user. So percent d and then the variable input and percent and then input. Okay. And then guys we could uh print. Please choose a number. Number one 2 or three. Okay. So let's try this. 3:05:34 Okay. So let's try to build and run our application. So we have uh we have to update this. So variable of interest is of course the input. Okay. So let's replace this with the input and then um build and run our application. So as you can see it's going to run and um we need to input a number here. So please choose a number between 1, two and three. So so for example we choose or we input one. So you have chosen case one. Okay. And then let's try um another one. So for example three. So you have chosen case three. So basically guys it uh executed the statement under this particular case label. Okay. And say for 3:06:35 example you have inputed or you have uh selected number four instead of the values 1 2 and three. So it's going to uh execute the statement under the default case. Okay. So you have not chosen a value in one two and this is uh should be three. And we could also use letters and characters inside our switch case statement. And basically here in our example, we're using the int type as the data type for our variable of interest input. And then we're setting the um case labels into int one and then int three. And then we're executing statement based on the value of our input. Okay. But as I've said, we could use characters or letters. And so for example, you want your user to input letter A. Um you want your user to input 3:07:36 letter B. And then you could execute statement based on that particular letter. So for for now, let's try to implement this inside our program. We want our user to input letters A, B or C. And then we could you know output uh different statements based on that particular character. So now we could display instead of please choose a number we could you know um say here enter a letter you could select a b or c and then um based on this particular letter we could output or um execute commands or execute statement. Okay. And then we're going to use the method um get get char. Okay. So this will return the int um equivalent of the letter or the 3:08:38 character that the user has inputed. Okay. And then we could try this inside our switch uh statement. So instead of using case one, we could say here case a And then here we could use case B. And of course here we could choose or set the case C. So every time the user types in the A. So it should print you have chosen option A. So we could copy and paste this. So B and then of course uh you have chosen option C and in our default wrong option. Okay. So we could try this. Let's try to 3:09:38 run or build and run our program. So enter a letter A. For example, we type in A. So you have chosen option A. So let's try this once again. So for example, the letter that has been or the user inputed is B. You have chosen uh B. Let's try this once again. So for example, the user types in D and then it will display wrong option. Okay. And then of course guys, you can make it this way also. So for example, you want to um add also the uh lower case of letter A. So case and then the lowerase version of A. So you could do it like this. So you have case A and then case with the lowerase A. And then you could 3:10:40 also do the same with the B. And then you could add the lowerase uh B here. And of course you could also uh do the same for your C. So uh lowerase C, lowerase B, lowerase um A. So it's going to you know um execute based on this. It doesn't matter if it is uppercase A or lowerase A. So let's try this once again. So for example we want B. So you have chosen option B. Okay. Now let's try this another time and then C lowerase C. So you have chosen option C. Okay. So I think um it is clear to you how to use the switch case statement in Z programming. And in this video guys, 3:11:41 we're going to discuss and I'm going to teach you how to uh implement functions in our C program. So basically guys, a C function is a self-contained block of statements that can be executed repeatedly whenever we need it. So um if you think about it, it is just you know a group of statements that we could um call and we could use repeatedly uh within our C program. So in this particular video guys, we're going to discuss the benefits of using the functions in C program. We will also um discuss the two types of functions in C. Um also the parts of function, the function prototype, the function definition and of course we're going to uh discuss also how to call a function inside our C program. And lastly, we will implement a basic program to illustrate the addition of two numbers using userdefined function. So if you're 3:12:44 excited guys, please make sure to watch the full video uh you will learn more in this particular uh video tutorial. And by the way guys, if you are new here in our YouTube channel and you like content about programming, so go ahead, make sure to subscribe and press the notification bell so you'll get updated whenever we have a new upload regarding different programmings or different topics. So we have topics Python, Java, Java effects, C programming and many many other um topics regarding programming. So now let's try to talk about the benefits of using function in C. So there are a lot of functions that you know we could uh associate in uh using function inside our C program. So the first one is modularity. So when we are using functions it could provide modularity in our um code. So it means that we could you know define different functions. We could uh readily call our 3:13:46 functions and um we could call this particular function if we need it or we need to execute certain statements. And of course guys the function also provides you reusable code meaning uh it will save us um a lot of space and you know it could be our code could be you know read uh more readable um by using this particular function feature. So that's readable or reusable code and then um in large programs debugging and editing task is easy with the use of functions. So functions uh make it easy for us to implement our programs. So the program can be modularized into smaller parts. That's what uh I have said earlier that we could you know develop a certain module inside our C program and 3:14:47 then we could call that particular module or statements or group of statements if we need in a particular situation and number um the the next one is separate function independently can be developed according to the need. So, so for example guys, we could group our statements depending on the need or you know depending on the the function or or the purpose of that statement. So we could group that statements and uh place it inside our C function. So actually guys there are two types of functions in C. So the first one is um let me type it here. type of functions. We have the first one um builtin function. Okay. So built-in function um of course the system provided this functions and stored in the library. Therefore it is 3:15:48 called um library functions. So we have like we are using scan f print f uh str uh strc py um strl lwr strc mp str length str cut and many more functions that are already available for us whenever we try to run a program. So from the previous tutorials we have used the print f. So as you can see this particular function we did not um implement this the system provided it for us the print f and this particular function will let us display um certain um objects or statements that we want uh we want to display inside our C program. So to use this functions you just need to include the appropriate C header file. So that's why we have here the include statement at the top of our 3:16:50 program. So basically we're including all the necessary function that we could use inside our C program. And of course guys the the the second type of um method is what we called the userdefined functions. Userdefined functions. Okay. So, user define uh userdefined functions. These are the functions that are defined by the user at the time of writing the program. So, that's basically us or the programmer um that you know define the um functions. Okay. And then of course the same with the uh built-in function. We can you know readily use this particular functions inside our C program. Now there are there are also parts of our function in C programming language. We have the function 3:17:50 declaration. We also have the definition and we also have the function call. So this is basically the the uh actual flow of the function. We have the function declaration declaration and then we have the definition. We have of course the function call if you want to use that particular function. So we have here for example syntax for function declaration. So we could um this will be the function declaration. This is just an example guys on how you could declare a certain function. So the syntax for that is data type and then function name and then of course open and close 3:18:52 parenthesis and then in here we can specify the parameter list. Okay or the variables that we want to use inside this uh particular function. So our example of that is like this int which is the data type and of course addition which is the uh name of our function. So addition and then the return type is int and then of course the list of parameters and in this case we don't have any parameter in this particular function addition. So we also have the function definition. This is actually what um the uh actual function would look like. So this will be function declaration or I mean function definition. Okay. So we could uh this the basic syntax to this is um return type 3:19:55 and then a function name and then function arguments. and then curly braces. So it should include the close or open and close curly braces and then inside here is the body of the function or simply the statements that we want to execute inside this particular function. So whenever we want to call this function, this will be the statements that that you know would be executed inside this particular function. So in order for us to call a function inside our C program, we just need to specify the method name and of course we need to supply parameters if there's u if there are any. And we would also need to specify the return type of our function. So now let's try to uh implement a 3:20:57 simple program that you know that could u illustrate the addition of two numbers um using userdefined function. So we have here the main function. All right. And then in here after the main or after the closing curly brace of our main function, we could create we could create our own function right here. Let me close this first so you can uh you know see better. So we could add a function here returning the total of two numbers. Okay. So we could declare it like this. Int and then addition open and close c uh parenthesis and then open and close curly braces. And of course guys as I've said this is this will be the body of our function. So in here we could um 3:21:57 define local variables. Okay. So local variables. So for example we we have int num one equals 10 and then num 2 equals 5. Okay. So these are local variables meaning these are the variables that are declared and defined inside the addition method or function. Okay. So we could say here return and then num one plus num 2. Okay. So that's the statement that we want to execute when whenever we try to call the addition method or I mean function. So inside our main function we could call this um method addition. So we could declare a variable here int answer 3:22:58 and then we could say answer equals and then the addition. So basically whatever the the return value of this addition um method it will be assigned into our answer variable. And of course we could print or display this particular value. So we could say the total of two numbers is and then the format specifier where just you know percent and then the answer which is the answer variable. Okay. So we could you know uh build and run our application uh application and then we have here the output the total of two numbers is 15. Okay. So that's how the function works. And as you can see here we have defined our 3:24:00 function with the statements inside our C function to return the total of the number one and number two. And then inside our main function we have declared the answer and then the type is int of course because the int is uh should correspond to the return type of this particular function. And then answer equals the addition. And then the last thing that we did here is to display the total of two numbers and in this case 10 and uh five which makes it you know the value or the output is 15. And in this video guys we're going to learn how to use C function arguments or parameters inside our function. So from the previous tutorial, we have learned how to define and declare our function inside our C program. And of course, we have learned how to use the basic syntax 3:25:02 to create a function and implemented a simple function that could add two numbers. Okay. So as I've said guys, in this video, we're going to focus on the function arguments or function parameters. So while calling a function the arguments can be passed to a function in two ways. So there there are two ways on how we could pass the parameters or the arguments into the function. So the first one will be call by value and the second one is call by reference. Okay. So in call by value way the actual parameter is passed to a function and then new memory area created for that particular past parameters and then it can be used only within that function and the actual parameters cannot be modified in the call by value uh way of 3:26:04 you know passing the the argument into our function while call by reference. So instead of copying a variable, an address is passed to a function as parameter and then uh we could use the address operator which is the amperand symbol. Uh I know you're already familiar with this. So address operator is used in the parameter of the called function and of course the changes in the function reflect the change of the original values. So we could uh understand this better if we try to implement our function by you know creating a simple project or simple application that could demonstrate the call by value or call by reference. So first let's try to create a program that would pass the argument as or it could call by value. So the 3:27:05 first thing that we're going to need is of course to uh it's actually the same with the program or I mean function that we have created from the previous tutorial but the difference is that in this particular video we're going to use parameter or argument. So the first um variable that we're going to declare here is the answer. So the type is int and then we have the variable um name num one. So the value is five and then int num two and then the value is 10. Okay. And of course guys we could declare the function. So for example, we could um create the function right after this closing curly brace of our main function. So the first 3:28:07 thing of course is the return type and in this case int and then the name of our function which is addition and we could say here int a and int b. Basically it means that this particular function would accept two parameter int b and uh int a. Okay. And then in here we could return the value or the total value of these two parameters. So a plus b. Okay. And of course guys we could declare the function right here. So we could you know add the function declaration here. function declaration. So you could say here int addition and then this particular function is going to take two parameters int num one and int num two. So as you can see here guys this is only the function declaration. 3:29:08 Okay. And this is the function um definition. Function definition. Again, this is function declaration declaration and function definition. So now we could try to call our function by value. So for example, we could say here um answer and then equals um addition which is the method or the function that we have created here and then we could pass along the values of num one and num two. Okay. So let me explain this first for you so it would be clearer for you. So we have here the parameter num one num two. As I've said in call by value the actual parameters 3:30:10 cannot be modified because num one and num two is it won't change um even if we you know change the parameters here the int a and b. So the value of num one and num two would not change even if we try to modify this int a and b inside our addition function. So the actual parameter is passed to a function and then new memory will be created for our parameters e uh int a and int b uh int b. Okay. And of course um we could display here the result. So print f and then of course the statement the addition or you could say the total of two numbers is and then the format specifier percent d and then the variable answer. Okay. And 3:31:14 then we could you know clean and build our application or or build and run and it should display the output something like this. The total of two numbers is 15. Okay. So you get the point. This is the calling of function by value. Okay. Now if we want to try to call a function by reference as I've said we're going to use the amperand symbol. So amperand symbol or it is the address operator and we're going to use that in our parameter of the called function. So let's uh let's try to implement a function that you know could call by reference and you should see by now how you how uh the call by reference and call by value is different. So the same thing we're going to declare the um 3:32:16 method here the return type is int and then the name is addition and then it's going to take two parameters with type int. Okay. And then we could uh also use this int answer and then the same value for example. And now guys instead of just using this num one and num two we could add the address operator the amperand symbol or the address operator in state programming. So basically guys uh we're sending or we're passing the uh address of this particular variable into our function. So so whenever we change this um value in inside our function, it's going to reflect the value of our num one and num two. Okay. So um we have here the amperand or address operator and then we call the um 3:33:19 function right here and then display the answer. And of course we need to add the um aster symbol for this uh variable here or the argument and then um one for the other variable p. So this means that it is the operator that is used as a pointer to a variable. So it's going to point the address to that particular um value of num one or num two. So of course we need to add this also here and of course for our variable num two. Okay. And then as I've said if we want to change the value of num two here in inside our function we could do that and it's going to reflect the changes of this num two and num one variable. Okay. And then of course we could still use 3:34:21 the aster symbol here. And let's try to run our program for now. So build and run and it's going to answer or it's going to the output this way. The total of two numbers is 15. Okay. So let's try to modify the um num one and num two. Okay. For example, inside this uh particular function, we're going to change the value of our variable a. So instead of five, it's going to like maybe six. Okay. So we could do that by using this particular um variable argument. We could uh add here the um variable a and then we could say six 3:35:22 then semicol semicolon at the end. And we could try to display the value of our a. So the value of a and then percent d and it should you know the variable a correspond to the variable num one. Right? So we could copy and paste this. So notice that num one equals to five here. Okay. So let's see what's the output of this. So build and run our program. So as you can see we have here the the output the total of two numbers is 16 and the value of a is six but as you can see here a corresponds to the num one right num one. So we have here num one equals to five and then we change the value of num one by using the the reference of variable a and then we set it to six. That's why we're getting six 3:36:23 here and then the total of our addition is six. Okay. So, and in this video guys, we're going to learn how to use arrays inside our C program. So, basically guys, we can declare variables to hold single element or a single value inside our C program. So, for example, like this age or int age and then we could um assign it to a value five for example like this. So this particular variable will hold the value five or a single value five and then it's uh going to assign to the variable age. Now what if you want to store like 50 um series of values like there are um 50 age that what uh that we want to save. For example, there are like 50 persons that we want to save the ages, then uh this 3:37:23 particular declaration and statement will not suffice because we're going to like uh declare it one by one. So for example int age 2 and then 6 and then int 3 = 7 and int uh age 4 equals like 10 and so on. So basically guys, this is not a good programming practice to declare multiple variables or yeah multiple variables to hold a single set or single type of data. So that's why we need the capability of an array. So basically guys, the array is a data structure in Z programming which can store a fixed size uh sequential collection of elements of the same data type. So in this case guys, we're just you know collecting and saving um the same data type of data 3:38:26 which is int. Now what we can do here is we can define an array and then we could set the length for example we want to save um 50 um ages right and then we could save the age into that particular array. So let me show you an example. So this is how you can create an array inside your C program. So basically the first um thing is you have to specify the type of your uh data that you want to save in that particular array and then the array name. So basically this is just like the uh variable name. So you have to label your container and then of course you have to specifi uh specify the type of data that you want to save in this particular array and then you have to add the spare brackets and this signifies that this particular variable is an array and then inside uh 3:39:27 this particular square bracket you can uh declare the size or you know specify the size or how many um values that this particular uh variable could hold. Okay. So in a typical C program you could do it like this. So for example the type is int right and then you could say ages or age right? So this is the array name and then this uh square brackets and then you have to uh specify the size. So for example five. So you want to collect five values or five age of five persons. Okay. So again this is the type in you have to specify the type and then you have to specify the array name the the variable name and then of course square brackets and then the size of your array or uh basically the amount of values 3:40:27 that this particular array could hold. So after this you could say equals and then you could specify the array or the elements of your array. So for example we could take all these values 5 6 7 and 10. So five 6 7 and 10. And for example because our array contains or should contain five elements you could add another one here. for example um eight or something. Okay. So again this is how you can create an array of um values. So int is the data type and then of course we have the array name and then square brackets with the size five. Uh for example, your um array should be five and then equals and then the uh curly braces open and close curly braces and then the actual element 3:41:29 value. For example, in this particular uh statement we have 5 6 7 10 and 8. So that's how you can initialize an array in C program. Now you can access this particular um or this elements or these values by using what we called index. So in C programming or any other programming with um um arrays you could access the values by using index. So this index is zero based. zero base it means that it will start it will start with zero. Okay. So meaning uh if you want to access the value five so you you have to use um zero index. Okay. This will be 3:42:31 zero and then this will be one. This will be two. this will be three and this will be um four. So again if you want to access or get the value of this particular element you have to use the zero uh value of your index and then one for the six 2 for 7 3 for 10 and um four for 8. So let me show you that how that works. So for example, you want to display the value uh six. Okay. So all you have to do is use the print f statement and then um double quotes and then percent d the format specifier for our um integer values and then comma of course and then we could use the name of our um uh what do we call this array. So ages 3:43:34 and then we could um specify the square bracket and then index of the element that we want to use. So for example six. So we want to use the index one for that to be able to get the value of six. So let's try this uh build and run our program. So as you can see the output is six. As you can see here six right now if you want to get the value 10 you have to use the um index three for that because as I've said the value is equivalent to the index three of our particular array. So build and run our program and it should output the value 10 which sits on the index three of our array. So that's how you can access the value from our array. 3:44:34 Now say for example you want to change the value of this array. Right? So we have here 5 6 7 8 or 5 6 7 10 and 8. And then if if you want to change the value of so for example and this one five the first element all you have to do is specify the index also. So as the index here for example 11 column that's all. So ages. So for example, we want to display this what will be the um value of our uh index zero. So we could test that by using the print f statement and then instead of three you could specify the value zero or index zero here. So let's try this build and run. And as you can see here 3:45:34 instead of five the initial value of our uh index zero it returns 11 because we assign it or we modify it by using the element or index zero equal to the uh 11 which is uh that's why we are getting the 11 value here. Now this is particular useful guys or if you want to work with the array. Um one of the best structure or the best statement that you could use to iterate the array is by using the uh for loops or loops inside our C program. So we could say this here for example for so we're going to use the for loop statement here and we could specify for example um int index equals to zero. We want to start with zero because as as I've said the index of our array is zero 3:46:36 base. It will start with the zero number. Okay. So index equals zero and then semicolon and we're going to say here uh here index um less than the uh actual value of our array or I mean size of our array. So five less than five. So another semicolon and then index++. Okay. And inside the for loop we could display the element of our array. So we could use this print f statement. And then we could uh use the index variable here and then change this. You could say index equals percent d the format specifier and then um you 3:47:38 could say equal to percent d and then of course the uh actual value of our array index. So in here we could specify the index. Okay. So it should display the index current index and then it should display the actual value of that particular index. So we could build and run our program. Um let me add first the back slash n or new line um state sequence new line and then it should display this particular output. So at index zero we have the value 11 at index one we have the value six right index 0 is 11 because we already modified our array specifying the array or index zero 3:48:40 should be equal to 11 and then at index one equal to 6 right here uh index 2 should be equal to 7 index 3 is 10 index 4 is 8. Okay. So that's how easy for us to access and change the value of our array and that's how we can uh define our multi or I mean single um dimension or one dimension array inside our C program. And in this video guys we're going to talk about multi-dimensional arrays in uh our C program. So from the previous tutorial we have learned how to use the um basic array. So we have implemented one-dimensional array. We um trying to display the contents of an array by using the for loop and of course we declare and initialize one-dimensional array from the previous tutorial. Now as I've said from this tutorial, we're going to learn how to work with 3:49:40 multi-dimensional array. So basically guys multi-dimensional array um works like uh the same with the one-dimensional array but the difference is that it contains um the array contains um set of arrays. So in C programming language uh it will allow us or it allows us to use multi-dimensional arrays and the declaration or multi-dimensional declaration for that is by using the type of force as I've said from the previous tutorial if you want to u store multiple values um you have to use arrays and in order for you to declare an array you have to specify the type of that particular array. So you have to specify the type and then of course the name of the array and then you have to specify the size here. So for example size. Now this is um good for uh 3:50:42 one-dimensional array. So you have to specify the type, the name and of course the size of your array. Now comes the multi-dimensional array or two-dimensional array. So you could do it like this. So size two and then this is the size one. So this is how you um declare multi-dimensional array or two-dimensional array inside our C program. So the type of course you don't uh you know you don't want to forget that the size of or I mean the type of the value that you want to save in this particular array. So and then the name and then of course the size one and then the size two. Now if you want to create three-dimensional array you could do it like this. size two. I'm in size three. So you have square brackets for your size one, 3:51:44 square brackets for your size two and square brackets for your size three. So again this is how you can declare your multi-dimensional array. But you know the simplest form of multi-dimensional array is by just specifying two um sizes. And basically guys this uh this will represent the columns and rows of your um array or multi-dimensional array because multi-dimensional array works like a table. So size one will be your um number of rows and the size two will represent the number of columns. So let's try this. Let's try to declare and initialize um multi-dimensional array. So following this particular declaration type. So the first thing is of course the type. So int and then we could say here a or a 3:52:46 variable name a. This is the name of our array multi-dimensional array. And then of course we could specify the size for our rows. So for example three right there. and then the size of our columns or number of columns. So that's basically like four and then you could uh you know initialize this by using the equal sign and then open and close curly braces. So in this uh inside this curly braces we could declare or initialize the values for our uh rows and columns. As I've said, uh, multi-dimensional arrays are, you know, composed of, um, arrays right there. Okay. So, we could add array of values right here. This will represent the row one of our array. So like for example zero um one 3:53:48 and then um two and then three. Okay. So again this is for uh initializing the um row initializing the row index by zero. Okay. So we could access this by using the index zero. Okay. And for example uh basically uh we declare it here like um three. So we need to add more um arrays to this. So open and close curly braces and another one to make it you know the length is three. So in here we could display or add four and then five and then six and then um 3:54:49 seven. Okay. And then the other row will have eight then 9 and then 10 and then 11. Okay. So basically we now have u declared and initialized our multi-dimensional array. So the three here represent this rows three rows and as you can see here we have declared four columns. So it should um count or I mean you know the columns start from this 0 4 8 and then um 1 5 9 2 6 10 3 7. So this will the four the the 8 and the zero represents the column um zero and then 1 5 and 9 represents column uh one. So why this is uh representing column 3:55:52 zero that's because our index is you know um is zero base or meaning it will start um counting from zero. So this will be the column zero, the column 1, the column two and the column three. Okay. And of course um we could um try to display the value of this. We could access the values of our multi-dimensional arrays by using the indexes of um the columns and rows. So for example, we want to change the value of um the values that we could get from the row two and um column three. So basically the value of or the value that we could get from um our array index two and three is um 3:56:57 11 because this is the row two and this is column 3. So 0 1 2 3. So we get the 11 or the value 11. So if you want to change this to something like eight. So we could do it or assign a value to this by eight. So it should display 11 or I mean 8 instead of 11. So we could try that. So print f and then um percent d which is the format uh format specifier for our int value. So we could specify the array index um two and then index three. So if we try to compile and run our program, we should get now the value um 8 value 8 as you can see here. That's because we already modified the value 3:57:57 inside the array of index 2 and three. So let's try to comment this and then compile and build our program. And as you can see, we're getting 11. That's because that's the initial value of the array index 2 and 3. Now, we could use array or I mean I we could use um bloops here to access and change the value of our um array or multi-dimensional array. And of course because we're using multi-dimensional array, we could also use um nested loops to change and access the values of our array. So for example um we could declare for loop here and this is for example int and then row equals zero and then uh row is less than or yeah row is less 3:59:01 than um like for example um two or or three. Okay. And then row ++. So basically we're iterating from zero, one, and two because we're we only have like three um rows, but we starting we're starting from zero. So that's make uh that's making it like the value of our row should only be within two not three. That's why we're using single or I mean um less than three right here. And then of course we could make another loop for our column. So int column and then equals to zero and then um column 4:00:02 is less than four and then um we're going to say here column ++. Okay. And then of course we could use this particular print uh print f statement to display the values of our um array. So percent d we could use here the uh array name which is a because we're using the array name a. So a and then um we are going to specify here the columns and rows. So percent D and then here percent D equals percent D. So inside here we could specify the row and then the column and of course the value of that particular row and 4:01:05 column. Okay. So this will be row and of course this will be column. Okay. So again we're just trying to get the value of uh inside our array represented by this particular row and column. Okay. So the these are the indexes the row and column. So let's try to build or compile and run our program and we're getting this particular output right here. But we don't want that. Let's try to add a backslash n to add a new line every uh execution. So as you can see here we have all the values coming from our array. So array and then we have index 0 0. So the value is um zero right there as you can see. And then a 01. So the value is 1. A 02 is 2. a 03 is three. And a1 and uh a10 is four. and so 4:02:10 on. So that's how you can uh that's how you can use the multi-dimensional array inside our C program. Okay. And I think that's clear enough how you could uh iterate and modify your multi-dimensional array by using for loops. And in this video guys, we're going to learn how to use array as a function parameter. So from the previous tutorials we already implemented functions that could take few parameters and then return a value based on the parameter that we have passed um to the function. Now in this particular video guys we're going to learn how to pass the array as a function parameter. And of course we already know how the array uh works inside our C program. We already implemented a simple program that demonstrates the capability of 4:03:11 using array. We already implemented a multi-dimensional array and even uh iterated the content or the elements of our array. Now we could take that further by using a function. And in this video guys, I'm going to show you how you can sum up the values of your array. And then we're going to use a function for that. So as I've said, we're going to pass the array as a function parameter. So here inside our C program, we could um declare a new variable or a new array. So for example, int and then my number array. Okay. So my um my number array is the name of our uh array and then it should take in or has the size of say for example six. So the number of elements 4:04:12 is six right. We could specify the values inside our curly braces. Now we could um uh specify the values 23 uh 30 um 21 um 18 um uh let's say 17 1 2 3 4 5 and another one for our last element say for example 25. So these are all the elements of our array and then we're we're going to sum up the value of this by using a function. So what we can do here is to add a function above the main function or whatever we could also insert function right after the main function. So for example uh the function will return the total. 4:05:14 So it should say int this is the return type and then the name of our array. So total value of array. So this will be the name of our function total value of array. So again this is the return type and this will represent the total value of the elements that we have here. So total value of array and then of course we need to specify the um argument or the parameters and because we're trying to sum up the value of our of our array we could um specify that the first parameter is an array. Okay. So for example int and then number array and uh this is the first parameter and represents the my number array here. Okay. And then we could also specify the 4:06:15 size of the array. So basically we have six here. So we could say here int and then size and again this will represent the size of our my number array. And of course we need to add curly braces inside. And inside this function we could add the logic to add all the elements of our array and then return the sum or the total. So we could say here int total equals zero. Okay, that that's the initial value of our total variable. And then we could um try to iterate the elements of our array by using the for loop statement uh statement the same uh for loop that we have implemented from the previous tutorials. Okay. So for loop so we could 4:07:18 say here int i equals to zero and then i is less than the size of our array and then um i ++. And then inside the for loop, we could say sum or total equals um total plus the number array right there. And then we could specify the index which is we're going to use i. So this is the variable i that we have declared inside our for loop. So number array and then the index i. Okay. And of course guys this is the same uh the same with this particular line. We could write it with this particular um line total equals 4:08:19 plus equals and then uh number array and then of course specify the index of that particular number array. So again this particular line is the same with this line. All we are all we are doing here is trying to um accumulate the total of our number array right here. So after the total plus equals number array we could return the value of the total. So by using the return statement and then of course the variable total. Okay. Okay. So I think our function or our function total value of array is already set. We could now call this particular function uh inside our main function right here. So basically for us to call that particular function all we have to do is use the name which is total value of 4:09:20 array. So total value of array right there and then open and close and then we're going to supply the parameters which is the first one is the array or the my number of uh my number array. So my number array and then of course the second parameter is the size of the um array which is six right there. And then of course this particular function returns int which is the total. We could uh catch the value by using also int. And then you could say here sum equals the return of this function that has the parameters array and the size of the array. And then right after that one we could print the sum of all the elements. So print f and then we could say here 4:10:22 the total value is you could use the percent d and then back slash n and then comma and then of course specifying the sum variable. Okay. And now we could um compile and run our program. So I think we have an error here because we use the comma. So we need to remove that and compile and run again our program should. So it should say here the total value is 134 which is the total of this particular value uh elements here from our my number array. Okay. So we could also add function or I mean add element to this particular array. So it should say uh after 25 we could add like for 4:11:22 example 50 and then another one um 25. So basically the length of our array or the size of our array should be eight because we already added two elements the 50 and 25. And of course we need also to change this particular uh parameter here. It should say also 8. Okay. So let's try to compile and run our program. And as you can see here the value is now 205. Okay. So let me explain to you in details how this works. So first we define the elements of our my number array and the size of this or the number of elements of this particular array is eight right there. And then right after that we call the function total value of array and then 4:12:23 we pass in the my number array as the parameter and of course the second parameter is eight which is the size of our number array. Now for the total value of array function as you can see here it takes two parameters the array and of course the size of the array. And then inside here we uh initialize and declare the total variable equal to zero. And then we iterate the my number array or number array by using the for loop. And then we use the i as the index variable. So i equals to zero and then i is less than to the size that we have specified. then I ++ and then of course uh in order to get the total of the elements we're using total equals 4:13:23 uh total plus number array. So basically this is the same with this line total plus equals number array and then specify the i index. So, so for example, this particular I um the value of I is zero then it's going to get the value 23 and then I value one it should get the 30 I value 2 is 21 I value um three is 18 and so on. So you get the idea and then of course after that we get the um total value and then of course return that to this particular uh variable sum and the last thing is we display that the total value is and then specify the sum of all the elements that we have from this um number array. Okay, in this 4:14:24 video guys, we're going to discuss what is pointers and how we can use pointers inside our C program. Okay, so if you're excited guys, please make sure to watch the full video. We're going to be learning a lot in this particular video and in the succeeding videos about pointers. So basically pointers in C are um you know easy and fun to learn. So there are some C programming tasks that are performed more easily with pointers and there are other also tasks such as dynamic memory allocation cannot be performed without um using pointers. So it becomes necessary to learn pointers to become a perfect C programmer. So if you want to be like almost perfect C programmer so it is necessary for us to learn pointers. Okay. And let's start learning them in simple and easy steps. So as you know every variable is a 4:15:25 memory location and every memory location has its own address defined which can be accessed using the amperand symbol. So I think we already used this particular symbol before in our previous tutorials but we're going to you know tackle deeper what is this particular symbol and how we can use this in um you know working with pointers and it is you know denoting an address in memory meaning the amperand and for example we're going to define here or create a program that could um showcase the capability of this operator and um the basic access to or basic you know access to the pointer address. So for example we have a variable int var one and then we 4:16:26 have char var 2 which is the length for example is 10. So basically guys as I've said this particular variables these variables uh has location or has a specific location in our memory and every memory location has its own address. So in order for us to verify that we could try to print the address or memory address of these variables. So we're going to use print f um function and then in here we're going to say address of var one is um percent x. So this is the format spec uh for format specifier when we're trying to display the address of the uh variable. So percent x and then we're going to specify a new line here and 4:17:28 then comma and then of course we need to use the um percent symbol and of course the the name of our variables for example the var one. So the address of var 1 colon and then percent x the format spec uh format specifier and then of course specifying amperand and the name of our variable one and um we could do also the same for the second one or second variable var 2. So percent x and then this will be var 2. So this is basically guys trying to test if this particular variables has you know we will just display the um address of this variable. Okay. So before we run our program let's change first this because I have uh forgot to type uh number one because this is uh this is supposing that this particular variable has the length of 10. Okay. So that's 4:18:31 char var 2 and then open and close um square brackets and then um 10. Okay. So let's try to build and run our program. And as you can see it's going to display the address of v1 is 61 uh fec and the second one will be fe. So that's basically the address of the variables var one and the var 2. So a pointer variable is a variable whose value is the address of another variable. Okay. So for example direct access of the memory location. Now like any variable or constant you must declare a pointer before using it to store a variable address. So the typical or you know the general form of pointer variable declaration is just like this. We need to specify the type and then the 4:19:34 um asterisk or star symbol or asterisk in other other terms and then of course the variable name. So that's how to declare a pointer variable. So again we need to specify the type and then asteris symbol and then the variable name. So um here the type or type is the pointers base type. Okay. And it must be a valid C data type. And of course the variable name or the var name is the name of the pointer variable. And as you can see guys, this particular symbol aster symbol is sometimes used to declare um or used for multiplication process or multiplication um operation. Right? But in this particular case it is being used as to uh declare a pointer variable. Okay. 4:20:36 Now in order for us to declare um pointer variable based on this particular declaration form. So we could say something like int and then percent or I mean the um aster symbol and then the name of our variable. So this will be um pointer pointer to an integer. Okay. And then we have for example double and then the aster symbol dp and this is basically the pointer to a double. We also have like float and then FP. This will be obviously pointer pointer to a float 4:21:36 and another thing ch and then this will be pointer obviously to a caragler. So the actual data type of the value of all pointers is you know a long hexodimal number that represents the memory address. So whether we declare it as int, we declare it as double, we declare it as float or character. So it's going to do uh it's going to return a long hexadimal number that represents the memory address. Now the only difference between pointers of different data type or data types is the data type of the variable or constant that a pointer points to. So for example this particular um variable points to this variable one then it's going to be a bit different because we are referencing to an int variable. So let 4:22:38 me show you that how you can you know use pointers. We could remove this lines. Okay. Int var one. We could assign a value to this like 20. And then this this will be the actual actual variable declaration. So this particular variable has the value 20. And then we could um declare a pointer variable. So int and then asteris IP. So this is pointer variable declaration. So you get to see the difference between this declaration. The pointer variable uses the symbol asteris. Okay. And then of course in 4:23:40 order for us to store the address of the variable one into the pointer variable IP, we could use IP variable equals the amperand symbol and of course the var. Okay. So basically guys, we're just passing the memory address of this particular variable one into the pointer variable IP. Okay. So for example, we could print the address of our var one. So print f address of var one. We could use percent um x as the format specifier and then back slash n for new line and then um use the amperand symbol and then var 4:24:40 one. So let's try to declare or I mean display first the address of the var one and then we could also do the same print the address or the value of the pointer variable IP. So the value of IP and then percent X back slash N and then the variable IP. So let's try this clean and build our program and it should you know display the same hexod uh hexodimal value. So address of var 1 is 61 FE14 and then the value of IP is you know 61 FE14. So basically we're just trying to display or I mean store the memory address of var1 into the pointer 4:25:43 variable IP. Okay. And of course if you want to access the value using a pointer um we could try to modify our program to access the value access the value using the pointer variable. So print f and then value of pointer variable IP. So for example percent d back slash n and then aster is ip. So basically we're just trying to access the value of this particular pointer variable. So let's try this 4:26:46 clean and build our program. And as you can see here we have the address of var 61 FE14 and the value of the pointer variable or I mean the address of IP or you know the pointer variable IP61 FE14. And also here we could say that the value of this is 20 which is also the same with our variable one. So that's how uh easy for us to you know use the pointers inside our C program. In this video guys, we're going to be discussing what is strings CNC and how we can take advantage of the usage of this particular strings. And then of course we're going to be dealing with the different functions that we could use in order to work with our um strings in our C programming language. Now if you are new here in our YouTube uh YouTube channel and you want content about programming, I am inviting you to 4:27:48 subscribe and press the notification bell. so you'll get updated whenever we have a new upload. So without further ado, let's uh dive right in to our topic which is the strings in C programming. So basically guys when we say string um in C programming it is the one-dimensional array of characters. Um this is called strings. Um um in other terms this is just you know a group of characters um logically grouped together and then and then there should be um a sense why we're grouping these characters together and this is terminated by null character backlash um zero. So actually guys there are two types of or two ways to declare string in C programming. Okay. So we could declare it like this. Basically guys, we have here the basic structure of our um 4:28:48 starter program. So hello world program. So I'm just going to delete that. And we're going to initialize or declare um string in C programming. So you could do it like this. You could um specify the type as char or car and then of course the name of your um variable. So you could name it something like this name. And then you could specify here the um length of your um array of characters. So for example, six. And then in here we could um add the different characters for this particular string. So we could say here for example harm and then we're going to specify another character. So first you have to specify single 4:29:49 quote and then the character and then single quote to close that particular um literal string and then another comma and then single quote the character again single quote comma and then um single quote another character. Okay. So you get the idea on how you could you know um declare your string variable in C programming. So I'm just going to continue working with this. So we have um declared six. So as I've said from the beginning you have to or the string it is the one-dimensional array of characters and it should be terminated by a null character. So null character in C is back slash zero. Okay. So basically now we know uh we do have the string name and then we need to 4:30:51 close this one up. So this is how we could um declare our string in C programming language. And actually guys you could do it also like this. So for example um you don't need to specify the length. So char and then you could say here last name and then all you have to do is um declare it as an array but you don't have to specify the length here for example five or six or something like that. So all you have to do is um initialize this with a uh with an actual value for example Hopkins something like this. Okay. And then close it with semicolon. So basically guys it means the same thing if we declare the string like this or if you want to declare the string 4:31:53 like this. And of course we could all um try to display this. All we have to do is print and uh print f and then we could say here the name is and then we need to add the format specifier. So percent s for string and then the new line specifier and then comma and then the actual value or string or the variable that we want to display which is the name something like this and then semicolon and we could also do the same for the last name. So print f and then open and close parenthesis. The last name is percent again percent s the format specifier for string and then new line and comma then the actual variable which is last 4:32:55 name. So we could try this add this the the semicolon at the end of the line that denotes that this is the end of this particular line. Okay. So make sure you do that because the compiler would complain if you did not specify the end of a certain line. So now we could build and run our program and it should display your string like this. The name is hello as we have specified in our variable um name and then the last name is Hopkins as you can see here. Okay. So that's a good start on how we could um start working with our string in C programming language. Now there are functions as I've said there are functions that we could use uh if we want to work with our string more. So so for example what if you want to copy a 4:33:57 string um concatenate a string get the length of the string. So we could do that. We could also compare strings if you uh if you like to compare strings. So all we have to do guys, we need to include um a header file which is string.h. So this um header file contains all the functions that we need if you we want to work with string in uh you know deeper sense. So string and then h as I've said this will contain all the functions that we need um like for example the str copy str concatenate str length or if you want to to get the length of a certain variable. So for now let's just try this. This is for display display the value of 4:35:02 our string. Right? And then of course uh here we could use functions to our string. Okay. So perhaps the first function that we could use is the SDR copy. So the keyword for that is STR SDR and then CPY. So as you can see here we have the auto suggestions um the SDR copy right here. So we could click on that and then in here we could specify the string. So let me explain first what this means. So the str copy function takes in two parameters. So the first one will be the destination or the string that um the copy of a value will be stored in and 4:36:02 then the second function I mean the second argument will be the source of um or I mean the source string. Okay. So again it will take two parameter this strpy. The first parameter will be the destination string. The second parameter will be the source string. Okay. So so for example in this um program I'm going to declare another string here and then um you can say here str and then full name for example this is just for a sake for the sake of example okay so for example this will be um maybe uh I don't know maybe 13 4:37:04 okay so we don't set a value for this for now and all we have to do is use our SDR copy function and then we need to specify the destination um string. So for now let's use this str full name as the destination string right there. And then comma and then of course we need to specify the source string. Okay. And then the source string will be um maybe the the last name. Okay. Now if we want to display the value of set or strr full name then we could use the print f statement and then we could say here the full name is and then percent s again back slashn 4:38:05 for the new line and comma for um the actual value strd full name right there and then end this up with a semicolon. Okay. And then we could clean and build this just to see the result of our program. And in here we have an error. Okay. So we copied the actual value of our um variable instead of using last name. So let's just um modify this. So instead of Hopkins it should be last name here. Okay. So clean and build our program and it should be okay for now. And as you can see here uh we have the display. So the last name or the name is hello as you can see and 4:39:06 then the last name is Hopkins and the full name is Hopkins and these two is identical that's because we already we just copied the value of last name and assigned the value to the str full name. Okay, so that's how easy for us to copy strings inside our C program. So there are there are other functions as well if you want to explore more about this. So for example the other function that we could use is um strat or c strut. So this will concatenate the string or two string. So basically it will just take two parameters the the first one and the second parameter and then it should you know combine these two string to to to form a new string. 4:40:06 So let me show you that. So let's just use this str cat and then maybe we'll just use the name and then the last name. So the first string will be name. Okay. And comma and then we need to specify also the um what do they call this the string or the second string which is the str full name. Okay. And then um semicolon Okay. And then after this we could display the value of our name. So all we have to do now is copy this and paste it this here and let's clean and build our program. So first now let's just 4:41:09 um close this close the output the output first and then clean and build our program and it should display here what we have done so far. So the name is hello, the last name is Hopkins, the full name is Hopkins, and as you can see here, the name is Hello Hopkins. So as you can see, it concatenated the name and then the last name. So the the name got the value of hello and then the last name got the value of Hopkins. Okay, so I think that's all there is to it for this tutorial. And if you want to learn more about strings, all the functions, you could explore the documentation. So if you want to know more about the different functions available in um this string.h H um 4:42:11 header file you could visit this website and then you could um see here the commonly used um string functions. So we already have um used the str CPY strat and of course the other most common you uh commonly used string function is getting the length of your string. Okay. And in this video guys we're going to be learning structures in C. So we're going to explore what is structures and how we could you know use structures inside our C program. So basically guys when we say structure it is a user um userdefined data type. Um it is used to store a collection of different kinds of data. So in a sense it could be something 4:43:12 similar to an array. So basically it is like a collection. The only difference is that an array is used to store the same data types. So in an array if you want to save an integer value so you have to make sure that all the elements of that particular array is also int or integer. And if you want to store double so it should have double or it should you know contain all double um elements. While if you want to use structure you could declare multiple um data type inside this particular collection. So in order for us to use um slure in C, we're going to be using this particular keyword strct. Okay. So this is how we could create a structure in C programming. So strct so 4:44:15 variables inside the structure are called members of the structure. Okay. So now let's try to define a structure in C. So say for example we want to um try to declare a strap courses. So all we have to do is specify the keyword strap. Okay. And then this is going to you know make sense later on if we want to access the members of this particular str. So for now let's just stick to this. um struck is the keyword that we could use to you know declare or define a structure in C. So again that's the keyword struck and then we could specify the structure name. So this could be any any name that you want to for example we could name this courses. 4:45:16 Okay. So this particular courses uh this will contain different variables. Okay. So as you can see here we have added curly braces opening and closing curly braces and then at the end of the closing curly brace these semicolon that signifies the end of this particular line. Okay. And then inside here as I have said we could have multiple variable type. Okay. So for example number one will be char or car and then we could name this for example website and then the length is 50. Okay. And then semicolon. And another one car or char. And then subject will be uh 4:46:16 the length 50. And then the last one will uh the last one will be about price. Okay. So as you can see here guys, we have these track courses and then it contains three different data types uh of variable. So we have here website with len 50, subject len 50 and then price which is uh an int or of type int. Okay, that's how easy for us to you know define a structure in C. Now we could um uh access this the strct courses but basically we need to move this outside of our main um function. So we have to move this I'll just have to cut and paste this. So it should be outside our main function 4:47:19 because we're going to declare or I mean uh access the strct from this main function right here. Okay. So you could think of this uh if you are into u object- oriented programming you could think of this as a class for now but um this is different because um this is a structure which is a collection of um you know different variables or different data types but you could think of this as you know an object or a class for now and then we could access this inside our main function. So in order for us to access that we just need to specify the name of our uh strap inside our main function. So all we have to do is use again the str keyword like this and then the name of this 4:48:20 track which is courses. Okay. And then um we could assign an alias to this. So for example course or maybe C a big letter C. Okay big letter C. Okay. And then semicolon. So that's how we could um access this courses track inside our main main function. So all we have to do is like um use the str keyword and then the name of our strct which is courses and then assign assign an alias to this uh str. Okay. And then after that one we could um initialize perhaps our um variables okay or members of this strct. So all we have to do is we could say here initialization. We could now access the members of the 4:49:23 strap courses by using this alias. So initialization for example um str copy. Okay. So I believe I I have already um showed you how you could um assign a value to a string because we're going to be assigning value to this website. So this is a string collection of um characters. So str CPY and then we're going to say here C and then website. So as you can see here we have the access to all the members of the courses struck. So, we're going to use the website first and then we're going to assign a value here. For example, um triplew programming knowledge something like that. So basically what we're doing here 4:50:25 um.com we're just doing here is um we're just getting the website um member and then assign a value to that which is the ww.programming programming knowowledge.com and after this we could you know access the this value by using this member of struck. So later on we will try that but for now let's just move to the next member. So again, we're going to use str copy strpy and then now we're going to use the subject subject. So the sub the subject will be introduction to CA programming. So that will be the subject for this 4:51:25 particular course. So again, we're just doing here um we're just getting the subject member of our strct and then assign a value to that which is this string introduction to C programming. Okay. And of course the other one or the last one will be the price. So what we do here is use the C alias that and then price and then we could assign a value here. For example, we want to um specify a value or a price here like $15 or something. And then after that after initialization of course we can use the these values right here. So all all we have to do is we could say here print. So we could use print f statement and then we could say here website 4:52:28 percent um semicolon r colon and then percent s and then we're going to add new line here comma and then the member of our str. So C dot and then website. Okay. And then semicolon at the end. So we're going to do the same for the other members. So uh the next one is the subject. So percent s and then back slashn and then we're going to access the subject member of struck and then the last one will be print f I mean the price. So price, we're going to do the same here. Percent um D, that's the format specifier for 4:53:30 our uh integer values. So C dot price. Okay. And then semicolon at the end of this line to denote that this ends with this semicolon. Okay. So now let's try this. Let's uh build and run our program. And we are we're having an error here. Error expected because expected. That's because um we didn't uh we did not add the semicolon here. Okay. Rookie mistake. Build and run. And as you can see here, we now have the values displayed here in our console. So the website is ww.programming.com programming.com and then subject is introduction to C programming and the price is $15. So that's how easy for us to use struck in C and then we could you know make 4:54:32 this um collection of different variables um and then we could assign values initialize and then we could also change if we want to change the values after initialization and then after that we could display the values or the actual values of the members of our strct. And in this video guys, we're going to learn how to use unions um inside a C program. So from the previous tutorial, we learn how to define and use structure and then we also implemented um different methods or different functions that we could use whenever we are working with structure. Right? So at this point in time we will be learning how to use union also. So basically union and structure is almost the same but there's a significant difference that we will discuss later on. So the thing about strct is or the thing about structure is that we can 4:55:33 store different data types in different memory location but when we say union we can store different data types in the same memory location. So that being said, um if we try to define union, a union is a special data type available in C that will allow us to store different data types in this um in the same memory location. So you can define a union with many members but only one member can contain a value at any given time. That's because uh we store the data inside the same memory location. So in other words, all the members of the union share the same memory location. That's why every time we set a value to a particular member of the union, other values will be over um will be erased and then replace with the new value of a 4:56:36 particular member. So to define a union you must use the union statement. So from the previous tutorial we use truck for this structure. But in the case of defining a union, we will define a union by using the union statement in the same way as you did while um defining the structure. And the union statement defines a new data type with more than one member for your program. So basically it looks like this, but um instead of struck you're going to use union. Okay. So that's union and then of course the name of your uh union for example data right there and then you have to add open and close curly braces that signifies that all the variable inside this curly braces is uh 4:57:40 a member of the union data. Okay. And then of course we can define the members here. So the same thing with our structure. So that being said we can say here int i. Okay. And then we could also um add float f and then say for example char strd and basically for example the length for this is like 10. Okay. So let me show you first how this particular union works. So the union tag is optional actually and each member definition is a normal variable definition. So such as I or int i or float um f or any other valid variable definition and at the end of 4:58:41 the union's definition before the finals semicolon you can specify one or more union variables. uh but is but it is optional. So you can also say here the name of your union is like um data. Okay. So you can refer to this data and then you can now act you now have the access to the members of your union by using this reference. Okay. Now a variable of data uh type can store um integer float or string of characters. So it means a single variable and then same memory location can be used to store multiple types of data. So you can use any built-in or userdefined data types inside a union based on your requirement. So it depends on you. So 4:59:42 the memory occupied by a uh union will be large enough to hold the largest member of the union. So for example in this particular code data type will occupy 20 byt or I mean 10 bytes of memory space because this is the maximum space which can be occupied by a character string. Now we can display the values uh of this union. So for example we try to display all the uh I mean any value coming from this union. So at first we could you know refer to the members by using this reference. So data dot and then we could say here I then we could initialize this value into for example um five like that and then we could print the value of i. So 5:00:44 here we could say the value of I is and then of course we need to have the format specifier for our I. Okay. So D and then we could add also the new line and then comma and then of course data I. Okay. And then semicolon. So let's try to run our program. So basically let's hope that uh we won't have problems. So build and run our program. And as you can see here the value of I is five. So we were able to set the value of our data I member and uh initialize it to five. Now take a look at this. 5:01:46 For example, we set the value of float into a something um into some value. For example, data f equals to for example, let's say 22 or maybe like 8. Okay. And then um we could try to maybe add 8.5 here just to uh make sure that it is kind like float value. So we set the value of our f into 8.5. So we could you know build and run our application. And as you can see here we're getting the value of i is something like this. Okay. So the value of i is something 5:02:48 like this. That's because the value has been you know corrupted when we try to set the member F into something like 8.5. And as you can probably remember that the members of the union share the same memory location. So that's why if we try to change the value of a certain member then it will override the value of the other member. So that's why it's uh somehow corrupted our value of I here and we're getting this random number like this. But the purpose of using union actually is to have a some sort of a value at a certain point of time. So for example, if we want to make use of the union, we could try to display the value of I 5:03:49 right here after the initialization. So the value of I is and then we're getting the the value of I member here and then also if you want to you know display the value of the float F uh value or member from this union then we could what we could do here is change this into F that's the formal specifier for a float value and then we could say here the we want to display the member F from the data union. So we could actually get the correct value right after this. So let's try to run this. So build and run our application. And as you can see here that uh we're getting the value of our I is five. So let's change this. Instead of I this is member F. 5:04:52 And this is member I because this is a member of this union. So let's build and run our application. And we're getting this output. The value of member I is equal to five. And then the value of member F is equal to 8.5. So that's basically the correct value that we're getting or we're setting here in our main function. Okay. So I think that's all there is to it for this tutorial and a sort as a sort of summary or review. We have learned how to use union inside our C program. And then uh we learned that we can store different data types in the same memory location by using this union keyword. And then um store different variables with different data types and um yeah we also set and initialize the value of the members of our union and then also display the 5:05:53 values individually. right here in our C program. And in this video guys, we're going to be discussing type defaf in C programming. So as a sort of review, in the previous tutorial, we have learned how to use unions and how to implement unions inside our um C program. And we also have implemented a simple solution or simple program that um implements the capability of unions in C. So as I've said in this video we're going to be discussing type defaf and yeah I'm going to show you how you can use typed defaf inside your program or C program. So basically guys, C is such a dominant language uh of its time and even now that even uh you can name those um primary data type of your own and can create your own um name data type by 5:06:56 blending data type and its qualifier. So it means that we could create our custom name for our qualifier or custom uh name for our primary data type. And then we can use the keyword type def right here. And this is a keyword um implemented to tell the compiler um for assigning an alternative name to the existing um data types. This keyword uh type def typically employed in association with userdefined data types. Um in cases if the names of data types turn out to be a little complicated or in uh intricate for a programmer to to get or to use within a program. So there are cases that the uh a particular data type or a name of a particular data type is like complicated 5:08:00 and it not easy to be used inside a program. So that's where the type def uh comes in. So it can be used to make the naming of our data types or of variables in C a lot a lot easier. So the typical format for implementing this type def keyword is like this. We can uh use the type def keyword just like that. And then we could um specify the existing names of data types or data type data type. Okay. And then of course right after that is the alias user given name. So again we're going to use the 5:09:00 type def keyword and then of course the existing names of data types. So there are like int signed int unsigned, um, char and other primitive data types inside our C program. And then of course we're we're going to add the user given name which is uh the custom name that we want to name this particular um existing name uh data type. So it uh this is going to make sense later on if we try to implement this inside our C program. So for now just think of this as the syntax of defining or how to name our existing data types. So type def and then existing names of of data type and then alias or the user given name. So we could um add here a sample snippet. So like 5:10:04 this type def okay and then sign long. Okay. And we're going to give this um user given name as long. Okay. So basically guys if you have or if you are trying to define assigned long um data type so it's going to be uh complicated or like it's going to have a long um name because you can do it like this signed long and then say for example v variable one and then signed long var 2 signed find long var 3 and so on. So as you can see the name of this particular variable or the data type um has like signed and then long 5:11:05 keyword. So it's going to take up more space, take more uh we're going to type more text inside our program instead of just using it like this. So all we have to do is define it like type def and then sign long and then s long and then we could implement this instead of like that we could implement that by using something s long and then g. Okay. So basically what we're doing here is that we're get we're just getting this alias from there and then um it's going to include all the data types or existing names of data type here. So the song is associated with this right here. So we're we can uh declare or yeah create a variable with assigned long 5:12:07 data type something like that. And then of course we could add a variable like just like this. Uh it will allow us to create two variables named G and D which will be of type uh signed long. And this quality of sign long is getting detected from Slong. Okay. which already define the meaning of is long or as long in your program which is this particular meaning signed long. Okay. And right after that we could make this or the concept of type type def can be implemented for defining a userdefined data type with a specific name and type. And this type def can also be used with structure um of C language. And of course we already have 5:13:08 um tackled demonstrated how we can use strct inside our C program. So basically what we could do here as I've said we could add or use this keyword type def in our structure. So the syntax is like this. All we have to do is type in um type def and then str and then say for example student. So this particular truck is named as student and then it has like the um members of this truck is of type char and then say for example s name which is the name of the student. Okay. And then we put we could say here int 5:14:09 h. Okay. So this particular strct saved um a data which is the name and the age of the student. And of course we could add an alias to our str. So for example student. Okay. So just like that and then of course we could use this truck inside our main. So for now let's get rid of this. So what we could do here is we could say stood and then st something like that and then we could see here print f and then enter student details. Okay, we could add a new line here. Semicolon and then we could copy and paste this. 5:15:13 Can see here. Enter student name. And we're going to add a tab slasht. And then we could what we could do here is use the scan f function. So percent s and then we're going to be passing the stame. So all we're doing here is just assigning a value of this STS name coming from our user. Okay. And then second line or the second information that we need is all about this the age of the student. So enter the age. Okay. So we should add back slashn right here. 5:16:13 to add a new line. Okay. So, what we could do here is scan F and then percent D. Okay. And then we can say here STH. Okay. And then print F. Um just like this back slash N for a new line and then we can say here input done. Okay. And of course we could display this if we want to you know to get all the information that we have entered the name and the age of the student. Okay. But for now let's let's just uh let's just try this build and run our program. 5:17:13 Okay. So we have here the output enter student details. So the first name or the the first option will be the name. So we can say here John and then the second option is the age. So enter the age of the student. So for example the age of the student is 18 and then yeah we need to add um it says here that the main.exe has stopped working. Uh we need to add the um amperand here and then build and run our program once again. So I hope this would this would work right now. So John and then the age of the student will be 18. So input done. Okay. So basically guys we could um define our struck with 5:18:14 the use of type def um keyword just like this. And as you as you can see here, we define our um stood um alias right here. And then we we use that stood alias right here to um name our variable st. And then from that or st we could access the members by using the dot symbol. So st and then the members of our struct student. Okay. And in this video guys, we're going to discuss what is file handling in C and then I'm going to give you a basic example. We're going to create a program on how to handle files inside our C program. So basically guys um C files input or output functions um handle data 5:19:16 on our secondary storage devices such as our hard disk and C can handle files as stream oriented data or system oriented data or binary files. So again guys we're going to focus on this. So the first one will be stream oriented data files and the second one will be system oriented data files. Okay. So when we say stream oriented data files the data is the data is stored in the same manner as it appears on the screen. Okay. So I I hope you can see that um the input output operations 5:20:18 like buffering data conversions take place automatically while system oriented data files the data files are more closely associated with the operating system and data stored in memory without converting into text format. So this is going to make sense later on when we try to implement our very simple file handling insider C program. Now there are five major operations that can be performed on files. So this will be again I'm just going to list it uh list it here just for you to see because I think it would be much clearer if you can see all the details all the things 5:21:19 that I'm talking here. So see file operations. So first one will be creation of a new file. The second will be opening. The third one will be reading. The fourth yeah fourth one will be writing data in a file and last will be closing a file. So these are the five major file operations. The first one is create again creation. The second is opening. So we could open an existing file and then we could read the contents and then write data into a file. So for example in your program you want to save an information. So you could write data 5:22:21 into a file. Okay. And then of course whenever we are opening a file we need to close it after using it inside our program. Okay. So the steps there will be steps for us to set up the file operations. So these are the steps for processing a file. So number one will be declare a file pointer. So this is important. So we need to declare a file pointer variable. And then this will be our variable that we we're going to use whenever we want to work with our files. And then after that one we need to open a file using f open 5:23:22 method or function. Okay. So after that we're going to process this will be number three. process the file using the suitable function right here. And number four will be closing close the file using f close function also. So if we want to work with files inside our C program, we want or we we might want to check this uh steps for processing our files. So we need to declare a file pointer variable and then we're going to open the file using the fop function right here and then process the file using the suitable function. So for example, we want to um 5:24:24 iterate through the lines uh inside a file. If you want to save or maybe write information into the file, you can do that here in step three. Meaning you could process the entire content of that particular file. And then right after processing maybe uh you need to close the file or not maybe you must uh close the file after closing or after processing it inside our C program. So basically guys there are a lot of functions that we could use when when we say um we're processing a file. So to handle files in C um file input or output functions available in the stdio library are the following. So I'm just going to list it also here for you to see. So we al uh we already discussed the the the two functions. 5:25:25 The first one will be f open and the second one be uh the second one will be f close. There are also uh functions such as get c which means um we read a character from a file and then we also have put c. So this function put C writes a character into a file and then also we have get w which means we need to read an integer from a file and then we also have put w. So write an integer and we're going to use this later on this particular functions. Okay. So you need to be familiar with this again. If you want to read characters from a file, you need to use this get C. And then if you want to write um character into a file, you you need to use put C. And get 5:26:28 W gets the integer and put Write an integer into a file. And then we also have F print F. So f print f um prints formatted output into a file and we also have f scan f. So reads formatted input from a file. We also have f gets right here. So f gets uh read string of characters from a file. And we also have the next one will be fputs. And then uh the last one is f ef. So fp puts right string of characters into a file. And then we also have f ef. So it will detect end of file marker in 5:27:29 a single file. Okay. Now, as a sort of example, we're going to implement a simple opening and closing of a file and maybe writing a um specific text or something into our file. So, we're going to do that right here. So, at first, we need to remember this the the the steps for processing a file. We need to declare a file pointer. So, in order for us to do that, we're going to have to follow this syntax right here. I'm just going to copy and paste it here. File open. So, as I've said, we're going to use this function fop. And these are the um possible um parameters that we could use. Okay. So, to put it simply, we could use this 5:28:30 we could declare a pointer variable. So, FP and then semicolon. And then we're going to use that pointer variable and then use the fop function right here. And then uh we could say here file name dot txt and then another uh parameter and then we're going to use here w. So w means that the file is being open for writing and if the file does not exist then uh there will be new file um created. Okay. So um let's just return zero for now. Okay. After that we could close our file. 5:29:30 Okay. If we open the file we could also close this. So what we what we need is to use the f close function and then passed in the uh pointer variable which is fp right here. Okay. And right after opening the file and before closing the file this is where the processing of the pile uh processing of the file happens. processing of the files right here. Proc of processing. Okay. So inside of processing we could just uh simply uh if you remember we have different functions. So get C put C uh F print F. So we're going to use this. So for now let's just say uh f print f okay then open and close 5:30:34 and then semicolon and inside here we could specify the pointer variable which is fp and then of course um percent s percent s where is percent s. There you go. And then hello world where. Okay. Hello world. There you go. So after this we could um save our file and then build and run. Okay. So for now we're getting process return zero. It means that the execution of the program is successful. So we're going we're trying uh we're going to try to 5:31:34 open the um file that we have created. And as you can see here, I have my um project right here from documents, codelocks, projects, and then programming knowledge. And then if we try to open this, we can see the text hello world. Okay, so there you have it on how you can write files or write lines of um strings into our file by using this simple program right here. And uh I think that's all there is to it in this video. In the next uh tutorial, we're going to read um text inside our um files and then display it in our maybe console or we want to if we want to process the contents of the file inside our C program. In this video guys, we're going to continue working 5:32:36 and discussing file handling in C programming. So from the previous tutorial, so actually this is part two of the file handling video tutorial and in the previous tutorial we um discussed the basics of file handling and um also discussed the five major operations that can be performed um on a file. So for example the creation as the first operation and then opening reading writing and closing a file and also we discuss the steps for processing a file. So basically if you want to uh handle files inside your C program you need to declare a file pointer variable as the first step and then the second step will be opening a file using the fop function and then right after that one process the file. So for example, you want to 5:33:38 count the number of lines um inside of that particular file or you want to add something to that file, you can do that. So that's the processes or processing of the file and then of course closing the file using the fclo function. And from the previous tutorial also we briefly uh discussed the different functions that we could use when we are handling files in C. So for example the get c the put c um get w and put w and the other functions. So in this video guys I'm just going to show you how you can uh read the content of a file and display it in your simple program. So we're just going to use this main function right here. So, I have here the main C um file or yeah, main.ca file. And then we're just going to use this main function right here just to get the contents of 5:34:41 our file. So, as you can probably remember from the previous tutorial, we already created a file inside our file system and let me show you that. Okay, so I have here the file and then file name.ext text and it contains the text um hello world as you can see here. So this is written from our C program and in this video we're going to read this by using also our C program. So in order for us to again if you want to handle files in our C the first step is to uh declare a pointer variable. So the pointer variable goes like this. So we need to uh call on this file class and then add the semicolon I mean the um asterisk or star symbol as you can see here and then of course the name of 5:35:43 your variable. So I'm just going to name it uh file name and then semicolon at the end. So this is our pointer variable. As I've said, this is the first step for handling files in C, we have to declare a pointer variable. And then uh the next step, uh since we're getting the content of a file, uh I just want to assign the content of a file into a single variable. So for example, I'm just going to declare here another variable uh car or char ch or the name of the variable is ch and then I'm just going to assume the length um 100. There you go. And then semicolon. So basically this particular variable will hold the contents of our file. Okay. 5:36:47 Next line will be um using the file name variable right here which is our pointer variable. And then the second step in the process is of course open the file by using fop function. We already use this function from the previous video. So in here we're just going to specify uh specify the name of the file which is file name.ext as you can see here. So that will be file name txt and then we're going to use the um r symbol. Okay, that's basically um reading the file name or I mean the file coming from our file system. And then the next step is of course if we want to print the contents of our file. So, we're just going to use the print f function right here and then specify 5:37:51 the um format specifier percent s because we're going to display um character or strings of character here coming from our file and then comma and then uh we discussed the function uh in the previous tutorial if gets f gets. Okay, so basically this function um read string of characters from a file and this particular function takes uh a few parameters. So for example, we're just going to um specify the parameters here. So for example, the variable ch that's the variable that will hold the contents of our file. And 5:38:52 then so for example 50 this is the count of characters that we're going to allow to be saved in our um char variable. and then of course the file name. Okay. And as always if you are working with file since we're opening the file here we need to use also the closing function which is f close right here. And then we're going to specify the file name right here. Okay. So for example, the file name and that's about it and we can run our program right now. Let's just save this and build and run. So it's going to output hello world. So 5:39:52 for example, just to show you a basic example, let's just fill out our file. Hello world. This is a string from uh file. So we're just going to um test this. So save and let's run again our program. Okay. So as you can see here hello world comma and then this is a string coming from a file as you can see here. So basically uh we successfully um read or get the contents of our file name txt file. Okay. So now there are other operations that uh you may want to do in your um 5:40:55 file. So for example, you want to like count the number of lines that's possible. Again, this particular symbol right here is uh like opening a file in a read mode. Okay, so R that's basically what we use here. So, as I've said, there are also other functions that we could use when trying to handle files in our C program. And of course, fgets is one of them. But there are also so for example, we have um get C. So, this reads a character from a file. Okay. We also have um get w. So this will be for reading an integer and we also have um fget gets that's 5:41:56 what we used here. So f gets reads string um string of characters from a file. Okay. And then of course there are other functions that you could use to write this is writeing into the file. So we have um put C um put W. So basically put C writes a character a file and then put Write an integer to a file and then we have F print F for writing and we also have um fputs okay to um write string of characters into a 5:42:59 certain file. So I hope you understand the basics of handling files in C and and in this video we're going to be learning innumeration or enum in C. So enumeration or enum is a userdefined or userdefined data type that we can use inside our C program. So it works like almost the same with strap. So as you can probably remember from our previous tutorials, we already discussed and used um strct inside our C program. So as I've said in this video, we're going to be learning enumeration. So that's um that's where our focus should be enumeration. So enumeration is mainly used to assign names to integral constants and these names make program easy to uh easy to read and maintain. So I'm going to be showing you a graphic right here on how we can declare, instantiate and operate with enumeration 5:44:01 inside our C program. So basically guys, this is how we can um declare the enumeration right here. So declaration we have this keyword enum and then the name of our enum variable. So in this case days of week. Okay. And then we have different states. We have seven different states here that starts from the value zero. The second will be one and the last one will be six. So um all of these states these are called enumerators. So this is just the list of constants separated by commas. So this will help us to make our program easy to read and maintain because all of these enumerators are already already listed here. So we know what values to get, what values to uh assign to a certain variable if we want to use this um 5:45:03 inside our C program. Now after that declaration we do have this instancation. So in instancation part we have also the name or the keyword enum right here and then of course the enum variable that we have declared uh on top. So for example this one days of week as you can see here and then of course we need to assign an object of enum days of week. So basically guys this day is is just an object of our days of week enum as you can see. Okay. And then right after that instantiation we can now use that in enumeration or enum um here in operation. So for example you want to like assign a value to our object. So day equals and then the value of our um enum that we want to use. So for example this one in this case we specify 5:46:06 that it should be Wednesday right here. Okay. So we could assign the value just like that. Now we can use this inside our C program as I've said because we're we're dealing with enumeration or enam in C. So we can um use our IDE to create our simple program implementing the enumeration or enum in um C. So for example, we want to um like implement the days of a week. So as I've said in our declaration, we can use the enum keyword right here. By the way guys, you can declare enam locally. We can declare enum locally 5:47:08 or inside a function right here or you can do it here before our main function globally declare our enum. Okay. So for example, we want to do this globally. So our keyword enum right here and then the name of our for example in this declaration we have the enum keyword and then the name of our variable. So days of week. So for example in our case we're we're just going to use the week variable name. And then inside here we can declare inside the curly braces. So make sure you use curly braces and then semicolon at the end uh of this particular line to to signif signify that it is the end of this particular 5:48:10 line. So inside here we can declare for example for Monday, Tuesday, Wednesday, um Thursday, uh Friday, Saturday and Sunday. So that's how we can declare our enum variable. Again you have to use the enum keyword and then the name of our enum which is in our case here week and then open and close curly braces and you can declare the enumerators here and of course you have to specify the semicolon at the end of this particular line. Now in using this particular enum we can uh do it here inside our main function. So we could again uh use the enum keyword and 5:49:11 then our name of our enum which is week as you can see here. So take note of that that we use the enum keyword and then the name of our enum and we can assign an object to this. So for example day. Okay. So that's how you can um specify our enum object. So enum keyword the name of our enum and then an object of our enum which is day. So for example you want to assign a value to this. So day equals for example Wednesday. So can just use wed and just three letters if you want. But anyway, you can use also the full um names of your constants. But in our case, we're just going to use the three 5:50:12 letters to have like a uniform constant names. Okay. So here we can use so for example Wednesday and then of course you can print this. You can specify the percent here and of course the object of our enum. Okay. So let's try to run this and see how our uh what the output of our program. So, so as you can see here, we're getting two. The value of our object is two because as you can see um our enumerators or the state of our enumerator starts from zero. So 0 1 and two. So that's why we're getting the value of our object here as two. But if we want to change this for example sun 5:51:14 for Sunday then run and build our program. So the output will be six. So by default guys um the value of our innumerators will be if we we did not assign a value to our innumerators the default value of this will be zero. This one will be one. This will be two. As you can see, if we try to hover over our um mouse here in our constant. So, we're getting two. Um this is obviously three, but we're not getting the um like the hover over display four. This is five. And this is six. So that's how our state is being um initialized by the compiler. So it is getting like 5:52:15 uh getting default values zero until to the last um state minus one of our enu uh enumerators. Okay. So if we try to um initialize our um states. So for example, we want to make this one. We could do that. So Monday will be one, Tuesday is two, Wednesday is three, um Thursday is 4, Friday will be five, Saturday will be six and Sunday will be seven. So remember earlier we are getting two coming from Wednesday because that's the default state of our constant Wednesday. But if we try to assign the value to our enum object here 5:53:17 into Wednesday. Let's try to see the output. Okay. So instead of two now we're getting the value three because we initialize already our variable and it's not assigning a default value um to our states. Now here's an interesting facts about initialization of enum. So if there are like two enum names um we can declare same value for example we want to declare value for Monday Tuesday we can like make this value one and one so it doesn't matter for this particular example because uh this is um allowed in C programming so we can have two uh enum names with 5:54:20 the same value. Okay, so for example, we can comment this one out and we can try to display the value of our constant. So percent um percent d and instead of day we can use Monday and um Tuesday. There you go. So build and run a program and we're getting this error right here. Okay, we're getting that output because we have specified our printf statement like this. But if we want to have uh we want to display the correct value, then we're going to use this percent d percent d and then comma in between and then we're just going to um specify the two 5:55:20 variable Monday and Tuesday and click and build and run our program. And as you can see here, we're getting values one and one. So that's one of the interesting fact about declaring our enum variable. We can use the same state or the same value for our constant. So it it doesn't matter in C. That's because uh it is allowable in C. Okay. And guys, if you have clarifications, if you have questions regarding enam, you can ask questions down below.