0:00 hi everyone welcome to my channel Lila webd in this video I'm going to show you how to set up the C programming language on the Windows using the visual studio code so normally you will be having a doubt that long back we have learned about the C programming language how we can set up the C programming language on the windows and how we can write the code in the visual studio code let's try to see whether if you are a beginner or just need to quick guide means so this tutorial or this video uh has you covered let's drive in into this one so now first first of all in order to run the code or C language C programming or anything so what we need to have it is first we need to have a c compiler so for this one what I will try to do we will use the Min GW so we can open your uh browser and search for Min GW download you can search for this one and here you'll be able to see the minimalist gnu for Windows download and here you need to click click on the download 1:01 thing and we need to download it so automatically the download will be start so the download will be started so it is started so after after completion of this one so you need to open this file so let's try to open this file so when you try to open this file so it will give you some set of thing something like this so here you'll be able to see so me GW get iPhone version like this so let's try to click on the install and here it will ask you the installation Direct Dory where it needs to set up so you can click on the continue and it will try to connect so here it will ask you basic setup so right click uh so all one by one one by one so you will be uh trying to do it so here in the install it will take some time to install let it install so here it is completed and if you click on the continue oh sorry so okay so here it will be asking you so what is the thing you need to install so here you'll be able to see you need to 2:01 select Mark for installation so here on this one so here you need to click on the mark for installation for for M GW 32 hyphen GCC g++ so this is thing you need to click on and normally you need to go for installation so where we can see all packages sorry basic setup in this basic setup so we have selected this one and somewh you'll be able to see installation yeah so apply changes so here it will ask you okay to proceed so you will click on the apply and it will connect to the and it will install the GC GCC so let it install so after installation we need to set up the environment variables we'll set it up so everything got installed so you can close this one so now this one is completed so now here we can go for uh we can close this this one and let's go for the environment variable 3:02 setup so here if you try to go into this one in in that seal here you'll be able to see the mgw and here in the bin you'll be able to see the GCC folder so this one we need to add it in our environment variables so let's try to add it environment variables and here in the environment variables and in the path so you can click on the edit and here you can click new and already this C MW is added for this one so there is no need to worry so already it is added so I'm clicking on the okay so you need to add it like this so fine so now it has been added so now we have added we need to add this m Min GW to our system path so we have open our startup menu search for environment variables and click on the edit the system variables so you you click on the okay to all in all windows to save the changes fine so now the compiler is ready to use now let's install the visual studio code so if you don't have the visual studio code means so then you have a code. visual studio.com there you 4:04 can install the visual studio code also so here code. visual studio.com so here you can install this Visual Studio code so it's not a problem so you click on the download for Windows and follow the install instructions once it is installed so you can open the visual studio code so let's open the visual studio code so I am opening this Visual Studio code let us open so after open opening this one so you'll be able to see like this and here you need to click on the extensions so in order to install the extensions so here you can search for the uh C or C++ so C++ you can search it for C++ or CR C++ so here you try to install the C++ so this one and also the code Runner also to run the code and all those things so now so these extensions help us to write debug and run C programs more efficiently so so fine so now we have completed our thing now let's try to open uh let's try to create a new folder 5:05 here in this one so let's go to the D and here I will create a new folder so here I will create C language okay and this is our folder let's go into here and here I will create a open folder and in this one let's go to the D and here I will write C language I will be selecting this folder so I have selected this folder okay now here let's try to create a new file so that is nothing but I will be creating a new file that is nothing but hello. C that's it so now I'm creating the hello. C so let it create now here so let's try to write the first code so here I'll be writing hash include and here I will be writing studio. H and here we will be wrting in main so this is our int Main and now we 6:09 will be writing printf so just I will write a print of only just in order to check whether it is working fine or not so hell world I will be using the hell world that's it so if you want you can return zero that's it so this is our code and now if you want to so now we will now open settings so here you can click on this gear icon and here you can run the code so just you click on that one so automatically the code will be running so here so here you'll be able to see the hello world the output we are able to see it so this is how so now this is how we will be using it so this tells the code Runner so now automatically the code is running so now you you can able to run this code without any problem and here you'll be able to see a hello.exe file so if you want to run means hello.exe file if you click enter so then again you'll be able to see the output so congratulations now you have successfully set up the C on the windows with Visual Studio code and uh and that's it you are all set to start coding in the C so this is all 7:11 this is how we'll be set uping the C language in the windows and the visual studio code this is how you will be writing it now we are able to successfully run the C programming language in our uh Windows system so if you want to debug this one means so you need to install the GDB so GCC debugger we need to install it I will try to I will try to explain you that one in the next video I will explain you so hope you understood about this concept so if you have any so this one uh so if you found this video helpful don't forget to like share and subscribe to my channel Lia webo for more programming tutorials so if you have any questions drop them in the comments below I will try to give the reply to all those things so thanks for coding thanks for watching and happy coding so this is all about the C programming language so we will be doing little bit of Basics and all those things will be covering up in this playlist so I will soon I will be covering more videos also thank you guys bye hi guys this is Leela welcome to my channel Leela webdo in this video we will learn about the what is C language 8:13 so we'll have a brief introduction about this C language in our previous video we have seen how we can install the C compiler and how we can run the C code in the visual studio code I have shown you now let's jump back to the basics things what is a c language so this is very basic important for every program programmers to learn so having a strong Foundation or having a knowledge in the C language is must and should essentially for every software developers like C and C++ so we'll have a we'll have a brief uh knowledge about the C language and I will try to explain you in a small small videos like this so now what is a c language so this video provides an introduction to the C programming language its significance and why it remains relevant today despite the emergence of newer programming languages like C C++ C and also Java so we'll try to see why still the C programming language is still relevant today learning why it is important to learn toing because in spite of having the newer programming languages like C java.net so nodejs and these all things let's try to see 9:15 overview of C origin so C was developed in 1972 by Dennis Richie at AT&T's Bill Laboratories in the USA so popularity so popularity so how it became it became widely used because of its simplicity and easy of use so it was developed in so the first language it was developed in 1972 by Dennis rich and at& B Laboratories in the USS so by the time it became widly used because of its Simplicity and ease of use so why learn C today so why we need to learn the C today so some articles if you try to see in the internet challenges the opinion that c is outdated and no longer worth learning instead it highlights several reasons why is still important so what are the reasons let's try to see so foundation for the objectoriented programming so for example let's say that if you are newer to programming and you want to learn about the object programming and all those things so languages like C++ csharp and Java use U principles so learning C first provides foundational programming skills that make it easier to transition to this languages so C is the basic Foundation 10:17 programming skill and make it easier to transform or to move into the next programming languages so this this provides a basic Foundation a twostep learning learning process like C first then oop languages is more thorough and rewarding so that is the main thing so first if you learn C every programmer then learning doop languages is more thorough rewarding so see in operating systems so what how in operating system it will support major operating systems like Windows Unix Linux and Android have large portions written in C only so the almost all the operating systems like Windows Unix Linux and Android everything have been written in C only extending or customization these operating systems often involves writing devices device driver programs which are typically written in C so if you want to extend these operating systems features and all those things me then we need to write the device driver programs so these device driver programs are also written in C only C embed systems so where we are using this C I'm trying to explain you 11:18 so smart devices like microwave ovens washing machines and digital cameras use embeded programs so these programs need to run efficiently and fit within limited memory making C the ideal language for such tasks so like the programming and all the things in washing machines microw everything is written in C only C in gaming and performance intensive applications modern games require high performance to handle real-time user inputs gaming Frameworks like directex used for building fast and interactive games are written in C only so this is thing modern games are also written in C only so key characteristics of a programming language normally if you want to know about a programming language it should have a key characteristics so some articles some articles or some videos if you try to see outside so it introduces four important aspects of any programming language so if you want to if any language want to become a programming language means it needs to follow these four important aspects the first one is data storage how the language manages the data so that is one thing and data 12:20 operations how the language process or manipulate this data uh store data and another one is the input output how the language interact with the user or external systems and the last one is the control flow how the language organizes the sequence of instructions in a program so these are the four important aspects that the programming language should be uh considered so how the data is stored and how the data operations manipulate how the data is manipulated and how the language interacts with the user input and output and how the language organize the sequence of instructions in a program so in this video this videos so whatever the videos we are trying to do so discusses the evaluation and versions of the C programming language highlighting the standards and which version is being focused on in the content provided so let's try to see about what are the different version of C we are having first one is the K andrc which has been introduced in 1978 so named of the Brian kingan and Dennis Richie who authored the first official book in C 1978 this 13:23 version laid the foundation for the C language and is referred to as K andr next one came name is the 1989 NCC in 1983 The American National Standard Institute NC formed a committee called X3 j11 to standardize the C language and next one is the result was the NCC standard finalized in 1989 officially named as ncx3 1.59 1989 programming language C so this version is often called as NCC or c89 so this is the another version which you are having in the internet so the language C another one is the is ver in 1995 the International Organization for standardization ISO extended the NCC standard this version is called as an ISO so this is an another version of C last one is the c99 2000 version in March 2000 ANC adopted ANC adopted isoc along with the new updates creating a revised standard known as c99 c99 introduced several new features and enhancements to the language so this one is the c99 last version so now why these 14:26 standards matter so you may be having a doubt that why the standards matter each standard ensures consistency in how the C language is implemented and used across the different platforms the c99 standard is modern yet widely supported making it a good choice for Learning and the practical application so the last one the last version is the C9 standard is the most modern and it also widely supported making it a good choice for Learning and also the Practical applications so now in this session what we'll try to do it is we will be learning about the c99 only and why because so we we all will be we all will be learning about the c99 so whenever you are learning about c99 means all the versions also the previous versions also it will be working why because so these all versions first it has came and afterwards only the latest version has been developed so with the throughout this videos playlist and all the things whichever we are learning C so I'll be explaining you in the c99 standard so you can see the thing and the code whichever you are trying to execute it will execute in the older versions also so this is all about the 15:27 brief introduction of this C Lang language so hope you understood about this concept so if you have any doubts or any suggestions please post the comments below to this video and if you like this video please do support me by subscribing to my channel thank you hi guys this is Leela welcome to my channel Leela webd in this video we will learn about the building blocks of C program so what are the building blocks of C program let's try to see in C programming alphabets digits and special symbols are combined to create important components like constants variables and keywords so these alphab digits and the special symbols are combined to create constants variables and the keywords let us understand each of these components that is nothing but constants variables and the keywords let us try to understand first one is the constants constants are fixed values that do not change during program execution for example the number 10 or the character a Remains the Same throughout the program in programming constants are also referred to as literals so this is the main thing and next one is the variables 16:28 variables are named memory locations that store values that can change as the program runs for example the variable age can hold the value 25 initially and later can be updated to 30 variables are also called as identifiers the next one is the keywords keywords are reserved words that have special meanings predefined in the C programming language for example int float and written are the keywords so constants in this C are divided into two broad categories one is primary constants and another one is secondary constants so these are the two different so first we have learned what is a constant what is a variable and also what is a keyword so constants means which are fixed throughout the execution so that means the value will not change all the time next one is the variable so for which the memory location value will be assigned in a memory location and it will be referenced with that variable name so now we can also hold the value and also we can change we can also update the 17:29 value and keywords are the nothing but special keywords that are available reserved words that are available that are there in the C programming language not only in the C programming language it is also available in all the programming languages you'll be having some keywords like Reser words like int float return return function so like these names are there so now when it comes to constants constants in C are divided primarily into two broad categories one is primary constants and another one is the secondary constants so first we'll focus on this primary constants primary constants are these include integer constants like 100 minus 50 like this real constants 3.14 or minus 0 3.14 means Pi 2.5 E4 like this character constants like A5 these things secondary con these are more advanced and include pointer arrays pointers arrays strings structures unions enums these all the things also you'll try to learn it so these are secondary constants so let's try to understand about the primary constants in detail first one is integer constants definition an constant is a 18:29 whole number without a decimal point it can be positive negative or zero rules for constructing the integer so constants must contain at least one digit no decimal points are allowed can have a positive or negative sign if no sign is specified means it is assumed to be positive no commas or blank space are allowed the range of values depends on the compiler for mod compilers like Visual Studio or GCC it will be minus 214 something like this to plus 24 for older compilers like turbo C or Turbo C++ that is - 32 768 to 32767 so this is the range of integer value how much value it can store examples are valid valid ones are 426 + 782 - 8,000 0 like this invalid are 32.5 contains a decimal .5 is a decimal thing th means contains a comma so that is the thing this is all about the integer constant real constants definition a real constant represents a number that may have a decimal point or or can be written in an exponential form these are 19:31 often called as floating Point constants rules for constructing these real constants in fractional form must contains at least one digit must have a decimal point can have a positive or negative sign if no sign is specified means then it is assumed as a positive no commas or blank space are allowed examples are valid are plus 32 32534 4260 - 32.768 point3 multiple decimals are there and three space 2.5 that it contains a space so these are invalid thing top are valid so these are floating Point numbers rules for constructing real constants in exponential form so if you are have if you want to real constant in exponential form means the number is divided into two parts one is mantisa the part before E example 3 3.42 in 3.42 eus 4 and next one is the exponential the part after e that specifies the power of 10 example minus 4 in 32. e to the^ of 4 so mantisa and exponents are separated 20:33 by e or capital e mantisa may have a positive or negative sign default is positive exponent must be an integer and also can be can and can also be a positive or A negative the range of real constants in exponential form approximately 3.4 E38 to 3.4 E38 minus to plus examples are 3 3.2 e ^ ofus 5 4.1 e ^ 8 or - 0.2 e to ^ 3 invalid or 3.2 e missing exponent e to the^ of e E4 missing vtis so like this these are the real constants in exponential form next one is a character constants definition a character constant is a single alphabet digit or a special symbol enclosed in a single quotes this is the thing rules for constructing the constant must be enclosed in a single inverted commas both single inverted commas should be point to the left should point to the left example a are not a so like this 21:34 only a single character is allowed okay only a single character is allowed examples are valid are A5 is equal to like this invalid are a so contains more than one character a missing codes so these are invalid variables in the C definition so now the constants this things finished now let's try to understand about the variables variables are named locations in memory that stores values since their values can change during execution they are called variables types of variables variables are categorized based on the type of constant they store integer variables store integer constants real variables store real constants character variables store character constants like this rules for constructing a variable means names length must be between 1 to 31 characters some compilers allow up to 247 characters but shorter names are recommended so that's common thing starting character must begin with an alphabet or an underscore so other than this we should not start anything content can include alphabets digits and underscores Reserve words keywords cannot be used as a variable names so we 22:36 have seen some keywords right in like this so those all things cannot be used examples are valid are siore int popcore eore 9 average basic salary these are the variable names which are supported invalid are one two three names so digit comes in between the first only underscore and alphabets only should be started starts with the digit float it's a keyword my name contains a space so these are all invalid best practices for naming the variables use meaningful names to represent their purpose in the program example for calculating simple interest use principle rate time instead of generic names like ABC so that is the thing which I want to explain so declaring variables variables must be declared with their type before use so like in age score float price interest underscore rate character grade initial like this keywords in C keywords are reserved words with predefined meanings in the C they cannot be used as variable names so these are reserved words C has 32 standard keyword words such as int float character if while written like this these keywords are essential for 23:37 defining variables making decisions and controlling the loops some compilers may add additional non-standard keywords like example ASM an recommends prefixing such keywords with two underscores but not all compilers follow this rule examples of keyword are control flow is if else while for like this these are keywords which should not be used as variable names and data types into character float wide others are return size of volatile these all things so total in summary constant fixed values like 5 3.54 a like this variables named memory location for storing changeable values example age salary keywords means reserv key words with predefined meanings example into F like this so key points to be remembered is constants can be integers real numbers or characters variables must follow strict naming rules keywords cannot be used as a variable names so this is all about the building blocks of C program so hope you understood about this concept so if you have any doubts or any suggestions please post the comments below to this video and if you like this video please do support me by subscribing to my channel thank you hi 24:39 guys this is Leela welcome to my channel Leela webd so we have we had a brief introduction about the variables constants and the keywords in the C language so now it's time for us we'll go through a simple C program so that you will be able to understand a practical approach by seeing how these elements come together in a working in a c program let's try to see so I'm writing a simple program that calculates the simple interest and through it the foundational principles of writing C program will be explain so first of all you know how to install the GCC compiler in your Windows operating system and also how we can run the code in the uh Visual Studio code also I have explained you in our first video so now we are calculating the simple interest the simple interest formula is nothing but simple interest is equal to P into n into R by 100 okay P into n into R / 100 so this is the formula for calculating the simple interest so where where p is the principle n is the years rate uh number 25:40 of time we can say it as a time and R is the rate of interest divided by 100 so let's try to write it so the first one writing the program so I will explain you one by one this all the things don't need to worry just I will write I will explain I will write the code for you hash include so here I'll be using stdio.h okay and always the program should be started with main so like this so I will explain you these all the things one by one so just go through the thing so here I'll be writing calculation of the simple interest so here I will write something like comments calculation of the simple interest so this is the code which we will be trying to wrate it now here in Main and in this one so we'll be having int principle so we can have a principle and also the year so normally the time we will be taking it as an year only and here we will be having float so these are the principle will be always the integer and here is also the integer float value there is nothing but rate of 26:41 interest and the simple interest so we will be calculating it so here I will be giving you I will be uh declaring the values so here just the initialization I have made it the principal values for example let's say that principal is equal to 1,000 rupees okay so let's say that 1,000 and the year is equal to let's say 3 years and here the rate of interest or the rate will be something around 8.5 let's assume now in order to calculate the simple interest so how we can calculate principal I told you the formula right principle into year into rate so here we need to keep it in the bracket so that the first here the calculation multiplication will be done divided by 100 that's it so in order to print the value what we can do it is print f sorry printer simple interest is is so here we should write simple interest is so here you can use as this 27:42 one is a floating Point number so slash and and here I can write the simple interest that's it and now we can return return the zero so that the program will be stopped so that's it so this is our simple code I will explain one by one if you want to execute means so here at the right side top you'll be able to see a run code option play button will be there click on that one automatically it will start executing and it will show you the output for you so here the simple interest is 255.000 you'll be able to see the output so hope you are able to see this output so that is a simple interest which you are able to see it so if you try to if I want to show you again let's close this one delete this one all and again I'm clicking on this one so here you'll be able to see it is executing and the simple interest is 255 0 so that means we have successfully executed the program so let's try to understand the program what we have written here the structure and layout of the C program is very much important so while C is a free form language allowing flexibility in the code layout certain following we 28:43 should follow certain rules ensuring Clarity and correctness so separate instructions each instruction should be written in a distinct statement for example p is equal to principal is equal to th000 something like this order of statements second one the statements must here in the sequence they are intended to be executed next one is the blank spaces use blank spaces between words to improve readability such as FL rate comma space SI like this principal comma space here and is equal to I have used the space so like this we need to use the spaces lowercase letter C language keywords and most uh statement should be in lowercase like written or float something like this so this one float integer keywords these all the things are in what I mean to say in lower case only so another another one is every statement must end with a semicolon so here every statement must end with a semicolon it serves as a statement Terminator so that is one thing multiple statements in one line it is possible to write multiple statements in a single line if each statement is properly terminated so here you can also 29:44 write uh something like principal and here also you can write it in the like this also you can write it without any problem so that there is no error in this one the next one which I want to explain is the comments in a c program comments are a crucial part of any program serving as a notes to clarify the program's purpose or specific statements they improve readability and maintainability of the code key Point key points about the comments are comments can explain the overall purpose of the program or specific statement such as formula for simple interest for example let's say that if I want to explain the formula means so here I can write formula for simple interest I can write something like P into n into R sorry divided by 100 so here I can write the formula in the comments so that you can able to understand it very easily so format of commands so you can also use the multi-line commments also for example let's say that this is the one right so if you press enter so like 30:45 this also you can write it it's any problem so multiple lines also you can write without any problem so like these are called as a multi-line commands so we can also use single line commments using double slash also for example let's say that this is the calculation of the simple interest so if you are having single line only means so then you can also use the double slash so this is also so these are called as a single line commands so you can also use the double slash multi-line commments means you can use slash star slash like this placement of commments commments can be placed anywhere before a statement for example here you can write something like formula for simple interest so this is the formula you can write it anywhere so here you can write it like this so this is the formula for the simple interest before a statement and after a statement also you can write it so here also you can write it formula so like this also you can write without any problem so this is also you can write it so not not and within a statement also you can write it so like uh here you can write it something like Star year like this also within the 31:47 statement or before the statement or after the statement or within the statement also you can write it without any problem non- nested comments comments cannot be nested meaning one comment cannot be written inside another the following is invalid so if you try to write it like this means this is invalid so like this this one is invalid so this type of things we should not be written splitting comments so comments can span multiple lines so like this also you can write it and best practices are start the program with a comment that includes its purpose the author and date it has been written so here you can write it and like this you can use it so that's it guys about the simple thing which I want to explain you so this introductory C program is a practical gateway to understand the basics of writing C code by combining rules about the program structure the use of comments and the clarity they bring it sets the stage for learning more complex programming Concepts more complex programming Concepts so this each rule and practice contributes to create readable maintainable and also the error free code so this is a simple thing and next 32:49 video what I will try to do is I'll try to explain you about the main and all those things I will explain you about the print of these things I will explain you hope you understood about this concept if you have any doubts or any suggestions please post the comments below to this video and if you like this video please do support me by subscribing to my channel thank you hi guys this is Leela welcome to my channel Lea webd in this video we will try to understand about the main function in the C language so what is this main function why we need to use it so normally what is main so main is a function in C okay so main is a function in C serving as the entry point for any c program so this main function serves as an entry program for any c program a program can hand can have multiple functions normally program if you try to see can have multiple functions but it must have one main function only it must have only one main function if there is only one function means its name must be mentioned as main only all statements in the main are enclosed in curly Braes so all statements whatever the statements you are having here those all should be enclosed in a curly braces so written 33:50 type of main so what is the written type of main if you try to see here we are using written zero functions in C return returns values and Main main also is not an exception for this one so normally functions if you try to see anything in C or any programming language it Returns the values and Main has is no exception so it also return returns a value the written type of main is here in this one the written type of main is in try to see here which means that it return returns an integer by convention main return returns zero to indicate success so here we are rning the zero indicate success if there is an error means it can return any non-zero value to indicate the failure checking the return value so the method to obs observe the return value of main depends on the compiler so here the the return type and all those things depends on the compiler if you if you are using the turbo C or C++ means use alt C information for that one or otherwise if you are using this visual shudio means observe return return value in the watch window of the debugger so Linux means we can use the Echo and execute the program in the terminal so like this we can check it so 34:50 some compilers also we use void main so some compilers like turbo C or C++ allow main to return nothing this is done by preceding it with the keyword void but this is non-standard right now so here you can also use the void in the turbo C++ but it is non-standard variables and their usage declaring the variables variables always must be declared before use so whenever you are using the variables means it must be declared before use example here we are able to see int principle here and Float rate and the simple interest so these are the Declaration of integer variables and these are Declaration of the float variables and now usage follows declaration so here we are able to see a simple interest is equal to like this we have used it right so we need to use arithmetic operator so we have used different types of Artic operators operators are used in CR plus minus into for some multiplication slash for division modulus for the reminder so these type of arithmetic operations we can use it and another one which I want to explain is the printf so C does not 35:50 have a keyboard keyword to display the output instead it uses the library function printf from the studio do so here this is the the studio. from this one it will use a library function printf so syntax of the printf is so something like here in the double codes we will be using the format string and here we can use with a list of variables so here specifies how value should be displayed common specifications are here we are using percentage f for floating Point numbers percentage D for integers and percentage C for characters we'll be using it can also contain leral text also which is printed as it is so here this is a literal text so examples of the print are something like this your able to see it right simple interest is something like this one so now so this is all about this one so compilation and execution how it will have so role of editor and the compiler so editor this is an editor Visual Studio code is an editor and it is used to type the program and we are having a compiler which converts the program to the machine language for execution so we are having the GCC compiler so it will be using uh to convert it into a machine 36:51 language for execution and now other programs in the development are so pre-processor hand is directives like hash include so these are pre-processors and directives and these pre-processor hash these all things hash include uh these are pre-processors it will handle the directives like studio. these are all directives Linker combines the program components and debugger so these all things we are used so now examples of IDs are normally you'll be able to see turbo cc++ Visual Studio code net beans and code runnner so like this code light sorry we will be using these all the things online compilers are also available for writing and executing the C programs so now we are able to see about the simple this example I have explained you so now if you try to see hard coding values like P is equal 1000 year is equal to 3 and rate of interest is 8.5 limits the program flexibility to make the program more General it should prompt the user for input during execution so for this one we can use the scanf so for this one what I can do it is instead of asking like this so here I can ask scanf okay for reading the DAT 37:53 input so here enter principal m ount and here you can use something like so principle is percentage D and here we need to mention M percent principal that's it and here another one you can use scanf enter year and here also you can do take it as in percentage D and here you can ask here M percent year so it needs to take ENT year I will try to explain you that one and the last one which you need to take it is the rate scan if enter rate of interest so here rate of interest percentage F and here you can use am percent rate that's it so now here we are mentioning the we are asking the SC uh enter principal amount enter year and also the enter rate of interest we are asking so here percentage D is used for integers percentage f is used 38:55 for floating Point numbers and here we have used it and address of operator we are using amp percent M percent gives the memory address of the variable so here instead of having the value it will give the memory address of the variable indicating where the input value should be stored that is thing input values must be separated by space tab new line like this so space separated th000 so like this also you can use it so now I will try to explain you so here we have implemented this one right let's try to uh execute this one so I am trying to execute so let's save this one I will try to execute this one so here it will ask you the series of questions let it ask so it needs to ask it is taking some time let's wait simple interest is 0 0 so it is it is so let's try to execute it again so I'm trying to execute it let's see whether it will ask you or not let's see 39:58 sorry the problem here what is happening is we should not write here something like enter principal amount like this so directly scanf means we should take it like this only so here we should enter first one is printf my mistake this one here we need to add principal amount then only we need to add the scanner then here also we need to add enter printf so here we need to enter it like this then enter here so we need to use a scan and here also we need to add printf okay printf here we need to add this is my mistake so so we are working on node J JavaScript these all things right so now we are writing the simple code so sometimes the problem comes so fine now if you try to execute here so now here you'll be able to see enter principal amount okay so principal amount is 3,000 assume and it is asking enter here three 41:00 and now it will be asking enter print of enter rate of interest so it needs to ask enter rate of interest why it is not asking the same scan of percentage M percent print of enter rate of interest yes you should ask the rate of interest right why it is okay fine so I kept slashing right because of that reason maybe it could be so you should not write slash and also here so fine enter rate of interest is uh let's say 6.5 now if you try enter so here you'll be able to see 360 so now this one is a dynamic one now if I execute it again let's try to delete this one and I will try to execute this one again now if you try to see here it will ask you enter principal amount okay so I will be using 5,000 and it will asking you enter here okay it should be 4 years and it will ask you rate of interest it should be 9% 9.0 and here if Center so it should be 1,800 monthly we need to pay sorry yearly we 42:01 need to pay 1,800 so this is how we will be we will be using the generic type of thing okay so prompts enter the values so it will it will prompt you to enter the values like principal year and also the rate of interest and it will calculate the simple interest using the formula and it will display the output using the printer so this is how we will be displaying it so by including Concepts like ENT and format specifi the program illustrates both user interaction and also memory handling so in the conclusion before wrapping up what I want to tell is main main is the heart of the every C program handling execution and ruring an integer status variables and operators allow computations printf and scanf are essential for interacting with the user compilation requires both an editor and a compiler often provided through an ADA this fundament this foundational knowledge enables an efficient programming in the SE so hope you understood about this print of and scanof and also the main functionality in the C programming if you have any doubts or any suggestions please post the comments below to this video and if you like this video please do support me by subscribing to my channel thank 43:00 you hi guys this is Leela welcome to my channel Lea webdo so in this video we will try to do some of the pro problems programming through programming so I will try to explain you one by one the coding thing so some solutions we'll try to do it with the programming thing so it's a basic thing so you people as a fresher or you people are doing the btech or anything so you people can practice these things for example let's say that uh any user so so rames something like that rames has a basic salary and he needs to enter the basic salary through the keyboard and we need to calculate the dness Elance which is a 40% of his basic salary and also we need to calculate the house rent Elance which is 20% of his basic salary so we need to write a program to calculate his gross salary so let's try to do it so now here for this one what I will try to do it is let's try to create a new program here I will create a new file uh let's say that salary. C okay so this is the thing now 44:01 here I will be using hash include Studio H and here in this one int main I'll will be using int Main and here we need to calculate this one so now here what I will try to do here I will ask here we can have float so what is the basic salary so here we can ask something like uh what we can do it is we can ask the basic salary so here we can ask basic salary and here we need to know the da DS Elance and also the H and also the total gross salary so you can have it like this total so these are the three these are the four things which we need to have so first we need to know the gr so enter the basic salary basic salary basic salary of of the person anything whoever it may be the person so now for this one so we can do the 45:04 scanf scan F off so here this one is a percentage F right so as this one is a float percentage F and we can calculate M percent sorry am percent basic salary that's it so now we got the basic salary so what we need to do so we need to calculate the BDA deess Elance it should be something around 40% of the basic right 0.4 into the basic salary that's we got the da and we need to get the H also it should be something like 20% of the basic salary so that means 0.2 into basic salary so we got the da H and also the basic salary also we got it now we need to know the gross salary gross salary is equal to nothing but basic salary plus da plus h so these all combined you will be able to get the basic salary so here we need to add a space so that we can able to understand it very easily so now we need to print all the details so print F so I will be 46:06 doing basic salary of the person is equal to percentage of sln so here we can write it something like basic salary now another one is printf dness allowance is equal to percentage of sln sorry slash and here we can write the da last one is printf printf so we can have uh what is that one house rent Elance house rent allance is equal to percentage of sln and here you can have the H the total one last one is nothing but printf gross pay gross pay is equal to percentage of 47:09 sln here I can have something like gross sorry gross gross salary so now here I can do return zero that's it so this is our simple thing so now if you try to execute the code let's try to execute this code so here it will ask you some series of questions so let's try to see it it is asking enter the basic salary of the person let's say that the basic salary of the person is 3,000 let's assume and here you'll be able to see the basic salary of the person is 3,000 dness allowance is 12200 and house and relevance is 600 total gross pay is 4,800 so this is how we will be calculating the uh total this one so here the explanation of this one is so here the person try to see the program ask for the basic salary of the person okay and the formulas is DNS allance that is Da it is 40% of the basic salary and h8 is 0.2% of the 20% of the basic salary and 48:10 grass salary is nothing but the sum of the basic salary da and H so here the basic salary is read using the scan up and stored in the variable basic salary so here it is stored da is calculated 40% of BP basic salary and also it is stored in the da and H is calculated with 20% of basic salary and it is stored in the H so gross salary is calculated with the sum of basic salary D and H the program prints the values of the basic salary da H and gross salary using the printer so this is the basic explanation of the O So now that the next one which I want to tell you is distance conversion so here I will try to create a new one that is nothing but distance so here distance do c so now let's say that distance between the two cities is input through the keyboard write a program to convert and print this distance in meters feet inches and ctim so this is the code which we need to write it so the program converts a given distance in kilometers to meters ctime feets and inches so now here for 49:11 this one what I will try to do it is so here I will do the hash include so distance hash include studio. H okay now here we will be having int main so now in this Main let's say that we'll be having a float so I will be having kilometers so we need to calculate the meters M I will take it CM feet and inch okay so these are the four things which we need to do it so here if you want you can give a space like this so now first of all we need to take the kilometers so print F the distance in kilometers kilometers so here I can use it uh like this and here what we need to do so we need to take the scanf so in this scanf I can take the percentage of and here we need to take the %c kilometer that's it so now what I 50:14 will try to do so first of all we need to calculate the meters meters is equal to kilometers into th000 okay into th000 we will be able to get the kilometers so now meters that is nothing but we know about this one so now here we need to get the centimet cm is equal to Meer into 100 and next one is inches so inch is equal to so we need to get the CM divided by 2.54 then we'll be able to get the ctim now next one is which we want to go do it is that is nothing but feet fet is equal to inch divided by 12 so this is these are the formulas so we got all the things now we need to print the details so here print F distance in meters is equal to sorry distance in meters is equal to percentage of sln and 51:15 here I can use the meters that's it and now here distance in here I can use the CM cm and here I can use cm and next one is distance in feet so we can use the feet and here I can use the feet and last one is the distance in inches I can use the inch so this is how we will be doing and last one we will be return zero now if you want to execute this code so directly you can it like this so now here enter distance in kilometers let's say 300 km now it is showing distance in met is 30,000 so 3 lak 998 so something like this it is showing so this is how we will be calculating the distance in the thing so now here if you try to give the three means you'll be able to get the output so the last one the last code before closing this one so I want to do another uh program simple program which will be 52:16 uh calculating the Aggregate and also the percentage calculation let's say that a student is there so he got marks obtained by a student so in five different subjects so it should be taken as an in inut through the keyboard and we need to write a program to find out the aggregate marks that is total marks and also the percentage marks obtained by the student assume that the maximum marks that can be obtained by student in each subject is 100 so let's try to take it so for this one what I will try to do it is so the same thing here marks I will try to take it marks. C program so for this one what I will do it is so here also same thing hash include studio. H so int main so in this one let's say that I'm having uh int so marks M1 comma M2 comma M3 comma M4 comma M5 comma aggregate last one is the aggregate so these are the integer marks let's assume so why 53:17 I'm taking it as an integer is so we will be getting only with an integer let's say I'm assuming it so float will be the percentage will be always float percentage I'm taking it so now I want to take the values print F enter marks in five subjects sorry enter marks in five subjects so here I'll will be taking only one scanf so here scanf scanf so I'll be taking three values something like like you can also provide it like this also percentage D percentage D percentage D percent percentage D and percentage D five are there so we can also use it like this M1 comma M percent so M percent M2 comma M perc M3 comma M percent M4 comma m% M5 so these are the things which we can do it so here like this also in single 54:18 scanf also we can take it like this now aggregate is aggregate is equal to M1 + M2 + M3 + sorry M4 + M5 so these are the things which we can do it so now here so we are taking it as an Aggregate and now we need to calculate the percentage so percentage means percentage is equal to aggregate divided by total five are there five subjects so now we need to print F so print F printf aggregate marks is equal to percentage d/n sorry sln and here you can use the Aggregate and in the same scenario so here we it should be printf not print and here also you can have it printf percentage marks percentage marks is equal to percentage F 55:21 sln percentage of/ n and here we can use it something like percentage that's it and here I will use return return zero so now if you try to execute this code so let's try to see it so here it is executing that is compiling and after compilation it will ask you enter marks in five subjects so let's say that 23 space 23 space 23 and Space 2 35 space like this I will enter so now here you'll be able to see the aggregate marks is 137 and the percentage in marks we got it is the 27 this is how we will be calculating the aggregation of the marks so now here so key points to be understood is variables and data the program uses the float for decimal values like salary distance and percentages int is used for whole numbers like marks scanf is used to get input from the user printf is used to display the results so basic arithmetic operations like multiplication division and addition are used to calculate the results so in problem second one various 56:22 conversions kilometers to meters feet to inches these all the things we have to it right we have did it using the basic multiplication and division formulas so first first problem what we have did is calculate the gross salary using basic salary deess elevance and ENT Elance so we have we have did it and second one is converts the distance from kilometers to meters ctime feet and inches we have did it and the last one is we have calculated the Aggregate and percentage marks of a student in five subjects so these are the foundational C programming problems that deal with input arithmetic operations and displaying the results so that's it guys about this one so hope you understood about the basic foundational program how to write the coding in the c c language so hope you understood about this concept so if you have any doubts or any suggestions please post the comments below to this video and if you like this video please do support me by subscribing to my channel thank you hi guys this is Leela welcome to my channel Leela webd in this video we will try to learn about the C instructions in the previous video a program is essentially a set of 57:24 instructions these instructions allows to perform specific task in a program so that is the main thing so this is the basic meaning of this one so program normally it is an set of instructions these instructions allow us to perform specific task in a program in the previous video we have learned how to write a simple C programs using various instructions now we will explore these instructions in more detail so types of instructions in the c c programs use three main types of instructions one is type declaration that is nothing but V variable declaration and arithmetic instruction last one is the control instruction each type servers each type serves a unique purpose in C programming let's dive deeper into each type first one is type declaration instruction this instruction is used to declare the type of variables in a program so this first one is so whenever you want to declare a variable so this instruction is useful purpose of this one is it informs the compiler about the kind of data a variable will hold example integer float character like 58:25 this placement typically written at the beginning of the main function or any block of code so example is int Bas so declares an integer variable named Bas in float RS gross salary and here you'll be able to see declares two float variables RS and also the gross salary character name and code declares two character variables name and code so these are the type Declarations of a variable s subtle variations declaring an initializing simultaneously so you can declare and assign to a variable in a single statement also for example in I equal to 10 J equal so here we are declaring the variable and also initializing the value also assigning the value also float AAL 1.5 B 1.9 and + 2.4 into 1.44 like this arithmetic operation also we can do it so this is declaring and initializing simultaneously order of Declaration and usage variables must be declared before use this is illegal because a is used 59:26 before being defined so here B is equal to a + 3.1 and a is equal 1.5 so here we are declaring we are we are declaring the before use only we are declaring it so that means we are after declaring we are using it so this is illegal assigning the same value to multiple variables for example let's say that here this is the correct in a b c d so if you want to assign the same value to the multiple variables means AAL B Cal 10 so all variables are assigned to the value of 10 but here this one is incorrect In AAL b c d 10 this will cause an error so this is one thing so the next one is the arithmetic instruction these instructions allow mathematical operations in a program structure left hand side should be always a variable and right hand side constants or variables connected using arithmetic operators so this is the thing example is in ad float kot daa Alpha Beta gamma so these are the float variables and this is the integer 1:00:27 variable and here I have initialized the variable = 320 and here K is equal to 0.56 I I have initialized it now here daa is equal Alpha into beta by gamma + 3.2 by 2.5 so I have used the arithmetic operation components in this example so what are the components I have used in this example so I have used multiplication division subtraction addition and also the assignment operator is equal to also I have used it so constants means integers 25 320 0 so here we have used it as 2 5 3 320 0.056 so those all things we have used it and now variables are integers one is AD and real real variables is kot data these all the float variables so types of arithmetic statements arithmetic statements can be categorized based on the operant integer mode arithmetic statement operant are integers so here in I King like this I I + 1 King is equal to 24 plus like this I used it so here it will be always an 1:01:28 integer real mode arithmetic component operant are real that is nothing but floating Point values so float here we have used it and we have used some arithmetic arithmetic calculation and always it will be in floating point we number only mixed Moree arithmetic statement operant are mix of integers and real values so here we are having float and integer and we are using the simple interest like this and average also we are trying to have it so this one is something like mixed arithmetic statement key points to remember single variable on the left only one variable can appear on the left hand side of the is equal to operator so left hand side always only one variable should be there so Z is equal to K into L is valid K into L is equal to Z is not valid modulus division operator Returns the remainder of an integer Division 10 by 2al 5 10 m 2 is equal 0 so here modulus result is remainder and 10 by2 is an div dividend arithmetic operations on different data types operations can be performed on 1:02:30 integers floats and characters for example let's say that if you are trying to apply the character the arithmetic operations xal to A and yal B and into Jal x + y if you trying to do it means then it will try to add the ask values of a 97 and 98 and it will result give the value 195 so this is also one concept which you need to remember no buil-in exponential operators so we need to use the PO function from math.h in order to implement the exponential operator so there is no buil-in operator for that one so we need to import it from the math.h file so float a a isal power of 3.2 comma 2.0 raises 3.0 to the power of 2.0 print f means then it will print the N other useful mathematical functions which is declared in the math.h is absolute square root sin cos tan trigonometric functions these are also mentioned in the math. okay the conclusion what I want to tell is this video covers the foundational types of instruction instruction syy type declaration 1:03:31 instructions allow us to declare and initialize the variables arithmetic instructions enable mathematical computations using operation operators and operants these instructions form the backbone of C programming and mastering them is essential for writing efficient and error free code so that's it guys about the instructions in the C programming language hope you understood about this concept if you have any doubts or any suggestions please post the comments below to this video and if you like this video please do support me by sub subbing to my channel thank you hi guys this is Leela welcome to my channel Leela webo in this video we will try to cover about the in-depth explanation of type conversions operator presidence and associative in the swe programming so let's try to see first one is the Artic operations so arithmetic operations if I try to explain you so here I will explain you with the yeah here I like so integer with integer so yields an integer result okay so here arithmetic operations when you are trying to do arithmetic operation integer with an integer the result will be an integer only example 1:04:32 is 5 by2 is equal to 2 so 5 by2 is equal to 2 always it will give you an integer division truncates the decimal part float with float so float with float means it will always yields the float result so one second yeah 1:04:58 hi guys this is Leela welcome to my channel Leela webd so in this video we will try to learn about the key concepts of integer and Float conversions as well as the operator hierarchy and associativity in the C programming so I will try to explain you with detailed explanation example so let's try to address this topic step by step so the first one which I want to tell you is the integer and the float conversion normally in C when performing operations or assigning the values the type of operants integer or float determines how the operations are executed and what type of result will be so let's understand this one in detail so rules for the arithmetic operations for example let's say that whenever you are trying to let's say this is an example so whenever you are trying to do integer plus integer means always it will result an integer only let's say that we are having uh in a isal [Music] 2 comma B B is equal to 3 let's say that we are having like this okay B is equal 1:06:00 to 3 so this is the uh thing which we are having now whenever you are trying to uh print this one integer plus integer a plus b if I try to do int C is equal to A+ B if I try to do this one so integer plus integer always results an integer for example if I try to do 2x3 means you know that 2x3 always will be an floating point but here we are having integer plus integer it will always result to an integer so that is one thing which you need to understand for example let's say that in result is equal to 5 by2 or anything so always results in integer when two integers are involved in an operation the result is always an integer any fractional part is truncated that is one thing so if you try to observe the float float Point let's say that float float number if you trying to do it means then always will be a float so here I am dividing with a float with a float number when two float Point numbers are involved means the result will be always a float so that is one thing which you need to understand so here you can see in such a way that I will show you print F okay print 1:07:02 F so here you can uh do percentage D percentage D or otherwise if you try to do so always it will be a floating Point number only okay so that is one thing which you need to understand so next one is which you need to understand is when an integer integer plus float when an integer and a float are involved means the integer is promoted to a float and the result is always is a float for example let's say that uh I will try to explain you in a is equal to 5 and int B is equal to 2 let's assume so now here you are trying to have a float value float result float result and I will do print up okay or otherwise we'll try to see with an online compiler then we'll be able to see it very easy so now we are able to see it very easily right so here let's assume that I'm having the output run so we are whether we are able to see the output or not yeah here we are able to see it so let's say let's assume that 1:08:02 we are having in a is equal 5 and int B is equal 2 okay and what I want to do int result let's assume int result okay or otherwise let's say that you know that it will be always float so let's I will try to do it result now here I will calculate with result is equal to a by B okay and I want to print print F result is equal to okay we know that it is a percentage F and here I will calculate with the result so we'll try to check whether what is the result 5 by2 means we know that one so here I am trying to calculate okay integer within integer so that's why we are able to get within 2. so that means we are getting an integer value only so the decimal part whichever you are trying to see we are getting it as 0 0 0 0 why because so whenever you are doing with integer with an integer means arithmetic operation integer with an integer means you'll always get an integer value only so whether you declare with a float the 1:09:03 result whether you declare it with the fold flow type also always it will be an integer only in see so whenever you are trying to uh do it with a float with a float so that means 5.0 and this one is 5.0 and let's assume that this one will be a float okay and this is also a float then the result will be always the float only so here now you'll be able to see 2.5 so this is how you'll be having or integer plus float for example let's say that this is an integer and another one is a float then you will be getting the float only integer plus float is also a float only so this is one thing which you need to understand so this is arithmetic type conversion in assignments so when assigning values the type of the right hand expression is converted to match the type of the left hand variable for example let's say that a float is demoted to an integer by trating its decimal part for example let's say that uh here I will try to remove it let's say that I am having an INT I variable and here if I try to assign 3.7 okay and if I want to check it 1:10:05 within percentage d i so now if you try to check it so this one always I becomes three okay I becomes three and fractional part 7 will be truncated so that is one thing so fractional part 7 will be truncated so that is one thing an integer to float integer is promoted to a float by in 0 for example let's say that for the same thing you are having a float and here you are are trying to assign a integer value now if you try to check it here the output so it will be always promoted to okay so here we are using percentage D so I need to send it to percentage Yeah so now you'll be able to see 3. so now you'll be able to see that it has now you have sent three but it will be 3. like this so during evaluation integers are promoted to floats if necessary and the final result is converted to match the type of the left hand variable so that is one thing so now let's say that I will be having one simple example I will try to show 1:11:07 you so we are having float AAL 2.5 B is equal to 4.0 and I'm having an in result so now if I try to do result is equal to a into B plus means so result is always uh integer only why because it has been declared as an integer and here this one will be demoted to int after calculation so there is one thing so this is all about the arithmetic operations and I will explain you about the operation hierarchy operator hierarchy so normally the operate hierarchy the first presidence which it will be taking is the star okay star slash and modulus will have the and modulus will have the highest priority multiplication division modulus second priority is plus and minus and the last priority is the is equal to so this is the hierarchy of the common operators operators with with higher presence are performed first example for example let's say that int I is equal to 2 + 3 into 4 okay let's assume that int I is equal 2 + 3 = 4 means then what will happen first 3 into 4 will be calculated 1:12:07 3 4 is 12 and 2 + 12 and now the answer will be 2+ 12 14 so like this it will be calculated so if I try to check percentage percentage D comma I and semicolon so now if you try to run the output for this one so you'll be able to see the output as 14 so precisions will be taken care for example if you try to apply the parenthesis means then the output will change it to 20 so 2 + 3 is equal 5 5 for 20 now the output will change it to 20 so paranthesis can change the order of the operations associ resolves the this between operators of the same presence most operators star/ modulus plus and minus are left to right associative so it will be left to right associative so that means what it will happen so left from left to write it will be happened so here let's say that I'm having uh 10x 2 into three let's assume so we are having something like this so here what will happen is first left to right 1:13:09 Associated I told you right left to right Associated right so here we will be able to see 10x2 is there so first 10x2 will be calculated it will be 5 then after 5 into 3 it will be calculated now the result will be 15 so you'll be able to see 15 so this is how left to right associativity it will have so this is are about the hierarchy of the common operators which I want to explain you so uh left to right I have explained you right so paranthesis also if you want you want to make it parenthesis means so you can change the order of Precedence with the parenthesis also you can change it now 10 by 5 it will become two uh sorry 2 3 6 10 by 6 like this Al so integer value you'll be able to get integer division you are getting so this is all about the concept of this one so hope you understood about this concept so summary in summary integer operations yield integer float operations yield floats mixed type operations promote integers to floats operator hierarchy and associ govern the evaluation of expression paranthesis can be used to override the default president rules so this is all about the associat of operations and all those 1:14:09 things in the C language so hope you understood about this concept so if you have any doubts or any suggestions please post the comments below to this video and if you like this video please do support me by subscribing to my channel thank you hi guys this is Leela welcome to my channel Leela webd in this video we will try to learn about the control statements in this one so we'll try to understand how we can decision control in programming in the C language we'll try to see it not only in the C language in all the programming languages how we can control this decision control let's try to see for example let's say that in our real time life if you want to modify our actions we often modify our actions based on the specific conditions for example let's say that if the weather is fine you will be you might decide to go for a STW let's say if the highway is busy you might take a diversion or something like if someone joins a WhatsApp group you might send them interesting videos so like this you'll be having some decision making so these decisions depend on whether certain conditions are met or not similarly in the programming also 1:15:10 conditions determine which actions to perform this is essential because not all programs can execute instructions in a fixed sequential manner so let's try to see about this one in programming sometimes we want one set of instructions to execute under certain circumstances and another set in a different circumstances so in C programming this is achieved using decision control instance so for this one so how it will look like is for example let's say that the Syntax for this one is I will try to show you if condition is there statement one so like this it will be if condition statement one or else statement two so here explanation is the condition is enclosed in a parenthesis if the condition evaluates to true the statement one is executed if the condition evaluates to false then the statement two will be executed the statement two will be executed conditions are created using relational operators which compare two values so the relational operators are first one is so relational operators Define how two values are compared here are the operators and their meanings for 1:16:11 example let's say that you'll be having something like x equal to Y so not triple equal x y so this one is true if x is equal to Y and we'll have another situation X is not equal to y and this one will be true if X is not equal to Y and here you will be having X less than y these are all relational operators true if x is less than y x is greater than y so here it will be true if x is greater than y x is less than or equal to Y then true if x is less than or equal to Y and here it will be X greater than or equal to Y so if it is true if x is greater than equal to Y so these are the conditions relational operators which we will be checking so equal to is equal to equal to is equal to operator you need to understand here it is used to compare two values if you are having single equal to means then it is an assign operator assignment operator used to assign a value to a variable so this is what about the condition statement so now I will try to give a simple example to understand the IFL statements in and 1:17:11 the relational operators so for example let's say that uh the problem for this one is if a quantity is purchased more than thousand means then I need to apply 10% discount uh to that one otherwise I should not apply any discount so we need to calculate the total expenses based on the quantity and the price per item so let's try to go into this one so here I will try to create a new file that is nothing but new file or otherwise I will take it in online editor yeah here online editor will be fine so here I will be asking so we will be having int quantity so I will be having a quantity and another one is Discount let's assum so these are the quantities and the discount and we will be having a float that is nothing but total rate uh sorry rate and also the total so this one is the thing price per item rate means price per item so now here I will be asking printer enter enter 1:18:13 quantity and price per item okay so this is your print and I will do scanf so quantity means percentage d so it should be whole number and percentage of here I can do uh % quantity another one is M perc rate so now here if quantity if quantity is greater than th000 means then I need to apply discount so here discount will be discount will be 10% or otherwise else will be discount will be zero discount is equal to zero so this is the condition so now here I need to apply the quantity so total price so here first of all so discount price I need to take so what is the uh discount price so here what I can do it is here I 1:19:14 can apply something like um what I can do it is so float here also I can do price with discount so so we don't know right price with discount how much you will be able to get so here I can do price with discount is equal to so this one is price with discount is equal to so how much it will be quantity here I can write into quantity so how much is the quantity and also how much is the rate and I need to apply the discount so this all divided by 100 so I can get so not, 100 so now I will get the price for discount so total qu total quantity means so what can you do here total is equal to so here I can write something like quantity into rate so this is the total thing I need to dis I need to cancel out 1:20:14 with the price with discount that's it so I can get the discount right so if no discount is there means that zero only so here I can do print of total sorry total expenses is equal to rupees you can keep it percentage of sln and here I can give the total that's it so return zero now if you try to execute this let's try to run this one so it is asking enter quantity and price per item okay quantity is 10 and price per item is 45 our quantity is more than th000 right so so without quantity you'll try to do so that means here what you to do 10 into 45 it should be something around so here you'll be able to see 10 into 45 450 Rupees is the total expenses so in the same scenario what I will try 1:21:15 to do I will try to calculate with the discount so here uh the discount will be greater than 1,000 right so I will be giving 1,00 okay and the item is 4 rupees let's assume so here you'll be able to see the discount has been applied around 40 rup or something like that so here we are able to get 3960 so with the discount it has been applied so here how the program works so user enters the quantity and the price per item so here we are entering and if the quantity is greater than th000 means the condition evaluates to true and the discount is set to 10% and if the quantity is less than or equal to 1,000 means the condition evaluates to false and the discount is applied to zero so total expenses is calculated something like the total expenses to here the total is quantity into rate and here I need to calculate the discount how much discount you needs to apply so quantity into rated discount by 100 so that I can get the discount how much discount I need to apply if the discount is zero Means Everything by divided by 0 is d0 only so here for total means minus this minus thing and I 1:22:15 will be able to get the expense so the here the total expense is printed so this is how we will be calculating so now so if no action is needed means when the condition is false means you can omit the else else block also that's not a problem uh you can keep it as a discount is equal to Z here you can initialize it and here you can remove this Sals block so then you can emit this one also so this also works not a problem so here you can see 10 and 45 so you'll be able to get the same output and here if you try to observe the same thing 1200 and6 so you'll be able to see 6480 so then also it will work this concludes the explanation of the decision control instruction relational operators and the simple IFL statement in the C programming so hope you understood about this concept if you have any doubts or any suggestions please post the comments below to this video and if you like this video please do support me by subscribing to my channel thank you hi guys this is Leela welcome to my 1:23:17 channel Leela webd in this video I will try to explain the use of IFL statement in the C programming with the focus fing on handling how to handle the multiple statements inside each block so if and else and the nesting if else also I will try to explain you so normally what what we have seen we have seen a simple if we have seen it now IFL statement so how we can handle it in the C programming let's right to see in C when you want to execute more than one statement inside the if or else block you need to group them using the braces this is called an if block for the if statement and an else block for the else statement so example I will try to show you so I I will I will write a program for calculating the gross salary of an employee if the basic salary is less than 500500 means it needs to calculate the H and da as per the percentages like uh whatever the percentage we' be giving of the basic salary if the salary is rupees 1500 or more means then the H is fixed to 500 and the da is calculated as 1:24:17 the percentage of the salary so let's try to write the code for this one so that means here the coding is if the if if it is less than 1500 means then da and H should be calculated with the percentage if it is500 or more means then H is fixed to 500 and da should be calculated as per the percentage so this is the requirement of our program and now we need to write it the code so what I will try to do here here I will remove this entire code so we are using the online compiler only so now what I will try to do it is so here in this one let's go let's have float okay basic salary basic salary I will have and the another one is gross salary so these are the gross salary and you'll be having a DA and H so this is the thing now we will ask printf enter 1:25:19 enter basic salary okay so here we we will be having a scan F so is this one is a float number right percentage F so M perc basic salary so you will be taking the basic salary so this is the variable which we are having it fine now if basic salary is less than 1500 means then what I need to do so here I need to calculate the H is equal to basic salary into 10 divided 100 so if you want you can keep it as a bracket like this why because left to right Associated will be there so into will be done at the first time so fine so now we got the H now the da is equal to so we will be having the basic salary into 90 90% of the B basic salary the da should be given and I need to divided by 100 that's it so this is the 1:26:20 formula which we are having so now if it is greater than 100 so500 or greater than 1500 means then what I need to do so H is fixed to 500 so we know that H is fixed to 500 and the another one is Da so we need to calculate the da so da is basic salary into 98% I'll take it 98% of the basic salary divided by 100 so we'll try to give divid by 100 that's it okay so we try to go Center yeah so now now we got the thing now I need to calculate the total gross salary for this one gross salary gross salary is equal to basic salary plus da plus h so depending on the conditions it will be calculated so now I want to print F gross salary is equal to pce percentage F sln so if you want 1:27:23 you can keep it and I want to give the gross salary that's it finish this is our code so let's try to run it this one let's try to see enter basic salary so the basic salary is something around 1,600 let's say so the gross salary is 3,668 so for example if I try to run it again and let's say that gross salary is 1,000 so then it is 2,000 so that's it 10% and 90% we are calculating right total it is 100% 2,000 we are able to see so 98 plus 500 so like this so this is how we will be calculating the uh if block thing so here if I try to explain you the statements inside the first if block are executed when the basic salary is less than 1500 so when the basic salary is less than 1500 the if block statements are executed it calculates the H as 10% and da as 90% of the basic salary so in the else block if you try to see the statements inside this else block are executed when the basic salary is rupees 1,500 or more it assigns 15 500 as H and 1:28:26 calculates the da as 90% of the basic salary so for example uh so this is how we'll be calculating so the next one which I want to explain is the nesting IFL statements you can also have one if else statement inside another if or else block this is called as a nested if I will try to show you one example so here I will try to show you one example here like this so for example let's say that uh I will show you here in our code only so here for example let's say that this is our code so this is our code and here you can you can have in I is equal to 1 let's say so here we are trying to check here in this one if I is equal to is equal to one means then it will print the if print a message it will print a message more questions like this so if I is not equal to 1 means then it will go into the else block but if I is equal to 2 means then it will ask you it will print another message but neither of 1:29:27 these conditions I is not equal to one or I is not equal to two means then it will try to print this else block so this is how it will be printed so this is called as a nested IFL statement so in see the condition inside an F statement does not have to be a bullan expression so this is one important information you need to understand so in the C condition inside an if statement does not have to be a bullan expression true or false any valid expression that results in a non-zero value is treated as true and zero is treated as false for example let's say that you are having an if block something like this let's assume okay if you are having an if block like this means it is true because the expression results in as five what it is a non zero and also for example let's say that you have given assignment operation in the if block if a is equal to 10 it is also valid because a is assigned as 10 so it is a non zero hence it is true even the negative numbers something like negative numbers are zero floating Point numbers also valid as true only so here minus 5 or 3.15 so like this if you add it in the false it 1:30:27 is treated as a true so this is one thing a common error is placing a semicolon right after the if block some people will try to do like the semicolon so this is the common error which you'll be able to see this causes the if block to be empty and the following statement always gets executed regardless of the condition so for example here if you try to see if a equal equal to five like this you have printed means always you entered five this one will be executed regardless of the I value so that is one thing which I want to explain you so that's it guys about this multiple statements if and also the nested if nested if thing so hope you understood about this concept and also the rules and regulations how to follow the if block when it is treated as a true so the truthy thing also I have explained you so in this video we have covered how to use the multiple statements inside if and else blocks grouped with braces and also we have seen about the nesting IFL statements to handle multiple conditions expression handling if statements when non-zero values are treated as true and zero as false a caution about the 1:31:28 semicolon after the if conditions which can lead to the logical errors also we have seen it so that's it about this concept so hope you understood about this thing if you have any doubts or any suggestions please post the comments below to this video and if you like this video please do support me by subscribing to my channel thank you hi guys this is Leela welcome to my channel Leela webd so in this video we will try to do some programs some problems in the C program demonstrating the basic concepts of the program programming using C and also focusing on this decision control structure which we have learned about the IFL statements so these are some of the pro programs you'll see the first program which you'll see is the profit or loss calculation so what this program will tell is this program calculates whether a seller made a profit or got a loss or neither based on the cost price and the selling price entered by the user so the logic explanation which I want to tell you is if the selling price is greater than the cost price means then the seller has made a profit if the selling price is less than the cost price means then the seller incur a loss 1:32:26 so like this the logic explanation I will try to I will try to show you in the notepad++ so that you'll be able to understand very clearly notepad++ yeah so here profit and loss calculation I will try to uh I'll try to show you so here let's go into the new one yeah so here so if the if the selling price is greater than the cost price means then the seller made a profit okay if that means profit is equal Al selling price Minus cost price and loss means if the selling price is less than the cost price mean then the seller has incurred a loss so loss means see cost price minus selling price no profit no loss means if the selling price is equal to the cost price neither profit nor loss so this is the logic explanation so now what I will try to do so user uh the input is user inputs the cost price and the selling price now we need to calculate the profit using the selling price Minus cost price and the loss is calculated as cost priceus selling price if profit is positive means then the 1:33:26 program prints The Profit value if the loss is positive means then the program prints the loss value if the profit is zero means it means that is neither profit nor loss so input for example let's say that input is 2515 means the seller has incur a loss of 10 Rupees so let's try to uh see this program for this one profit or loss calculation so I'll will be using the online editor for this one so here this is the thing and I will try to return the zero so that means I explained you right it's a success case so now we will be having a float cost price so we'll be having two things cost price selling price okay and the another one is profit I'm writing like this profit and a loss so these are the float variables so now we will be asking printf enter cost price and the sorry and the selling 1:34:28 price like this so now here scan F we will be getting two variables percentage of percentage of comma %c cost price and also amp percent sorry %c cost price and also %c selling price so these are the two variables which we will created so now we need to calculate the profit profit profit is equal [Music] to selling price minus sorry Minus cost price and the loss is equal to cost price minus selling price that's it so now if profit so now here we'll be using the profit condition if profit is greater than zero so that means we got a profit so here I will try to do seller print 1:35:30 of seller has made a profit of rupees percentage 2f okay and here I can write the profit profit that's it so else if loss is greater than zero means then printf seller has made a loss of rupees here also I can do percentage 2 F and here it will be loss that's it so nothing has happened means then I can do a else printf printf there is 1:36:32 no there is no loss or profit that's it so this is the thing so this is the output for this one now if I try to execute this run this one it will ask you it is executing so let it execute command time what is the problem for here I don't know let's execute it again so fine here it is asking enter cost price and the selling price so here I'll will be adding the cost price as 300 and the selling price as 500 so now if you press enter command not found so what could be the reason here print of print of print of it is correct if profit is greater than Zer else if loss loss is greater than zero everything is correct command not phone so that's why we should not rely on these online compilers and all those things it's better if we can if we have our own Visual Studio only but why unnecessarily to go we try to check it 1:37:34 here at the final thing this one return zero so now if I try to run this one so let's see whether it will ask or not enter cost price okay 300 and 500 if I press enter see seller has made a profit of 200 so now this this is this compiler is fine so just like our local compiler so now seller has made a profit of 200 if I try to make it as a cost price and selling price equal 300 and 300 so there is no loss or profit if I try to run it something like cost price is 500 and I have S sold it for only 200 then seller has made a loss of 300 so now this one is able to work perfectly so we are able to calculate the profit and loss calculation depending on the user so now the seller has made a profit or a loss or neither based on the cost based or neither based on the cost price and selling price we are able to do it so the next one which I want to explain you is the odd number odd or even number so 1:38:34 the this program checks whether an integer entered by the user is odd or even so now for this one so what we can do it is so the logic explanation I will try to do it it's a simple thing only it's a simple code only uh I will remove this entire code here from top to bottom so this code is finished and here I will use int n okay okay more otherwise what I will try to do it is I will keep it like this only so now here I will be having a number int number so we got a number now what I need to do so print of I will ask enter any number okay and here I will be using the scanf okay and in the scanf what I will try to do so here percentage D and I will ask M percent number okay we got the number now what I will try to do if n mod 2 is equal toal 1:39:36 sorry not equal to equal to zero so if it is zero means then I can do print of print of the number the number is even so this is an even number and if else so if it is not there means then what I can do print if the number the number is odd that's it so this is how we will be writing whether to find an even number or non- number so here you can use the return return zero so that it is a success case so now the explanation for this one is so how can I explain this one is order or even number so now this program checks whether an integer entered by the user is odd or even so a number is even means if it is divisible by two without any remainer that means n mod equal equal to Z means then we can say it as an even number or otherwise it is odd so now here the program explanation if I try to see the input we are taking the input user inputs an integer n so we are checking the condition if n m 2 is equal toal Z 1:40:38 then the number is even we are printing or else we are printing the number is OD so now let's try to see the sample output for this one so it will ask so what it is trying okay n we have written right number okay so now here you'll be able to see it it is asking enter any number so now if I try write 45 it should tell that oh sorry 45 it should tell that it is number is odd in the same scenario if I try to write 12 means it should tell it as a number is even so this is how we will be able to calculate the uh what I mean to say the number is even or not so the last problem or the last program which I want to explain you before closing of this one is Leap Year determination so how we can determine the leap year thing let's I will try to explain you so normally the this program so whatever the program we are trying to write determines whether a given year is a leap year or not so the logic explanation what I want to tell you is a year is a leap year if it is divisible by four and not divisible by 100 so that 1:41:38 means year mod 4 is equal to 0 is equal equal Z and also year mod 100 is not equal to Z then we can say it is in divisible by uh sorry it is a leap here or otherwise year mod 100 is not is equal to zero means ear mod 4 is not equal to zero means if it is divisible by 100 means then also it is a leap year so this is the blind Logic for the finding of the leap year otherwise it is not a leap here so let's try to see so I will try to write the code for this one leier calculation let's say that we are having an INT here so here I will write printf enter here and here I can ask the scanf percentage D so it is an integer and here I can write the year m%c year so that the memory location in the memory location the value will be saved so now if here mod 100 is equal to equal to0 if it is equal to equal to Z means then what I 1:42:39 can do so if it is equal to zero means 100 100 equal to Z means then I need to check that if here mod 400 is equal equal to Z or not if this one is also equal to zero means then we can say that it is a print of it is a leap here okay so for example let's say that if it is not a if it is if it is not mod 400 is not equal to zero means then we can blindly say that print F not leap here okay so now one one if condition is finished so for example let's say that year mod 100 is not equal to zero then we need to check that else and here we can write in such way that else if here mod 4 is equal to Z or not ear mod year mod 4 is equal to equal to Z or not we'll try to check it then we can print it print of leap here so I'm trying to write it here with the N if thing so that you can able to understand it very easily the freshers so who are 1:43:40 trying to learn this C language and who are bch students they can easily able to understand it so now here I will be writing printf printf not a leap here that's it so this is the logic for this one so now if I try to execute this so run it if I am not a leap here okay I did forgot to give a semicolon so now here it is asking 2012 if I try to enter sorry if I press enter it is saying it is a leap here if I try to run this one 2 2013 then it is not a leap here so this is how we can able to calculate that whether whether a given year is a leap year or not so that's it guys about this all the things so hope you understood about this concept if you have any doubts or any suggestions please post the comments below to this video and if you like this video please do support me by subscribing to my channel thank you hi guys this is Leela welcome to my 1:44:41 channel Lea webd in this video we will discuss about the logical operators and also the conditional constructs in the C programming language so now this video discuss how logical operators and conditional constructs in programming language can be used to execute multiple conditions and take appropriate actions so let's see about this one with clear examples and uh explanation so logical operators in C C actually provides three logical operator first one is the ERS ERS and so this combines two condition both conditions must be true for the result to be true so example which I will try to show you is the for example let's say that this is the example if a is greater than 10 and also B is less than 20 then both conditions are true so this is called as a logical n and another one is logical R so this is another example which you'll be having combines two conditions at least one condition must be true for the result to be true so this condition will be in 1:45:44 such a way that we will be writing in the C programming language if a is greater than 10 or B is less than 20 so then it will print this one at least one condition is true so the last one is the neg negation not operator so this not operator what it will TR to negates a condition the result is true if the condition is false then only it will be false so now here you will write condition in such a way that if not off a greater than 10 then the condition is false so these are the three logical operators that are available in C and we'll be using it so now I will try to take one simple example so we need need a program that takes marks in five subject calculate the percentage and determines the division based on the following rules first division is percentage greater than or equal to 60 means then it is first first thing second division means 50 less than or equal to percentage less than 60 so that means it should be in between 50 and 60 third division means it should be between 40 and 50 and less than 40 means 1:46:44 fail so now I will try to show you a simple example so I have already example with me so just I will try to copy it and I will show it here so here this is the thing so now here we are taking the five subjects marks M1 M2 M3 M4 and M5 and we are taking the percentage also so these are the integer and here we are printing F and we are trying to check the value for this one okay so now here we are checking the percentage M1 + M2 + M3 + 4 into 100 ID 500 so we are we are checking the percentage for this one so if the percentage greater than equal to 60 means then what we need to do it's a first first division else if the percentage is greater than or equal to 50 means then it is second division else if a percentage is greater than equal to 40 means then s or otherwise fail so now if I try to run this one so it will be asking you about so here I can write 35 45 25 25 and 56 and 67 let's try to see 1:47:46 1 2 3 4 5 so if I right click so we got the third division so that means greater than equal to 40 so we got the third division so this is how we will be able to calculate so now here we are writing the nested Els conditions so now advantages for this one is straightforward to right disadvantages disadvantages is code becomes difficult so here the simple nested if by using nested if we have written code becomes difficult to read due to excessive nesting matching ifs Pairs and bres challenging indentation increases making debugging harder so now the same way by using the logical operators we can implement the same thing so this approach eliminates uh logical Operator Operator approach eliminates sting by com combining conditions using logical operator m% m% and R so for this one what we can do it is the same scenario we can write in such a way that so these all if conditions Ned if conditions you can remove it and here I will be writing in such way that if percentage is greater than equal 60 means first Division if 1:48:48 the percentage greater than equal 50 and less than 60 means second division and if the percentage is greater than equal to 40 and less than 50 means third division so that is so now if you try to run the same output so now here you'll be able to get the same output 34 23 and 13 and 56 and 47 so if I try to press enter now he is fail so this is the thing so now here you'll be able to get this one so advantages of this one is code is flat and easier to read and no nested blocks disadvantage is all conditions are evaluated even one even if one is already satisfied leading to unnecessary checks so method three is using El if condition okay so here we have used all the netive condition right so method three what we can use it is the we can this approach is use the lcf construct to eliminate the unnecessary evaluation so for this one so what can you do here if you are using the simple F like this so we can have something like this one so if percentage greater than 60 means like this LF means like this and L means like 1:49:51 this so here we can do it like this so now if I try to check the scenario then also we'll be able to get it pass so 23 sorry 34 45 and 56 and 67 if I press enter so we got the third division so this is how so this ruce the indentation once a condition is satisfied and no further conditions are checked handles the none of the above case with the final else SC so this is how we will be checking the uh what I want to say is The Logical operators so this is how we'll be using the logical operators log now the key takeaways is so here what I want to tell you is so by the end of this video logical operator simplify condition handling but may lead to unnecessary evaluations if not used carefully LF is efficient and reduce code complexity when dealing with multiple exclusive conditions choose the approach that best suits your specific requirements and ensures code readability and maintainability so 1:50:51 that's it guys about this one logical operators concept hope you understood about this concept so if you have any doubts or any suggestions please post the comments below to this video and if you like this video please do support me by subscribing to my channel thank you hi guys this is Leela welcome to my channel Leela webd in this video we will try to see about the usage of these logical operators and conditional operators in the C programming language which are essential which are essential tools for decision making in the programs so let us try to understand each one in this video so first one is logical operator so that is nothing but we can say it as an Sr no problem so I already told you the logical operators are the mainly three types logical operators are used to combine multiple conditions or Expressions to produce a Boolean result true or false the three main logical operators are logical and logical R and also the logical not so in this video we will see about this logical thing so for example let's say that um so I will WR 1:51:51 write will try to write a program for this one so normally so let's try to understand a program that where the insurance eligibility of a driver so you'll try to see the program something like the insurance eligibility of a driver so it should be determined based on his marage marital status gender and age so the driver will be insured only if so this is the program which we'll try to write if he is married and they are an unmarried male about 30 years old or they are unmarried female above 25 years old then only this insurance is valid so now if you want to take an insurance means at least you should be married or otherwise if you are unmarried means and male means then it should be then you should be 30 years old or otherwise if you are unmarried female means then you should be 25 years old so now the C program which we are trying to write it here so we need to use the logical operators for this one so the C program uses logical operators to combine these conditions into a single check the the conditions are checked using logical end and Al logical 1:52:53 R and the final ration is made is made using an if condition so let's try to write this one so for this one so what can I do here so the condition so in which we can write it is for example let's say that I have already the code with me so just I will copy and paste it here so that you can able to understand it clearly I will explain you the code here so here we are having explanation of this thing so here we are having a character car sex and also the marital status we are trying to check and we are checking the int age also so these all the things I'm getting it age sex and also the marital status so here we need to enter it so now here I am trying to check the conditions for this one so here marital status is equal equal m so that means if the driver is married and the result is true insured so if it if the marital status is married means then it is true so for example if the mar second condition the marital status is if the driver is UNM married and male and Boulder than 30 1:53:57 then it is true okay and another one I'm trying to check if he is unmarried the driver is unmarried female and he is greater than 25 then it is also true so if any of these conditions are true means then the driver should be insured so now if I try to execute this one so let's try to see it here so it will ask you age okay fine so I will write it as an 45 okay and I should be uh sex is so unmarried okay so I will try to add it as an unmarried and also I am male let's try to check it so now here if I try to see driver should be insured so that is thing so now using logical operators with multiple conditions so you can also check the logical operators so now so we will try to see logical operators now in this one I will try to explain you about the logical operators logical and logical can simplify decision making process involving multiple conditions for example in a company salary calculation program the 1:54:59 salary depends on the gender years of service and qualification so if you want to write it means so you can have so very big one so I will try to explain you this one so here I can have a simple code so just I want to show you the simple code for this one so here year of service qualification and also the salary so here we are asking enter gender year of service and qualification so like this we can use this multiple conditions like this and we can able to get this one so we'll try to see the scenarios and all the things the this program calculates the salary based on the three factors gender years of service and qualification The Logical operators and and R are used to combine the conditions that determine the salary so if the gender is male and years of service is greater than 10 and also the qual qualification is equal to 1 means then the salary will be 11,000 so else if gender is male and year of service greater than 10 and the qualification is equal to zero means so here graduate and also the postgraduate so if he is only The Graduate means the are if the gender is male and year of service is less than 1:56:00 10 and the qualification is postgraduate mean then the salary is 10,000 so like this based on the qualifications and all the things so you can able to deter write the logic for this one so the last one which I want to tell you is the not operator okay the not operator is used to reverse the logical value of the expression if an expression is true means applying the not operator will make it false and vice versa this is is particularly useful for negating the conditions for example if not a flag something like that so this is how we will be trying to do it so we can we we should also know about the operator presidence the second one which I want to tell you is the operator presidence so now here if I want to learn about this operator presidence here in C programming operators having have different levels of presidence which determine the order in which the operations are performed in an expression so now I will try to provide the values summary of this one so logical knot has the highest precedence and star this one arithmetic operations have the next highest presence logical end has a lower 1:57:01 presidence and R has the lowest presidence operators with higher presidence are evaluated before those with lower presidence you can use parenthesis to alter the order of evaluation if needed so the last one which I want to discuss you with before closing this one is conditional operator so now what is this conditional operator or ternary operator we can say the operator is a Shand for an IFL statement and is sometimes called the ternary operator because it takes three operat the general syntax is expression question mark expression two and expression three I will write it here expression one question mark expression two and expression three if expression one is true means then expression two is evaluated and return if expression one is false means then expression three is evaluated and return return for example let's say that this is our example int X is equal to age greater than 18 means then 1 Zer so if age is greater than 18 means then X will be 1 or else X will be zero so this is simple thing so you can also use the nested 1:58:02 conditional operators also so nested conditional operators means you can Nest conditional operator to handle more complex conditions for example here if you try to check it here big is equal to a is greater than b then we will be checking a is greater than C then three or otherwise four so if a is not greater than b means then I will try to check whe whether B is greater than C or not so then six and8 so this one is the complex nested conditional operators so the now what I want to tell you is so there is a points out a common mistake where the colum part of the conditional expression might cause an error if it includes multiple statements to fix this enclose this one in a paranthesis for example let's say that here I will try to show you a is greater than b means question mark G is equal to a or otherwise G is equal to B so this is the correct way so this is how you can assigning thing you can do it so total in the summary what I want to explain you is so now this video explains how 1:59:05 logical operators logical and logical R and not operator and conditional operators like question mark this one are used to handle decision making programs in the C program logical operators are used to combine multiple conditions while the conditional operators provide a more cons consense way to express simple if statements understanding the presidence of operators and using paranthesis effectively is key to ensuring that Expressions evaluate in the correct order so this is the main thing which I want to explain you so here in this uh video we have learned about The Logical operators like logical and logical R how we can use it with the different ways and also the not operator we have seen and we have seen about the operator prence also the not operator has highest presidence and R has the lowest presidence and we have seen about the ternary operator question mark and the column which will be evaluated so this is that is guys about this one so hope you understood about this concept if you have any doubts or any suggestions please post the comments below to this video and if you like this video please do support me by subscribing to my channel thank you hi guys this is Leela 2:00:06 welcome to my channel Lea webdo in this video we will learn about the loop control structure so introduction to the loop control instructions so in programming Loops are a mechanism to repeat a set of actions multiple times so if you want to repeat a multiple set of actions multiple times then Loops are a only the thing this repetion can be used in a specific count or a condition Loops are a powerful tool for automating repetitive tasks making programs efficient and concise so key points so what are this key points in this one let's try to see Loops allow executing a portion of code repeatedly so I already told you Loop stops when a specified condition is no longer true so until and unless that specific specified condition is true the loop will be repeated so there are normally three types of Loops are there in C language types of Loops are while 2:01:07 for and do while so in this video we will focus here in the first one the while loop let's try to focus on this one so about the while loop now the while loop so let's try to learn about the while loop the while loop is used when the number of repetitions depends on a condition that is checked before each iteration so now this condition will be checked before each iteration so I will try to give you the Syntax for this one so the syntax will be like this while condition and body of the loop so here what I want to explain you is so the syntax I will try to explain you the condition is evaluated at the start of each iteration so this condition will be evaluated at the start of each iteration if the condition is true the body executes then the body of the loop executes if the condition is true if the condition becomes false the loop stops and the control moves to the statement following the loop so the next the control it will move to the next statement so that is 2:02:09 the thing so I will try to show you an example program of a simple interest calculation so now I will try to show you about the simple thing let me try to show you you so now so let me open the online compiler for this one Chrome so fine so this is our online C compiler now let's try to write the code so here I will be writing the code in such a way I will explain you this concept also so first one is int principal and the year and the count I will take it okay the count here I'm taking extra count float rate and also the simple interest so this is the simple thing which I would be trying to take it okay so now here I will Loop over the while loop while and here I will make it as a 2:03:10 count is equal to 1 here it's a semicolon count is equal to 1 so this is the thing while count less than or equal to three oh sorry while count less than or equal to three then here what I will try to do so I will ask the print of enter values of principal rate so here I will ask [Music] principal principle actually principle not principle here also it should be principle and here it should be rate rate here sorry here and also here rate of interest so rate of interest so now here it will be scanf so I will be taking the three values scanf okay principal and 2:04:11 year and rate okay so here I'll be having the rate so now I need to calculate the simple interest simple interest is equal to principle into year into rate so it should be divided by 100 that's it divided by 100 now I want to print the simple interest and I need to make the count Plus+ that's it so now I will paste it here so here I'm am simple interest so here I will print simple interest and the count I will make it as a Plus+ that's it so this is a simple code now if I try to run it here let's see what we ask enter values of principle year and principle is 3,000 let's assume and year is 4 years and the rate of interest is 9 press enter so the simple interest is [Music] 2:05:12 1,80 so again it is asking okay so 1,000 and it should be 5 years and the rate of interest is 10 so I need to pay 500 so the next another one 5,000 so rate of six and the rate of interest is 20 so I need to pay 6,000 so this is how it has asked three times why because the count I'm checking to three times so let me try to explain you how it is working the loop runs three times count less than or equal to three so here the loop runs three times each iteration prompts the user for input of principle year and the rate so each iteration three times it will ask it calculates so each each time it calculates the simple interest and displays the result the loop counter count is incremented for each iteration so here count plus one so that's it so here in the key points which you need to remember is that count is the loop counter and the body so whatever the body is en enclosed with the curly braces here and the loop ensures the instructions are executed repeatedly 2:06:13 until the condition count less than or equal to 3 that means it becomes false so that that thing so Loop condition must terate so you need to understand that the key points tips and traps also you need to understand that Loop condition must have to terminate so that means ensure that the condition eventually becomes false otherwise Loops runs indefinitely so example of this one is so I will try to explain you so you should not write it here so while I is equal to 1 I less than 10 and I am trying to print the I so here the loop will always be less than 10 so here I is never incremented so you are not trying to increment the value of I so the loop runs forever and increment and decrement thing so you can increment or decrement so you will be having two types that is nothing but here this is thing so I equal I + 1 the Shand notation is I ++ you can also use the I ++ and here 2:07:14 decrement means I is equal to i- one or also you can use IUS minus so here the decrement loop is such a way that it will be having so int I is equal to 5 and here I am checking the decrement thing I greater than or equal to 1 then print make the computer literate so I is equal IUS 1 so here I am trying to decrement it so floating Point Loop counters Loop counters can also be floating Point numbers so not a problem floating Point numbers also you can use it so for example let's say that here this is the example so let's say that you are having float a equal to 10.0 and a less than equal 10.5 you can also increment with the 0.1 so the increment or decrement may be any value example 0.1 so you can also use the multiple conditions also so you can use logical operators like m% m% or for more complex conditions also you can use it for example let's say that here this is our thing while I greater than equal to 10 % 2:08:16 % J less than or equal to 15 so like this also you can use multiple conditions in a single while addtion so common errors normally the errors what you will be able to see is extra semicolon so you should not keep the semicolon after the while loop the semicolon makes the loop empty causing an infinite Loop so that is the main thing improper initialization forgetting to initialize or increment the counter correctly can cause The Logical errors also so that is also one important thing which you need to understand so normally we are having some increment operators like P post increment so one is the post increment so you need to understand about this one also post increment i++ the value is used first then it is incremented so for example let's say that here so here it will print i++ first of all the value is used so that mean 0 is less than 10 then it will be incremented to one so value is used first then only it incremented so it will print from 1 2:09:16 to 10 okay so here 0 less than 10 it will check and here it will increment afterwards it will increment then then one will be printed pre-increment value is incremented first then it will be printed so here if you try to check it this one so here I'm using I less than 10 here I'm using I less than equal to 10 so here first of all the value will be incremented then only the condition will be checked then it will be printed so that is also one option which you need to understand so now we are having compound assign operators what is this compound assignment operators so instead of writing I equal I + 1 you can use i+ isal 1 increment by 1 J minus equal 10 in decremented by 10 K star into 2 multiply by 2 m byal 2 divide by two M mod is equal 3 means remainder after division by 3 so these These are called as an compound assignment operators so now I will try to show you printing numbers from uh 2:10:17 using the while loop from 1 to 10 so using standard increment so I will try to show you in the online editor so this is our online editor right so now here if you try to check it so I'm using in I is equal to 1 while I less than or equal to 10 so print f i i + 1 so now if you try to check it here so you'll be able to see the 1 to 10 has been printed so using the IAL I + 1 so now if you want to standard increment we have seen it so now if you want to print with the basic increment means uh sorry increment operator means you can use i++ and there is no need to use the I is equal to okay now if you try to do here the same output you'll be able to see so compound assignment also you can use it i+ is equal to 1 so now if I try to run this one then also it will work without any problem using a post increment also you can use it so instead of using this one you can also use I ++ and is equal less than or equal to 10 2:11:20 instead of using less than equal 10 you need to use the less than 10 that's it now if you try to see then also you'll be able to see okay so here you need to make it as a zero or otherwise you can make it as is equal not a problem so not is equal to 10 it will not work so you need to make it as a zero here so then also this one also will work so using pre-increment operator also you can work so this is how you will be working in different situation in different thing you can work it summary what I I want to tell you is the while loop the while loop is a versatile and Powerful tool for repeating in programming so I will try to show you the summary I will print it and I will have written this one so the while loop is a versatile and Powerful tool for repetition in programming the loop runs as long as it's condition evaluates to True care must be taken to ensure proper initialization incrementation and termination to avoid infinite Loops increment and decrement can be implemented in multiple ways including plus plus minus minus and also compound 2:12:20 assignments Plus is equal to and minus is equal to so that's it guys about this F Loop so hope you understood about this concept if you have any doubts or any suggestions please post the comments below to this video and if you like this video please do support me by subscribing to my channel thank you hi guys this is Lena hi guys this is Leela welcome to my channel Lea webo in this video we will learn some of the programs involving the while loop I will try to do it the first program or the first problem which we'll be trying to do it is calculating the overtime pay of 10 employees or five employees something like that so here let's say that employees the problem for this statement is the employees working more than 10 hours are paid overtime at a rate of 120 per hour so we should calculate the overtime pay for five employees or anything based on their hours work so here what we will try to do it is we will initialize the variable so here so what I will try to do it is so here I will try to have float okay overtime pay so this is the over time 2:13:21 pay I need to give it here I will take something like and here I will have in hours they have worked hour and also I is equal to 1 so these are the employees so let's say that so while I less than or equal to three okay so for three employees I will try to check and here I will be asking the printer enter number of hours worked so this is the number of hours work so I will do the scanf scanf percentage D and here I will give m% hour okay so number of hours work so now here if how is greater than 40 means then I need to give the overtime pay for this one so OT pay is equal to hour minus 40 so normal pay means hour minus 40 so I need to minus out the 40 how many hours they have worked so I need to do hour minus 40 and I need to add the 2:14:22 120 rupees for each hour okay sorry not plus 120 into 120 so whatever the things comes into 120 or otherwise overtime pay is zero OT pay is equal to zero that's it so now here what I need to do here I need to pay I need to print the total number of amount I need to pay over time amount so hours is equal to percentage d okay these many hours he has worked and over time pay is equal to percentage D and I need to give our and also the VP that's it so now here what I need to do don't forget to do the i++ at the end that's it and here at the end we can have return zero that's it so this are this one so here what I have did it so first of all I have initialized the variable so here this is not float I have initialized the variable OTP that's that stores the overtime pay and also 2:15:23 hour stores the number of hours worked by an employee and I is the counter for the loop so now the program prompts the user to enter the number of hours worked for each of the employees so let's say here three employees are there so now if the hours worked hour is greater than 40 means if the worked hours is greater than 40 means then the overtime pay is calculated as hours minus 50 into 120 otherwise it is zero so now we are printing the now we are the program output ours work and they calculate overtime pay for each employe let's try to see for this one output so here number of hours worked is 50 let's assume okay hours is 50 and over time pay is oh what is happened okay have used the dollar day so let's try to give it as percentage let's try to see again so here 50 oh overtime pay so what we what is the over time pay okay it is not percentage it is percentage of it's a float right so fine so over time pay is let's say 50 so now hours is 50 and over time pay we 2:16:25 need to pay is 1,200 okay again it is asking number of hours it has been worked so let's say 45 so it is ask it is asking to play now if I try to give 41 so 12 you need to pay the code execution is successful done finished so this is how we will be calculating the thing so now if you don't want like this means you can keep a slashing so that you'll be able to get each line in individual line so here if I try to give 45 it LO again so 34 so it should be 0o 67 it should be 3,240 so like this you'll be able to have so this is one program which which demonstrates the while loop so printing the overtime pay for the employees so the next one which uh the next program which I want to explain you is the factorial of a number so calculate the factorial of a number entered by the user the factorial of a number means here n is the product of all integer from ENT so here I will try to do this one so here I will remove this entire code of to here okay so here I will take int num I and also the factorial so these 2:17:28 are the integer variables I'm taking it okay so now I will be asking is printf enter a number okay so this is the number I'm asking and scanf percentage D percentage D and here we need to give M person number number also I will give so now here factorial is equal to 1 and I is equal to 1 okay I'm trying to calculate the factorial for while while oh sorry while I less than or equal to n okay while I less than or equal to n then I will try to do fact is equal to fact into I that's it and I ++ I less than sorry so now I ++ so now here what I was 2:18:30 trying to do so factorial is equal to 1 and I is equal to 1 okay so now what I was trying to do here so we have the number and I from I less than equal to n so then I'm trying to calculate the factorial so now at the end what I will try to do so I will try to print the result so for this one here that's it so now if you try to check it i++ okay semicolon is compulsory in C language so now here if I try to do three means 3 into 2 into 1 so it should be six so like this you'll be able to see it so now I will try to explain you this one so code explanation means input number so it will prompt the user to enter a number num okay and we are initializing the variables fact is initialized to one and also I is initialized to one for looping and it is fact is initial to one to hold the factorial value and now using a while loop to multiply fact by each integer from one to number so now at the last we 2:19:32 are printing the calculator result so this is how we will be printing the factorial number so now this is how we'll be calculating the factorial number let's move on to the another one another problem or another solution so we need to calculate the power of a number so compute the value of one number raise it to the power of things something like x to the power of two something like that so now for this one what I will try to do is I will remove this enter code so I can have in float X comma power okay let's say that power and here also what I want to do int y comma I okay and here this one is float okay so now I will be printing of the X and Y values enter two numbers okay so the ENT enter two numbers I'm trying to take it enter two numbers percentage F and percentage D X and Y I'm trying to take it so now here what I will try to do here I will try to do power is equal to 1 and I is equal to 1 2:20:36 so you know that power of X Comm y the math.h we have a power of X comma y just we are trying to do with a looping thing so that you can able to understand the looping concept so here while I less than or equal to y okay then I will Loop over 1 by one so here I will try to do power is equal to power into I that's it so now here I ++ I will do power into I okay so now sorry power into X we need to do into X so we are taking the x value right power is equal to power into X now we need to print the value that's it so now now here I will try to explain you the code so here the code explanation what I will the program prompts user to enter the base number Base number X and also exponential y so we are taking the thing and we have initialized the power of value to the one to store the result and I is used 2:21:37 for looping so this is the store of the result and looping so now here I am trying to check I is less than or equal y so this is looping right and y means those many times I need to Loop that one right so those many times I loop I I need to Loop this x so here power is equal to power index so that means 3 into 1 so like this it will go on execute so now if I try to execute this code it will ask you base thing so three and two now 3 to^ two so 3 into 3 it should be n so like this you'll be able to calculate it so this is all how you will be calculating summary of Concepts what I want to tell you is while Loops are used to for iteration Loop controls I are incremented to control iterations if statements handle de such as calculating overtime pay and multiplication subtraction are used for calculations so now print of display messages and scan takes the user input so this is how we will be calculating some of the examples demonstrating the while loop hope you understood about this concept if you have any doubts or any suggessions please post the comments below to this video and if you like this 2:22:39 video please do support me by subscribing to my channel thank you hi guys this is Leela welcome to my channel Lea webd in this video we will learn about the for Loop in the C programming so it is one of the core looping structures in the programming and explores various ways how it can be used we'll try to see so now let's try to have a detail breakdown about this one so now here let's try to why looping so why we need the looping in the programming I already discussed about this one looping allows repetive execution of instructions in a program for instance Computing simple interest for multiple inputs or printing a sequence of numbers can be achieved efficiently using Loops so there are different types of Loops are there so one is while for and another one is do while so you know about this one do while so now we have learned about this while loop already in our previous video now we are learning about the in this video we'll focus on the fur Loop and its flexibility so what is the 2:23:40 definition of this fur Loop the fur Loop the fur Loop enables consise specification of initialization condition testing and incrementing or decrementing of of an counter in one line so that means the entire initialization condition testing and also incrementing or decrementing in one line it will try to do it so the Syntax for this one is so it will be look like it will look like something like this for initialize semicolon condition semicolon and next one is the increment so these three things will be in one line only and you'll be having body of the loop so here initialization mean sets the loop counter to its starting value condition means test whether the loop should continue executing or not increment means updates the counter after each iteration so I will try to show you one simple example how we can implement this one so already I have a simple example with me so let us move into this one here I will try to copy and paste it so the same thing I will 2:24:40 show you with a simple example here yeah so here we want we have initialized the variable how it works let's try see so now here we have initialize the variable princip Le year and also count we are having a rate of interest and simple interest so here the count starts at one so here we have initialized the count starts at one and the condition is Count less than or equal to three ensures that the loop runs three times and increment count Plus+ so now here it has incremented count plus increments the counter after each iteration so here I will try to show you the execution of this one so the counter is set to example count is equal to 1 so here it has set so so it will test if the condition is less than or equal to three is true means then the loop execute if it is not true means the loop will exit and execution the loop of the body runs here so after the body executes the counter is again updated and it will retest again the condition the condition is reevaluated if it is false means then the loop exists so this is how it will 2:25:41 happen now if I try to execute this one so here you'll be able to see okay 3,00 and 2 sorry N2 and rate of interest is three so you'll be able to see it like this again it will ask you so 1,003 and two four so like this you'll be able to see and again it will ask you so this is how you'll be able to see so it has asked three times why because the fur Loop has executed this one so this is how the loop this is how the fur Loop works so variations of the for Loop so now I will try to show you the variations of the fur Loop so the flexibility of the fur loops so the F for Loop has a lot of flexibility so that is the main thing which you need to understand the flexibility of the for Loop is demonstrated with the different examples right now I show it each variation emphasizes that initialization condition and increment can be adopted to suit your specific requirements so in different ways we can use this for Loop the first one is the standard usage I will try to show you the standard usage 2:26:42 for this one so I will copy it and show you this is a standard usage so now in I I have initialized declared the variable so for I I is equal 1 I less than or equal to 10 I ++ and it will try to print it so here if I try to show you the output for this one in our online C compiler let's try to see it so here so now I is equal 1 I less than or equal to 10 so it is will print the values from 1 to 10 so now here we have it will print the numbers 1 to 10 so braces are optional for single statement in the loop body so if you are having only single means so the braces are optional so you can have it if you want you can have it it's nice to have it or otherwise if you're having single statement means there is no need to have a braces so now here it will execute from 1 to 10 so incrementing inside the loop okay so for example if you don't want to use this i++ means you can remove here and just you can keep a semicolon and at the bottom you can write this i++ now this also works the same so not a problem so here what is happening the counter is incremented inside the loop body not in the first 2:27:42 statement so here the counter is incrementing inside the loop body not in the first statement so initialization outside the loop for example let's say that you don't want to initialize it here so already you got it initialized at the top so then is it's also okay so you need to keep a semicolon here and like this so now if you want you can keep it i++ in the inside or otherwise you can keep it in the outside also so here also you can keep it so now if I try to WR it then also it will work without any problem so here initialization inal one is done before the for Loop only so initialization and incremented outside the loop so for example if you don't want this i++ means so you can have it inside this one also and you you can do this like this also so I less than equal to 10 I ++ like this also you can do it now if you execute this one this also works so both initialization and increment are handle outside the for Loop so semicolons must still be present so you need to understand that note that semicolons must still be present so you cannot remove this semicolon so if you try to remove the semicolon like this means then the issue will come so it will throw you an 2:28:41 error okay so here like this so you need to keep the semicolon so the next one is combined condition and the increment so you can also combine the condition and also the increment for example let's say that you are having an inti okay and here I have initialized to I equal to 0 semicolon and i++ you can also use this like this I now zero will be tested then after wordss I will be printed now this also works without any problem sorry we need to keep the semicolon here now this also works without any problem okay so it has printed up to 11 so if you you remove this one then up to 10 it will print so here i++ performs the post increment comparison I less than 10 happens first and then increment happens after the completion so that is the thing you need to understand you can also use the pre-increment also for this one so if you want you can also use the pre-increment plus plus I less than or equal to 10 so then run this one so then also you'll be able to see the same output you'll be able to run it so here 2:29:42 plus plusi performs a pay increment increment happens first and then after comparison I less than equal 10 happens after so this is these all the different ways how we can use the for Loop so so the summary in the at last in the summary what I want to tell you is flexibility offer you can perform initialization condition checks and increments anywhere even outside the first statement as long as semicolons are correctly placed compactness the F Loop integrates all the required steps of looping in a single line making it consense and also the readable and the last one is variation different styles show how versatile the for Loop can be depending on the situation so this is how you will be able to implement the different ways so I have shown you right how many different ways you can customize the for Loop so you can use the initialization condition checking and also the incrementation or otherwise if you want to do it outside also you can do it you can check only the condition so condition must be checked so you cannot skip the condition in the for Loop so this is how you'll be able 2:30:43 to see so now you can apply the for Loop effectively in different scenarios and in different ways you can so let me know if you have if you want if you have any doubts or anything things in the comments so if you like this video please do support me by subscribing to my channel and if you have any doubts or any suggestions please post the comments below to this video and I will try to give the reply thank [Music] you hi guys this is Leela welcome to my channel Lea webd in this video we will try to learn about the nested loops and also the multiple initialization and also about the do while loop let's try to understand so let's try to understand one by one so first we'll learn about the nested Loops so what is this Nest Loops in the C programming language not only the C programming language in all the programming languages this is the base foundation so this is nested Loops how we can implement it so the definition of this nested Loops is Nest Loops occur when one Loop inner loop is placed inside another loop outer loop this allows us to repeat a set of operations multiple times for each iteration of the outer 2:31:45 loop I will try to show you one simple example for this one so here let's go to into this one and let me paste the code here so here we are having r c and Su and I am looping over for Loop and inside the for loop I looping over the outer loop and also the inner loop and here I am printing the value so how it works this one see the outer loop for R is equal to 1 R less than or equal to 3 and r++ so it will run three times why because R less than or equal to three means so this outer for Loop will run three times 1 2 three then it will stop so now when R is equal for each iteration of the outer loop so that means when R is equal to 1 then it will go to the inner loop for c equal 1 C less than equal to C++ it will run twice and takes value 1 and 2 okay R will be always one and it will take the values 1 and two so this program calculates the program calculat sum is equal r+ C for each combination of RN C printing the result so here what 2:32:48 will happen so when R is equal to 1 the loop will open uh loop will run twice that means r r is equal to 1 c 1 and two and it will print here then again it will go to the top and R will become two and here again for the two it will run two times and again R will become three and again it will run two times so like this the code will execute now if you try to run this code so here you'll be able to understand very easily so first one outl R is equal to 1 C isal to 1 and sum is equal to 2 so when R is equal to 1 again two three two times it needs to repeat right so here in the C and again C is equal to 2 so Su is equal 3 now R becomes two and again c will repeat two times here and R becomes three c will repeat two times so then at the end the r is also completed outer loop is also completed it will come out of the loop so now for each value r 1 2 3 for each value r 1 and two and three the inner loop Cycles through all the values of c like 1 and two 1 and two one and 2:33:48 two like that the sum is calculat and print printed for the each combination the programs indentation inner loop indented inside the outer loop helps make it easier to understand which Loop is inside which so simplified output with one statement so for example let's say that we can also use a simplified statement instead of calculating the sum separately and then printing it we can simplify The Code by directly calculating the r plus C inside the printf also so just we can direct L use this like this and we can do it now if you try to see here the output then also we can able to see the same output so just we have say set the simplified output with one statement only so types of nested Loops so you can Nest different types of loop such as for Loop inside a while loop or a while loop inside a for Loop so like this but the nesting principles and all those things Remains the Same so that is what I want to tell you about the nested looping structure so hope you understand about 2:34:49 this Ned looping thing let's move on to the next one that is nothing but multiple initializations in the for Loop so can we do the multiple initializations in the for Loop so now here we can do that one also multiple initialization in the for Loop up to now we have seen only one initialization is there either I is equal to 1 or C is equal to 1 like that so can we do multiple initialization in the for Loop you can initialize multiple variables in the for Loop using commas similarly you can update multiple variables in the increment section Al of the for Loop so I will try to show you the simple example for this one so here you will be able to see and I will print it here yeah for I is equal 1 J isal 2 J less than or equal to 10 J ++ so here we have initialized two here I is initialized to one and J is initialized to do the loop will run as long as J is less than or equal to 10 J is less than or equal to 10 and we are incrementing the G so multiple conditions in the for Loop so now can we 2:35:50 able to do the multiple conditions in the for Loop yes we can add the multiple conditions in the for Loop also you can also include multiple conditions in the test expression connecting with the logical operators like and and R so by using these two logical operators we can we can use the multiple Expressions so now if I try to show you the example for this one so for I is equal 1 J is equal 2 J less than equal to 10 % % I less than equal 15 so when these both become true then only it will execute so here you'll be able to see J ++ and also I equal to I + 2 I + is equal to 2 you can do it or otherwise IAL I + 2 so now here this Loops checks that J is less than or equal to 10 and I is less than or equal to 15 also J is incremented by 1 while I is incremented by two on each iteration so like this you can also implement the what I mean to say multiple initial ations or 2:36:50 multiple conditions or multiple incrementation in the for Loop also we can do so we will uh we will do these problems for this one so simple programs I'll tell you in the next video just I'm explaining you the concept in this so the last one which I want to explain you in this video is the Dual Loop so can we so what is this dowi Loop so definition of this do Loop let's try to understand the dowi loop is similar to a while loop but the key difference is that the condition is checked after executing the Loop body not before that is the thing so that means the condition is checked after executing so that means at least one time the loop body will be executed so that is the thing the Syntax for this one is so here you need to understand syntax little bit careful so do the loop body will be there then afterwards it will check the while condition the body of the do while loop will always execute at least once so that is the main main thing you need to understand even if the condition is false the first time so even if the condition is false at the first time also the body of the 2:37:51 condition will be executed at least once the difference between the while and the Dell so you need to understand about the difference between the while and the D so here I will paste it the difference between while and D while loop means the condition is checked before the loop body is executed so that means first the condition is checked then only the loop body executed if the condition is false at the beginning means the loop will never run the DU Loop the condition is checked after the loop body has been executed even if the condition is false initially the loop will run at least once so this is the difference between while and the do so I will try to show you a simple example about the do while loop so that you can able to understand it very easily and here I am having a do and I printing if credit is yours pleasure is mine something like that and here I'm using while four is less than one okay so four is less than one is it four less than one so never four is always greater than one so that means this condition is false but still this print up will be executed once so if you try to see here 2:38:53 so you'll be able to see credit credit is yours pleasure is mine so here the condition for four less than one is always false but the statement print of you are able to see right will be executed once before the condition is checked so this is what about the do Loop brief introduction about the do Loop so in summary what I want to tell you is by the end of this video so you need to able to understand the by end of this video a loop inside another loop commonly used to handle task that involve multi-dimensions or the repetitive actions n loops and multiple initializations you can initialize and update multiple variables in a for Loop in one statement and the last one is the Dual Loop execute at least once as the condition is checked after the loop body so this is all these features help me make loops more flexible and Powerful allowing you to handle more complex repe to task efficiently in your programs so hope you understood about this for Loop and also the duway loop if you have any doubts or any suggestions please post the comments below to this video and if you like this video please do support me 2:39:54 by subscribing to my channel thank you hi guys this is Leela welcome to my channel Leela web in this video we will try to learn about the two statements in the C programming that is break and continue so what what is the diff what is the use of these two statements in C language let's try to see not only the C language you'll try to use it in PHP or C or JavaScript anywhere we will use this break and continue let's try to see about this first the break statement we'll try to see about the brake statement what is this meaning of this brake statement so if you try to see here the brake statement the brake statement allows you to exit a loop immediately without waiting for the Loop's condition to become false so that means whenever you want to come out of the loop immediately without waiting for the loop condition means then we'll be use this break statement this is useful when you have achieved the purpose of the loop early or encountered a situation where continuing the loop is necessary so in this scenario we will use so where the purpose of the loop uh we have achieved 2:40:54 the purpose of the loop early or anded situation where the continuing of the loop is unnecessary so key points for this break statement is so you where we need to use this one so usage the brake statement is commonly used with conditional statements like if inside Loops so where will you normally use this brake statement is normally with using the if condition so whenever you use the if condition in that place we'll use The Brak statement so comes with a combination of with if and break when a break is encountered the control jumps to the first statement after the loop so whatever the statement is there after the loop the the break uh the state the control will jump to there so I will try to show you one simple example so here I will try to do it so this is the thing a prime number is divisible only by one and itself we know this one so the definition of the prime number is it is divisible by only one and itself to check if a prime number is prime try dividing it by all numbers from two up to one less than number itself not minus one so for example if you're having five means so you'll divide it by 2:41:56 2 3 4 like that so then if any division results in the remainder of zero then the number is not prime otherwise the number is prime so this is simple example so let's try to achieve this one so how we can achieve this one so I already have the code with me so I will try to show you this one in our uh here in this so hope you understood about this one so here I will try to paste it enter code so here fine so we are having having an integer number and I I means here the counting and also number means which whatever the number you are trying to give it in the SC in the control so here we are trying to give ENT number so we are storing it in the number variable so here we are taking the loop with i i is equal to 2 so I less than or equal to num minus one so here we are trying to check num mod is equal equal Z so that means if it the remainder if the remainder is z so that means if it is equal to zero means then we know that it is not a prime number so here directly we are printing it is not a prime number break okay exit the loop if not PR and we are trying to do I ++ so if I is 2:42:57 equal equal to num so num means I equal equal to num means so whenever this I value is equal to the number means then we know that it is a prime number that's it so now if you try to see the output for this one so here it will ask you so 23 if I try to print it so it will tell it is a prime number or otherwise if I try to do 24 then you'll be able to see not a prime number so why is the if op after the loop is necessary so why is the if after the loop is necessary here the control could exit the while loop in two ways case one the number is not a prime and break exits the loop so number is not a prime number and break exits the loop so case two so the loop ends because I becomes equal to number this means no number from two to number minus oneid so it is prime so this in this two case so break inside the Ned Loops so now we's try to see another scenario break inside the Nal Loops so now what is this break inside the Nal Loop so if you are having an Nal Loops means can we use the break inside the Nal Loop so which one will exit so whether all the 2:43:58 loop will exit or not the brake statement only exits the loop where it is placed so if you have an ex Loop means brake will exit the innermost Loop not the outer one so that means only one while loop or one for Loop only will be break so now here if I try to show you some example for this one so here I'm having one simple example I will try to show you here yeah in I is equal to 1 J is equal 1 so let's say that so if while I ++ is less than equal 100 and while j++ is less than equal 100 so here first the condition will be checked then only the increment will happen so now if J is equal equal 150 means break so exit the inner loop so that means only this while loop only will be exit so this top by Loop will be working as usual so now if you try to see here so it will print all the values but it will exit automatically okay so this is this is how we will be able to check it now here if you if you try to so here it will go on print the output for this one so up to when up to 150 it will try to do it 2:45:00 here up to 200 so now here what I was trying to tell you is in this program When J is break exits the inner loop so here this only this will only will be exited outer loop continues execution so what what happens this outer loop will be continuing the execution will be continuing so this is what I want to explain you so here so what I would be trying to tell you is the next one is the continue statement so what is this continue statement so now you hope you understood about this continue statement so now we'll try to understand about the break statement sorry we understood about the break statement so now we'll try to understand about the continue statement so here let's go into this one yeah the continu statements SKS the remaining statements in the current iteration of a loop and moves to the next iteration so this is the main thing so this is the main thing in the continue statement so where we will be using using this one so often us it with the if block to skip cases in a loop so for while and do 2:46:00 while Loops control jumps to the loop condition for the for Loop control jumps to the increment step so that is the main difference between while and the two now here I will try to show you a simple example for this one also so I have a code with me already I'll try to show you example so here in I comma J so for I is equal 1 I less than = to 2 I ++ for J equal 1 J less thanal j++ if I equal J means continue continue means instead of printing it here it will go back to the loop here so now if I try to show you the output for this one see 1 2 2 1 so now here the matching will not be printed skip when I equals to J so that is the thing when I is equal means continue skips the printf moving to the next iteration of the inner loop so that is the main thing now this is all about the continue statement and also the break statement so I want to explain you about one of the one another another concept that is nothing but the do do do the odd loop I want to explain you so the do by Loop 2:47:01 ensures that the code block execute at least once I told you right even if the condition is false initially this is because the condition is checked after executing the loop body for example let's say that I will be having one simple scenario so here oh sorry so here I am taking one character so the loop asks the user for a number so it will ask ask for a number calculates it square and display it so square of do you want another number and it will try to do it so now if the user inputs y means then the loop repeats otherwise it terminates if the loop is Val means then it will continue or enter a number so 23 means so here it will write so square of a the square of 23 is 5 do you want to execute another number yes okay if I try to Center so okay fine so it got stuck so let's let's close it so now here okay we are clearing the buffer right so that's why so now here after entering a number press uh so here we 2:48:02 have used F flush of studing right so what is the use of this F FL of studying why we have used it is so here when you when you are when we are asking for a number here okay I pressed for and press enter right so now enter is a keyboard input so it is waiting uh will it will it is trying to take the key uh the enter also as a key it will keep the enter also in the buffer so now what I was trying to do if I if I press y it will go back again to this one and it will try to scan the number so this time it will take the enter as the keyboard input so that's why what I was trying to do it so here I am trying to do frustra in so that is the thing so here here you want another number means so s means so I am clearing out the buffer and then I taking the another number so that is what I want to tell you so here so now after entering a number pressing enter leaves a new L character in the input buffer so that is the when scan of percentage person read input it picks up this leftover slash and using flush of studing clears the input buffer ensuring 2:49:02 SCF reads the correct input so that is the main thing so that's it all about this D and all those things so hope you underst understand about this one so the summary of this one is so what we have learned about this one in this video so let's try to recap so that you can have an clear idea about this one so break means means exits the loop entirely skipping and skipping the remaining iterations continue means skips the rest of the current iteration and moves to the next do well means guaranties at least one execution of the loop body nested Loops means breake affects only the innermost Loop where it is placed for f FL of St mean standard input this one is standard input so here the standard input means keyboard so clears unwanted leftover input so this is all the concepts which we have discussed in this video hope you understood about this concept so if you have any doubts or any suggestions please post the comments below to this video and if you like this video please do support me by subscribing to my channel thank you hi guys this is Leela welcome to my channel Leela webd in this video we will learn about the switch statement in the C programming language 2:50:01 the switch statement is a control structure in the C that simplifies making decisions when there are multiple Alternatives so normally we will be using if if you are having multiple conditions or multiple alternatives are there means then we will be using the switch statements just like if Els only so we'll try to see the difference between the fs and switch statement also unlike a series of f statements which C which become cumbersome a switch provides a cleaner and more organized way to Branch the execution of a program based on the value of an expression so this is the brief overview of the switch statement in the C so the typical syntax of the switch statement will look like this one so I will try to show you here so this is hope so switch you will be having the expression so expression means the condition or something like that I will try to tell you this expression thing and you'll be having the different cases so here the value and the constant and default here so I will try to show you this one so 2:51:01 the first one is the expression this is evaluated first and should result in an integer or a character value so that means this one should should return an integer or a character value So based on that integer value this case will be executed here the next one is the case labels constant one like each case is followed by a constant value if the switch expression matches the case means the corresponding block of the code will be executed so for example here the expression returns one means so here you're having a case one means so these statements will be executed the last one is the default case so what is this default this is optional if none of the case labels matches means then the code in the default block runs and you are able to see the break also here the break statement ends the execution of the current case prevents the execution from falling through to the subsequent cases so that is the break statement we will be using so execution flow of a switch so how will be the execution flow of switch first first 2:52:03 what it will write is this expression is evaluated first the result is compared against the values in the case labels so here the value will be evaluated when a match is found then that case will be executed if there is is no break means the execution continues to the next case and the default value if present so for example let's say that if Case constant one is matched means if there is no break means then automatically the case all the cases will be executed if no cases matches means then the default block executes if provided so for example I will try to show you a simple use case scenario with no break situation without a break so here I will try to copy some code and I will show you here so this is our online compiler and here in this one what I will try to do it is let's assume that here we are having an INT I is equal to 2 so here I am taking the switch of I so now this evaluates to the integer value and here I'm taking the case one case 2 2:53:06 case 3 and also the default so here I am Pro I am printing the value I am in case one and I am in case two I am in case three and the last one is the default value now if you try to observe here so what will be the output so here the output will if you try to observe carefully so here first what it will try to the switch starts evaluating the cases so when I is equal to 2 so here the I is equal to 2 then it matches the case one is it matching no it is not matching so I is equal to two right case 2 so here I is equal to 2 this is the case matching so when I is equal two matches the case two execution begins from here so that is the reason k i Am in case 2 has been printed since there is no break in the case two it falls through and executes the case three also so here it will not check automatically one time it has checked the case right it has been passed so automatically all the statements below the below from the matching it will be executed so and executes the case three and the default one case as well so here 2:54:07 it will be executed all things so that is the thing with no break case so for example the same thing if you try to write it with a break means then here the code will be in such a way that so I will copy and paste it here yeah so here the same situation in I is equal to 2 then here what it will happen so once I equal 2 matches the case2 it executes it executes the code in that case2 block and the break statements so here we have provided the break statement the break statement which is provided prevents the execution from continuing to the subsequent cases or or the default one so that is the thing so additional tips so if I try to execute this code so if you try to execute this word so here you'll be able to say I am in case 2 only this one case will be executed so automatically the break is there so that's why it has been not exing additional tips and tricks so order of cases the order of case labels doesn't matter so for example case three can come before case one also for example let's say that here also you can 2:55:09 copy this one and you can paste it at the top also so the here the order doesn't have any uh anything no braces needed unlike if El statements you don't need braces so here if you are having multiple statements means there is no need to keep the braces to group multiple statements in the case and mandatory case matching every statement in a switch must belong to some case or default so every switch statement so everything should have a case so now no default if there is no default and no case match means the control will simply exits the switch case so that is one thing multiple cases for the same code so for example let's say that you you can group the cases together if they share the same logic so if if something like if it is sharing the same logic means then you can group the code so here you can see something like example I will try to show you so like this so you are having case a and case b means so you here you can write the casa like this and casea like this and you can print a is an Apple so like this also you can use it so the multiple 2:56:10 cases also you can use it so switch switch case versus the if use switch when decisions are based on discrete const values so whenever the decisions are in the constant values means then we can use the switch use if when conditions involve ranges are more complex logic so if you are having more complex logic means then we'll be using the if if conditional statement so expressions in switch so for example let's say that so this one is valid so here I will try to show you some invalid and valid switch cases so that you can able to understand here so switch of I + J into K so this is a valid one but but case I less than or equal to 20 only constants or constant expressions are allowed in cases so here you should not write something like case I less than equal to only the constants or constant expression should be used n switch while technically allowed so this n switch also technically allowed nesting switch statements is rare and can reduce the readability so nesting of switch statement should not be used but those 2:57:10 are technically allowed so some common us uses of switch so where we will be using the switch statements and all those things means so what can I explain you for this one is common use cases is menu we will be using in the menu driven programs handling input based on specific Keys like a b c like these things simplifying code with multiple discrete options so this this one in C language we also have a goto statement also so the goto statement provides an unstructured jump to another part of the program making code hard to fall and debug using structure control statements like switch if Els or Loops is recommended to maintain ratability and structure so I will try to explain you about this goto also so let I am trying to explain you so in conclusion what I want to tell you is the switch statement is a powerful and a structured alternative to a series of if statements when dealing with multiple discrete choices its usage can lead to cleaner and more readable code especially when combined with the break to avoid 2:58:11 unintentional fall throughs so this is all about the brief introduction of the switch statement hope you understood about this switch switch thing so so we'll try to do some programming examples also so just I'm explaining you about the switch statement so if you have any doubts or any suggestions please post the comments below to this video and if you like this video please do support me by subscribing to my channel thank you hi guys this is Leela welcome to my channel Leela in this video we will try to learn about the little bit explanation of this switch statement and also the go-to statement we'll try to learn so you know about the switch statement in the C language or in any programming language so if you are coming so you may be having a clear understanding about the switch statement so let's try to have a clear understanding about this one a switch statement is a control structure that allows multiple Paths of execution based on the value of an expression this is the definition of a switch statement but it has some limitations let us try to explore that limitations what are those in the switch statement so that is the thing so first 2:59:11 one is cannot test the float Expressions so first limitation is can not touch the float expression C language a switch can only work with integral or enumeration types like integer or character etc for example you cannot use a floating Point expression float or double in a switch so there is one limitation which in which switch you can able to see and also no variable expression in the switch statement so that means if you want to write any expressions like for example let's say that the values in the case statement ments must be constant for example case a + 3 a + 3 this is not a valid one so these type of things like Expressions so when you are trying to do some calculations or anything is not allow and also no duplicate case values are also allowed so for example if you are if you want to write multiple cases with the same case valuable means then it is not allowed so here if you try to see case values in a switch must be unique 3:00:12 for example this following is unique uh this following is invalid I will try to show you switch of a case three and case 1+ 2 this is also three causing a conflict so like this also it's not valid so that is thing so now you may be having a doubt that why we need to use the switch instead of if else so that is also one important thing right so one is performance Advantage for this one so let's try to understand about this one so why to use the switch instead of if else first is performance Advantage so what is this one the compiler creates a jump table for a switch during compilation this jump table allows the program to directly jump to the correct case during execution in contrast IFL statements evaluate conditions sequentially at run time making them slower especially for complex conditions so this is the performance advantage of this jump so compiler it will create a jump table for a switch C for switch so that the using 3:01:14 the jump table the program directly jumps to the correct case in contast ifs means it will try to execute the conditions sequentially making them slower especially for complex conditions so this is all about the limitations of the switch statement and also why we need to use the switch instead of the IFL statement so now in the second one what I want to explain you is about the goto statement in the C language especially in the C language what is this goto statement goto statement allows for an unconditional jump to a labeled part of the code within the same function so in the same function function so if you want to move to an particular line so you will be using this go to so here the Syntax for this one is so something like this it will be go to label name so here you will be giving the label name and directly you'll be using this label name colum canid can be any identifier and you can write this code so automatically it will jump to this one so I will try to show you some example for this one so that you can able to understand uh this so here I will try to open here this one so 3:02:16 for example let's say that you will be having uh int int goal okay int goals is equal to three let's assume okay move this one if goals less than or equal to 5 means then it should go to okay go to SOS let's assume or else so I will be exiting the program exit of one okay now here and now here if you try to observe carefully so one second and now here exit so here we need to add the label so SOS so here SOS column and here print of 3:03:18 here go to statement executed so this is the line which I would be trying to write so now if you try to execute so here go to SOS is there right automatically it will jump to the here into this one so exit of one so okay fine so here it is asking exit so I will try to return it directly okay now here I will try to return the zero so that it will not be executed now if I try to execute run so automatically the go to statement executed is came so now so this is how the go to means directly it will jump back to Here For example let's say that here I will try to write the print of executed code means then and here also it will try to WR printf condition done something like this if I try to write it and if I execute here so 3:04:20 it will execute directly go to statement executed so this print of condition and this executed code these all are not exec directly it will jump to the SOS things so this is all about the now what I mean to say about the go to statement so if the condition goals less than or equal to five is true means the program skips the else block and jumps to the SOS label if the condition is fall means then the program executes the else block and it will it will it will terminate using the return return statement so it will stop executing that one so when to use the goto statement so that is one thing which you need to use it so should we use it to use should we need to use the goto statement means so we should avoid using the go-to go-to is often considered bad practice because it can make code harder to read understand and also deug most task achievable with goto can be Rewritten more elegantly using Loops or other control structures like ifls or while so exception uh exception n Loops so now I will try to show you in the uh this code I will try to give you 3:05:20 a simple code so where go to is used to break out of multiple Nal Loops this can be tricky to implement without go to so now I will try to show you one simple example for this one so here let's go into this one I will remove this entire code okay and here I'll be having two variables like int i j comma V K and here I'll will be having one for loop I is equal to Z or I equal to 1 I less than or equal to 3 and I ++ so this is one Loop and inside this one we'll be having another loop J is equal to 1 J less than or equal to 3 and J ++ you'll be having another one and here also I'll be having for K is equal to 1 K less than or equal to 3 k++ so these are the manest loops we are having it and inside this one I will write something like if I is equal to isal to 3 sorry I is equal to 3 m% m% J is equal 3 % % k equal to 3 so if I J K is equal 3:06:22 equal to 3 means then I will write go to out so I am going out of this n Loops so here and if else if else is there means then if then I will try to print F print F percentage D percentage D percentage D and also last one is slash n so that in the next Loop you will be having comma I J comma a I will be printing this I comma J comma a so if it is both are equal means then it needs to go out so here I will write in this out out print F out of the loop out of the loop at last something like this slash in okay now if you try to execute this one so you will be able to see the execution of this so now we have able to uh come out of the loop using the go to statement but we can able to implement 3:07:23 the same functionality without go to also so for example let's say that here uh what I can do I can have an uh something like exit Loops okay exit Loops is equal to Zer so here this is the flag to indicate that when to exit all the loops so here if you are having like this means so you can have in some such way that exit Loops is equal to one and here I can use the break statement that's it and uh sorry and here if you try to see that's it so now here uh you can come out of this one else statement and here you can use uh like this if exit Loops is there you can uh break it here also so each Loop I am trying to break it if exit Loops is there you can break this one also and at 3:08:25 last what I would be trying to print it is so I can remove this label print out of the loop at L so now if I try to see the output the same output you'll be able to get it so here you will be having the int let's try to make it as an INT and here if I try to run it the same output we can able to T it but this time I have did it through the without goto statement so this approach avoids the use of go to statement and it is more readable so key takeaways use switch per for performance when handling discrete constant cases avoid go to except in rare cases such as breaking out of the deeply nested Loops modern programming practices favor structure and readable code using loops and control statements instead of goto so this is all about the switch statement and also the goto statements hope you understood about this concept so if you have any doubts or any sessions please post the comments below to this video and if you like this video please do support me by subscribing to my channel thank you hi guys this is Leela welcome to my channel Leela webdo so in our previous video we have understood about the concept of the switch statement so in 3:09:27 this video we will have a simple program demo uh demonstrating the switch statement we'll try to see so I will give you I we will be having a three couple of options that is nothing but calculating the factorial of a number or otherwise calculating whether the number is a prime number or not and we will try to calculate with whether it is an odd or even not number so the user will try to select the option so which one you need to calculate So based on the option so we will calculate either it is a factorial or prime number or odd number let's try to see so for this one what I will try to do it is so here in this code so hope you able to see this one so I will remove this entire code so we will be having the choice choice means nothing but the whatever the user needs to select whether he wants to calculate the factorial or prime number or odd or even or otherwise he want to exit it and we'll have a number okay I will have an i and also the factorial so let's try to assume it like this so now I am 3:10:27 looping over the infinite Loop for this one so why because so I will be going on asking the questions for this one so here so what I will try to do so here we will be displaying the menu options like printf sln menu sln so this is the first option so menu we will be showing the menu for the user so this is the menu we'll be showing and I will be asking the first one first option printf sorry printf so one so factorial of a number factorial factorial of a number so this is the first option which the user has to select that's it so second one is the printf and here I will be asking to uh what I trying to say it is or 3:11:29 otherwise we can we can remove this loop I will try to tell you how we can why you be using this so print of two next one is check if number is prime check if number is prime so this is the second option and the third option is print f check if check if number is odd or even so this is the third option and the fourth option is fourth option print of fourth option is exit Okay so that is the thing ex exit so the last option is print of not not option so just you ask the user enter your choice that's it so these are the options which We'll be asking so now so when the user selects the option so we will uh scan the option scan 3:12:32 of percentage D Choice M percent Choice that's it so this is the thing now if I try to run it here so you'll be able to see the menu factorial check uh check if a number is prime and here the top third option we need to keep it yeah so check if the number is odd or even or otherwise enter your choice so here if whatever the choice you will try to check it two sorry if it is two means then you'll select the two and press enter code execution successful but here two means we need to calculate check if a number is prime or not so then that means we need to ask the number so now you you you are able to understand this one so now here so when the user enters the choice so something like 1 2 3 and four if you try to check it here so 1 2 3 and four anything if the user selects then what we need to do so according to the option we need to calculate the thing so the first one is factorial second one is number is prime and another one is OD or even so we'll try to take the switch option here so here I'll be having the 3:13:35 switch so I will take the choice whatever the user has entered the choice so for example if the user has entered case one so that means I will be taking the case one so here we will be calculating the case one so here will ask print of enter number to calculate the factorial so we will ask the factorial so if he select the case one means we'll ask the number to calculate the factorial now we will scan the scan the percentage D percentage D and percent num so num also I'm taking it so now what I want to do if num is less than zero then what I will try to do so print F so factorial is not defined for negative number let's try to keep it like this so 3:14:36 just I'm handling the error case so else if it is not there means so that means if it is a positive number means then I need to calculate the factorial so how can I calculate the the factorial so just I can keep fact is equal to 1 so this is the variable which I have indicated it so for I is equal to 1 I less than or equal to [Music] num I ++ I will try to do it and here I can do fact star is equal to I that's it so now here at the end so if the uh for Loop is completed so printf factorial factorial of percentage D is percentage D so here we can use num comma fact that's it finish so we have calculated the factorial now if I try to run this program so you'll be able to see the one factorial it will ask enter number okay three if I try to do it so 3:15:37 factorial of three is six so we are able to calculate the factorial now in the same scenario what we need to do so case one is completed so else part this one is completed now I need to imp the case two case two means what is that case two prime number okay so here we'll ask printf enter number to check if it is prime okay so this is the question I'm asking so here I will be taking that scanf percentage D num that is nothing but ERS num to read the value to store the memory location so now here what I will try to do here the same situation here the same situation what I will try to do is if num if num is less than or equal to 1 means then you can just print print of percentage D is not a prime number 3:16:42 okay prime number if it is less than one means it is not a prime number sln and here you can give num value that's it if else means then we need to calculate the prime value so now here I will Loop over int I will take is prime is equal to 1 so here I'm defining it here assuming the number is prime so we can declare it like this not a problem for I equal to 0 sorry I equal to 2 I less than or equal to num okay num by two we can do num by two also I ++ so if num mod where is I is equal equal to Z then we can keep it as is prime is equal to0 so that's it and we can break this statement so we found it right so we'll 3:17:43 come out of this Loop so then here we will write if is Prime if it is prime means then we can print printf percentage D is the is a prime number okay and here if you want you can give sln and uh you can print the number if it is not a prime number means then else so here you can write percentage D is not a prime number so I can copy this one simply and here I can do is not a prime number that's it so now if I run this one let's try to see so I will check the two it last check prime number or not so I'll try to give three so it is telling three is a prime number so now we are able to calculate the prime number also so the last case which I want to do it is the that is nothing but odd or even so case three case three so here you can write printf 3:18:44 enter enter number to check if it is odd or even odd or even means you people already aware of this one so you people already know about this order even thing so here I can do scanf percentage D and % num so I took the number and here what I would be trying to do it is if num mod 2 if n 2 is equal to equal to Z then I can print up then I I can do the printf printf percentage D is a even number so you people already know if it is divisible by two means it is an even number if it is not divisible by two means then it is an odd number okay so print of percentage D is a odd number that's it sln and here also you can do now so this 3:19:46 is is also finished so case three and here we need to add the break so so for every case we need to add the break I forgetting that to add a break so here this one is completed right we need to add a break here and case two also if it is completed means I need to add a break here okay and case three is also finished I need to add a break here that's it so now this one is completed so I will write complete the case 4 also case 4 means printf exiting the program goodbye something like this we can say Okay exiting the program goodbye and here you can use exit of zero so you can use exit of zero and the last one is a default case so here you can use the default case default case means so here I can use 3:20:48 invalid Choice printf invalid invalid Choice please try again slm that's it so for exit if you are using it means then you need to use uh hash include sorry hash include STD li. H header that's it so fine let's run the program so if you run this program so here print somewhere I have used the print only it seems print print print okay print of print so now if I try to run yeah here if it is asking factorial okay press enter Choice uh three so you'll be able to get a six so code execution successful so but I want to ask multiple questions like this so whenever I press exit then the code should be exited so for this one what you can do it is so the entire thing you can keep it in while one and you can Loop over here the switch case 3:21:49 entire switch case you can Loop over so now if you try to run it so now it will ask you series of questions so here if I try to do it so four if I try so factori of four is 24 enter enter a number to calculate the factorial again it is asking the factorial okay so did I get the break here enter a number to calculate the okay so here here okay fine let's try to rerun it again so it is running okay so it is asking factorial of a number so it is ask enter a number to Cal factorial so if I try to press enter four so factorial of 4 is 24 and again it is asking you that again the options so now what I will try to do here I will uh do second option so I will select the second option so enter a number to check if it is prime if I select five here five is a prime number and it is asking again option so I'll press three so enter a number to check if it is odd or 3:22:51 even means so I will take six so it is say six is even number and if I go to exit so then exiting the program goodbye so then it will exit so this is a simple example demonstrating the while loop switch Loop if Loop if condition and all those things we have seen it so this is how we will be implementing the switch statement in the code so hope you understood about this concept if you have any doubts or any suggestions please post the comments below to this video and if you like this video please do support me by subscribing to my channel thank you hi guys this is Leela welcome to my channel Leela webd in this video we will learn about the new important Concept in the C programming language that is functions so what is a function in the C programming language so let's try to see about the definition of this one so function is a self-contain block of code that performs a specific task so this is the definition of function a function is a self-contained block of code that performs a specific task functions help make programs modular reusable and easier to understand so 3:23:51 functions help make programs modular reusable and easier to understand there are basically two main types of functions in the C programming so one is Library functions these are built-in functions like print of scan of which we have seen in our earlier programs and another one is the user defined functions functions that the programmer creates like message it so these are all user defin functions which we'll be creating in a couple of uh minutes um afterwards we'll try to create it so these are user def messages uh functions which we will be creating by our own and these are all self built-in messages that are available in the library functions so let's try to see the structure of a c program with the function so let's try to I will try to explain you the structure of a c program so the structure of a c program with functions a c program can have one or more functions if there are multiple functions the program always starts execution with the main function so this is commonly we know always the program always starts execution with the main function only other functions are called 3:24:54 invoked from the main so if you want to call other functions means those should be invoked from the main or from other functions so that is the main structure of a c program C program can have one or more functions if they if you are having multiple functions means the program always it starts execution with the main function after executing of the main function then the other functions will be invoked from the main or other functions so let let's try to understand the key components in the function so this one I will try to explain you the key components of main function so first one is the function prototype declaration so before using any function first of all you must declare it so that means you must declare the function example something like void message so this one is the Declaration so here void indicates that the function does not return any value message means the name of the function so this is the main key components of function first one is the Declaration of the message and here first one is the return return type what is the return return type that the function return returns indicates that the function does not return return any 3:25:51 value and you are having the name of a function so I will try to show you the definition of a function so the definition of a function in such a way that you will be having here I will show you so here this is the definition of a function so void message so this one is the definition of a function you'll be having and here in this one you can write print up so function program or whatever the code you want you can do it so this is the definition of a function so Now function call to execute the function you need to call it so now you have mentioned the function so in order to execute this function you need to call it so normally how you will be calling this one is directly like a message so wherever you want it you can call directly like a message like this that's it so when a function is called control is transferred to this function after the function completes its task control returns to the point where it was called so that is the main function called how it will happen so I will try to show you a simple program with one 3:26:52 function so that you'll be able to have a clear understanding about this one so here if you try to see here is a simple function so hash include the header files has been included so here I'm calling I'm declaring the function prototype void message so this is the function prototype which we are trying to use it and here we are having int Main and we are calling the message function and we are printf and we are wring the zero so here the function definition is there so here we have mentioned the function prototype and here the function definition is there so void message and here we are printing it now if you try to run the program for this one okay so you'll be having like this so you'll be able to see the output so I try to explain you the program normally has two functions one is main function and another one is the message function main function is the starting point of the program so which you people already know and the message means it is a user def function so that means the user has created this function the function message is declared at the top so here we have declared at the top void 3:27:53 message and next one is defined later so that is nothing but this is the definition defined and we are calling in the main function using the message like this this is the function call so when message is called the control transfer to it after printing the statement it statement so whatever the message is whatever the statement is there in the message after printing a statement the control returns to the main and continues the execution from here so that's why you you will be able to see the smile has been outputed first and then afterwards the printf has been outputed so this thing so now example two I want to explain you about the another example so how so here we are having only single function right if you are having a multiple functions how you will try to call it let's try to see so I have a c code with me so let's try to paste it here so here we are having a simple function so I will try to explain you this one this program defines and calls three user defin functions Italy Brazil and Argentina so here we are having the three functions multiple functions we are having Italy Brazil and Argentina and these are all the function prototypes so just we are mentioning 3:28:56 this at the top okay declaring at the top now definition the function definitions is at the bottom so void it void means the function does not return anything and we are printing if and we are Printing and we are printing so here Italy means I am in Italy Brazil means I am in Brazil so respective functions definitions we have implemented it here now if you try to see how we have called this one control starts in the main function so normally when you try to execute the C program so run means so normally the control starts in the main program so that is the reason you will be able to see the first output is I am in the main so that means so this line has been executed then afterwards the function call has been called it so here the control will transfer it to here and it will try to print the I am in Italy so after printing I am in Italy here you'll be able to see the output then again the control transfers to where it has been went so here it will start again Brazil so here it will print the Brazil and again the control will transfer to the main function so next the line it needs to be executed is the Argentina so it has printed the Argentina at the last and now again it 3:29:55 has return returned the control is transferred to the main function so here return return zero so it will execute the function uh sorry the execution will be completed so after each time function completes control returns to the main function so that is the main thing which you need to understand it clearly so that this is all about the function declar function definition function declaration function definition and also the function calling so how we will be doing so this is the basic functionality how we will be doing so now you need to understand the important points that needs to be considered uh while we are using the functions so I will try to explain you about this one for example let's say that I will give you one by one points so I have the points with me first one is the execution order so functions are executed in the order they are called so that means how the uh program has been called so here it has been called Italy Brazil like this right so functions will be executed how they are called not the order they are defined so they Define not the order they are defined so how 3:30:57 they are called so those those type this type only it will be executed main function every C program must have exactly one main function so this is main thing you need to understand main is the starting point of the execution so you should have only in every C program only one main function and it is the starting point of the execution calling functions functions can can call other functions even main can call itself through this is rare though this is a rare even main can call itself multiple calls a function can be called multiple times from different places in the program so this one also you can do it function cannot be Define another restriction is function cannot be defined inside other functions so for example if you want to define the function means function cannot be defined in another function for example let's say that here you will be having like this so this one is incorrect so you are having an into main function and inside this main function you are trying to declare the function means so this one is incorrect so this one is also you need to understand so now so these are the important points that you 3:31:58 need to consider so there are basically uh two types of function I already told you right now you will be able to understand about the two types of function one is the library function those are predefined functions like printf and scanf these are stored in the libraries and provided by the compiler and the next one is the user def functions those are created by the programmer just now we have seen it right message Italy and all those things so these are the two different types of functions which we have learned so now why we use these functions so you need to get an idea that why we need to use this function first one is the modularity so what is this modularity it breaks the program into smaller and manageable parts so the code instead of writing line by line very big lines so we can divide the code into different different parts in in such a functions and another one is the reusability functions can be reused multiple times and readability makes the code easier to read and maintain so these are the use of the functions in the C programming language in the summary of this video so 3:32:58 what we have learned so you need to understand so you need to understand functions are the basic building blocks of the C program so that is one thing every program must have a main function other functions can be created and called as needed functions make programs easier to write debug and maintain so this is all about the pure definition of the functions how we can declare it how we can Define and how we can call it hope you understood about this concept if you have any doubts or any suggestions please post the comments below to this video and if you like this video please do support me by subscribing to my channel thank you hi guys this is Leela welcome to my channel Leela webdo in this video we will try to learn about the specifically how the basic concepts of functions in the C programming especially in the C program will try to learn it and also how the functions communicate with each other using an arguments also called as parameters also and return values so let's try to understand with examples and also the each key Point let's try to learn so first one is why we use the 3:34:01 functions for example let's say that why we use the functions so why we use the functions just because of the code reusability functions help avoid redundant code if you need to perform the same task multiple times means like the calculating the area of a triangle you can create a function do it once and call it whenever it is needed so for this because of this reason for example let's say that suppose you are having a uh example I try to show you suppose you need to calculate the area of a different triangles in different parts of your program instead of repeating the formula every time you can write a function to calculate the area and reuse it for example let's say that I have a sample code with me 3:34:53 hi guys this is Leela welcome to my channel Leela webdo in this video we will try to see the basic concepts of the functions in the programming especially in the C language so this tic this video is all about the C language right so you'll see about in the C language the basic concepts in the fun functions and also how the functions communicate with each other using the arguments which we also call it as in parameters also sometimes and the written values so let's try to understand each one with examples and explanations of each point so first of all you need to understand why we use the functions so what is the use of these functions first one is the code reusability so functions help avoid redundant code if you need to perform the same task multiple times like calculating the area of a triangle you can create a function do it once and call it whenever it is needed so this one is the basic function basic functions why we use this one so for example let's say that so the triangle example only I will try to tell you for 3:35:54 example let's assume that suppose you need to calculate the area of it different triangles in different parts of your program instead of repeating the formula every time you can write a function to calculate the area and reuse it the example code it will be in such a way that so I have the code with me let us go into our code here I will copy this code and I will try to show you so instead of here I will copy this entire thing here and I will paste it okay sorry I will paste it here yeah so here you will be having the calculate area so this one is our calculate area into calculate area into base and in height I'm taking it and we are wring the we are calculating the area of a triangle calculating base into height by two so in the main program so the first one area one calculate area of 10A 20 calls the function to calculate the area area 2 and we are printing out the areas here so for example if you want to know about this code means so what you can do 3:36:55 here let's try to make it down let's see whether we can able to get the output or not hash [Music] include studio. H let's try to run the program so that we can able to see it or not implicit Declaration of main okay into main it is there so calculate [Music] area so here in this output so we need to use the Declaration right so now here we are having a calculate area in and in and it is taking the calculate area into base and in height and this is the main program so now we are able to see so breaking the program into a smaller isolated task makes the program easier to design test and understand for example let's say that if you are designing a program with multiple steps let's say that if you are designing a program with multiple steps like calculating Printing and storing data 3:37:56 each of these tasks can be handled by a separate function so let's try to show you this separate function code I will write it here only so here you can have a void calculate void print result void store data and in the int main you can say calculate print result store data and so like this you can use it so now the next one what I want to discuss you is the communication between the two functions so how the communication will happen between the functions so functions communicate with each other through arguments values passed to functions and written values values sent back to the calling function so let's look at how this works in the given example so I will try to show you in a given example here I will I have a I have an example with me so let's say that we are having a calculate sum inex into Y into Z so here these are the three arguments which you taking so here we are having int ABC sum okay int ABC sum and we are printing the argu printing the numbers so printer any three numbers and we are taking the values and we are calling the function 3:38:58 and we are printing it now if I try to run this program so here it will ask you some series questions like 2 3 4 and I press enter sum is nine so this is how we'll be calculating the sum so now here if you try to understand the actual arguments of the variables are values passed to the function in this case a b and c in main so here these are the actual variables the formal arguments are the parameters declared in the function definition that is nothing but X Y and Z in the calm these arguments need to match in type order and also the number that's the main thing function prototype the Prototype which you are able to see this this is the function prototype the Prototype tells the compiler about the functions written type and the types of its parameter the fun function prototype is defined before the function is called so this one is defined before the function is called so this one it will indicate the compiler so what is the written type of the function and what are the arguments and type of functions it indicates that calculate sum here takes 3:40:00 three in parameters and returns an INT that is the main thing so here you'll be able to see a return statement return D the return statement sends a value back to the calling function in this case the sum of the numbers is written to the main without the written statement the function wouldn't provide any meaningful result so that is one thing control flow once calculate sum completes its tasks it it returns control back to Main and the sum is stored in the variable sum so it Returns the control back and the sum is stored in the sum so now if you try to see the output so this output will be like this further explanation of the return and return values are so now multiple return statements a function can have multiple return statements based on conditions the value written depends on the condition evaluated for example let's say that here you are having some code let's say that this is the code into function of in 10 if n is less than or equal to 10 3:41:01 so we are wring n into n or else we are wrting n into n into n so Returns the square if n is less than 10 Returns the cube if n is greater than 10 so here the parenthesis after the written statements are optional both of these are valid so here you can have something like code like this also okay so like this return a you can have it or otherwise with parenthesis also you can do it a function can only return return one value at a time you can't return multiple values in a single return return statement however you can use pointers or structures to return multiple values so I will try to explain you about the structures concept when we are trying to do so it can only return return one value at a time so it can't return returns multiple values so here this this return a comma B is invalid okay so if you want to return multiple values means so here we can use a struct concept like struct result Ina to B and we can create that result and we can send it so this one is valid we'll try to learn about this one when we are learning about the struct structs the next one is the passing 3:42:03 argument by value so this concept also you need to understand when we pass arguments to a function in C they are passed by value this means that the actual argument in the calling function Main remains unaffected by changes made to the formal argument in the called function so if I I will try to show you a simple example for this one so that you people can able to understand it clearly so when we learning about the pointers you need to understand here so here you'll be able to see that we are having a function B okay here a in main so here uh we are having a main function okay let's try to ex this one so here we are having a main function into a equal to 30 and we are having function a so we are having print of a we are printing it so that means here we are having a is value 30 we are passing it to the function and it is receiving as an argument to the B we are we are passing it as a b so now here B is equal to 60 so we are printing if the B value so now here we are 3:43:05 manipulating the B value means changes the value of B locally but doesn't affect a in main so now here we are passing to a function means that the a value doesn't change if I try to show you here the B value inside this one it is printed as 60 whereas the a value doesn't have been changed so that means it is passed as a value not a posi as reference so that is one thing you need to here a in main remains 30 because only a copy of a is positive function not the verigin L in summary what I want to say is functions help in code so here in summary I will try to explain you the concepts so in summary functions help in code reuse and modular design they break down complex tasks into smaller manageable pieces functions communicate with each other through arguments input values and written values pass by value means changes to function parameters don't affect the actual arguments in the colum function return return can only send back one value and the return return statement can be used multiple 3:44:06 times in a function depending on the logic so this is all about the functions how the communication happens hope you understood about this concept if you have any doubts or any sus please post the comments below to this video and if you like this video please do support me by subscribing to my channel thank you hi guys this is lilan welcome to my channel Lea webdo in this video we will try to learn about the order of passing arguments and also about the library functions how we'll be using and mismatched arguments in the print and the written type of the functions we'll try to see about this one now let's try to understand about the order of passing the arguments in the function so we need to understand about this one so key point is the order in which the arguments are passed to a function is compiler dependent not strictly defined by the language so that is the main thing so for example let's say that here you'll be able to see a simple code I want to show you so int AAL 1 is there and I'm using a print of percentage D percentage D percentage D and I'm passing a Plus+ a and also the 3:45:08 A++ here a is modified within the argument list the values passed to the printf depend on the order of evolution by the compiler common misunderstanding is one might think that it will print a22 will be printed actual result will be 3 3 and 1 so how it is let's try to see so normally it will happen right to left evaluation as chosen by the compiler so first one will be A++ evaluates to one then increments a to 2 so plus plus a increments a to 3 and evaluates to three the value of a is now three so the last arguments is three so that means it will be happening from right to left so first a value will be 1 it will print one and then increments to two then it will increment to three and then it will print three and a normally it is a three it will print three so these values will be 1 3 1 comma 3 comma 3 are passed to print F so here it will 3:46:08 be pass it to 1A 3A 3 so that is one thing so now here here printer prints them in the order they appeared in the format using the in the string like 3 3 and 1 writing code that relies on the order of argument evaluation leads to unpredictable behavior and is considered a poor practice so this is one thing which you need to understand the second one which I want to tell you is the using the library functions so here this the second one so now you understood about this concept so second one is the Library functions Library functions like s cos Etc need their prototype declared to inform the contain compiler about their usage so for example let's say that so here this is our example code I will try to show you so we need to use this math. include prototype for math functions like sin cos Etc and here you can use sign like this it will be mentioned here in this math. now if 3:47:10 these prototypes are missing the compiler cannot verify whether the correct type of argument and return values are being used or not so here we are using headerfile studio. input output functions like printf scanf is used math. mathematical functions like s cos power Etc has been used for example let's say that I will try to show you a simple example for this one so here this is our example so without using math. H the compiler won't recognize the functions or verify their correct use so here you are using studio. and math. and here we are using float a equal 0.5 and we are using S cos these all things right so these methods these functions declaration all those things are indic mentioned in the math. so without using this math. then it the compiler won't recognize these math functions the third one which I want to tell you is the mismatched arguments in the printab okay so mismatched arguments sorry mismatched arguments in the 3:48:11 printer I try to print here yeah printer accepts a variable name of argument variable number of arguments so ma mismatches in format specifi and variables may not result in the compile time errors so it will not result the compile time errors I will try to show you some simple examples for this one so here the first one printf may print 10 20 and a garbage value where garbage comes from the undefined memory so here we are having three percentage D and we are using only the missing one variable and here we are having only one percentage and we are using three or two variables extra variable J without a format specifier we are trying to use it so if you want to use this one so for example let's say that so we are here we are using this value right so let's try to go into this one here I will mention this two things and here I will use oh sorry and here I will use int I is equal to sorry I isal 1 and int J = 2 let's 3:49:13 assume and if you try to run this one one so here you'll be able to see some garbage value has been printed and this one is omed and the second one printer will be ignored J because uh we'll ignore J because there is no percentage D for it so now always ensure the number and type of format specif match the arguments pass to printf to avoid the unpredictable outputs that is one thing the next one which I want to tell you is the written type of functions the written type of functions the functions in C have a default written type of in unless explicitly specified otherwise example for this one is for example let's say that you are having float square of float X and you are wring X into X WR a float value so here if the return type is not explicitly declared as a full float the compiler assumes that the functions returns an INT the return float value will be truncated as to an integer causes errors in the output so for example let's say that here I will try to show you a simple example for this one so here uh we are 3:50:14 having a float Square float of X and return X into X we are using and in main float AAL 1.5 and here we are printing the value percentage to your percentage to F and return zero now if I try to print the value for this one so here you'll be able to see 1.0 and 2.25 so that is that is that is one thing why Precision matters so Precision matters also you need to understand very very clearly so this Precision thing using the correct data types and prototypes ensures accurate Cal calculations and prevents tcation or rounding errors example using a Flo for precise decimal calculations including appropriate header files math for mathematical operations so these are the Precision matters so normally the general takeaways what I want to tell you is before closing of this one order of argument passing avoid writing code that depends on the order of argument evaluation compiler differences may lead to the unpredictable outputs and we need to use the prototypes always include the necessary header files to declare the 3:51:15 library functions prototypes help the compiler check the validity of the arguments and written types print of mismatches Ensure format specifi and arguments list match exactly debugging mismatch print of statements can be tricky and the return types explicit written explicitly specify the return type of functions to avoid surprises the default return return type is int so whenever you don't mention the return value and you are wring some value from the function means function means then the return value for this one is int so that's it guys about this uh functions concept which I want to tell you about these things so I have told you about the order of which how you pass the arguments and we have shown you about the library functions also like sign double and header files how it will deal and we I have explained you about the mismatched arguments in the print of if the print of uh arguments and all those things are mismatched means then how the compiler will take this one so it will not throw you any compile time errors it will print the garbage values and another one is written type of the functions so float square and all those 3:52:15 things I have shown you so if you don't mention it by default value it will be int and the Precision thing I have explained you so hope you understood about this concept if you have any doubts or any suggestions please post the comments below to this video and if you like this video please do support me by subscribing to my channel thank you hi guys this is Leela welcome to my channel Leela webo in this video we will we have learned about the functions the arguments and all the things we have learned it let's try to do a couple of programs or some example codes how to implement the functions in the C so first one the problem is calculating the factorial of a number so the first of all what we need to do it is we will try to calculate the factorial of a number so for calculating the factorial of a number so you people know that uh factorial of a number is N I will try to explain you here clearly so what is the fact factorial of a number a factorial of a number is nothing but n is the product of all positive numbers using a function so here what we'll try to do normally the formula for this one is n 3:53:17 factorial n factorial is equal to n into nus1 into nus 2 like that it will be going on so let's try to do it so now here for implementing this factorial of a number so what we'll try to do it is so here let's go into this one yeah so now here let me implement the let me start the factorial of a number so for this one I will remove move this entire code actually float Square X these all the things are not needed and in this in main also not needed so let's write so now we will take a number okay and we'll take the factorial factorial so these are the two things and we will ask printer enter a number slash okay so this is thing and scanf percentage d m percent number so this this is the scanner now 3:54:20 what I want to do so here we need to calculate the factorial so here I will write factorial is equal to fact of and I will pass that number to this one so now we need to calculate the factorial of the number so here for the for the timing for the first so what we'll try to do we'll declare the function so here it will take int fact off and you can write it as an in if you want you can mention the variable name or not need not a problem and at the bottom what I will try to do I will declare the function so let's try to declare the function int fact of int num okay and in this one here let's write the code so we got the num so I am declaring the variable in time and I am declaring the variable factorial is equal to 1 okay so here I can use for I equal to 1 I less than or equal to num I ++ so this is the 3:55:23 sorry so this one is our code and here what I will try to do it is so here factorial factorial is equal to factorial into I that's it this is our code and now here I will return the factorial for this one so return the factorial fine done so we are calling this method so we are able to store this value and here I will try to do print of factorial of percentage D is equal to percentage d/n and here we need to write the num and also the factorial that's it so now if I try to run this code let's see so here it is asking percentage number where is that one okay so here you need to give M okay now if you try enter a number okay if I want to calculate six factorial of a six is 720 so now we are able to successfully 3:56:24 execute this one so now the fact function here takes an integer input and calculates it factorial we uses a loop to multiply numbers from one to the input number here so main function reads a main function reads the number from the user calls the fact function to calculate the factorial and it will print the factorial value so this that's it about the factorial thing so now the next problem what I want to tell is we need to calculate the power of a number so that means for example let's say that we need to calculate a to the power of b a rise to the power of B using a function so let's try to implement using a function so for this one what I will try to do I will remove this Entre code okay so for this one we will be having a float value power so we need to take the float base and also the int exponent so this is our function declaration so we will be having int Main and here we'll be having two values that is nothing but float 3:57:24 base and int exponent and we'll be having a float result so these are the three variables which I will be trying to do so here I will use printf and here I will ask enter two numbers enter two numbers so one is base and also the exponent so I want to write the two numbers so here if I try to enter it so scan F so here I will take percentage F sorry and percentage D and here we can take M percent base value and also m per exponent value so these are the two values which I have taken now I want to calculate the result result is equal to power of Base comma X exponent I [Music] want I want to pass this uh function so we need to create this function so we have already declared the function we need to create this function so after creating this function let's try to 3:58:25 printf so printf printf so here uh what I want to do is percentage 2f so two decimals I'm trying to show 2 the Power of percentage D is equal to percentage 2f I will try to do it sln and here we can write the base and exponent and also the last one is the result that's it so this is the thing so now we can use the return Z to exit the program so now we need to implement the the function power function so let's try to implement the power function float power of so it will be taking two values that is nothing but base and also the another one is int exponent so these are the two things so now if I want to mention this one is int and also the float result is equal 3:59:25 to 1 and we need to Loop over the 1 by one so float I is equal 1 I less than or equal to exponent those many times I need to multiply that one and I ++ so here we need to calculate the sorry here not float it's for L for the now here what I want to do result is equal to result into base so these many times I need to multiply and Last At Last I need to return return the result that's it so now if I run this program so it will ask you enter two numbers base and exponent so I can write something 2.3 and 8 2.3 Power 8 so here 2.3 2.3 to the^ of 0 so what happened here oh what happened here I'm not taking the exponent so I'm taking the exponent 2.3 to the power of exponent in exponent let me check once so now let's try to rerun 4:00:27 it again function declaration so here if you try to see so 1.54 1.5 and 4 now here you'll be able to see 1.5 to ^ of 4 is 5.06 now we are able to successfully execute the power of a number so this is how we will be writing the function in order to calculate this one so fine we now we are able to implement this power function also so what is this power function does so takes a floating Point base value and an integer exponent as inputs uses a loop to multiply the base exponent times and the main function reads the base and exponents from the user here it will try to read it and calls the power function to calculate the result and it will print the result so that's a simple thing so the next problem what I want to tell you is convert ear to a Roman numerals so we will try to do convert ear into it Roman numeral equivalent so for this one what I want to do it is so I will remove this entire code okay so here we will be having a function declaration so function declaration means it's a simple thing so we'll try to do it here in romanize in 4:01:29 here in value and car Roman so here I trying to take the year value and the value and the Roman value so here this is our function declaration so let's write implement the main function so int Main and in this one so you need to have you need to take the user from the you need to take the Year from the user so here you can ask enter year that's it enter here so if you ask the enter here so we need to scan it and here we need to do percentage d m percent here that's a simple thing okay so we got the printer and scanner so now we need to so what I need to do so here so we need to romanize the values for this one so I will try to show you this romanized thing so now here let's try to implement so now let's implement the method for this one so here int romanize okay so this is 4:02:29 the and here you'll be having int year int value and also the C Roman so these are the values we'll be having now we need to do in count so determines how many times the Roman numeral fits into this one so here we need to do the thing in year in count is equal to this one and here I will be doing year by value okay so year by value I do it here so we will be having some couple of things like year is equal to okay so now here what we'll try to do so here I will divide the year into a small small parts so here I will use romanize of so how many times it will fit we'll see so here I will pass the year and thand th000 is denoted by m here okay Y and we will be having 4:03:32 another one oh sorry so we will be having another one that is nothing but here so we need to have we will be having a 500 so 500 is donated by D okay and we have an another one that is nothing but 100 100 we have 100 100 is dened by C so like this we need to mention all those things sorry and here you'll be having another one that is nothing but uh like this so we will be having all the things like I have the list with me so 100 500 5 500 is there okay so 50 10 5 these are all the Roman numbers no now we got the Roman numbers so what I can do here so we can return return the zero and we need to count the values one by one so here we got the count here by value so whatever the value th000 means 1988 if it comes means by 1,000 it will do and here if it is divisible means then we'll take it and in I okay so how many times 4:04:33 the count you will be getting so we'll try to do it so how that many times we need to print so for count I is equal to 1 I less than or equal to count I ++ okay and here what I will do printf percentage C and here I can print the Roman and we will return the at at last we will return the year value that's it so we are rning the remainder of for the further processing so now if you try to run this one so let's see what could be the output for this one so here it is raising the issue so we are having everything correct okay here I'm having a return problem so let's try to see so here still it is asking year is equal to okay okay okay so we are having some issue here so I have given the name 4:05:34 wrong so let's try to run this one so at last you'll be able to see it will ask you for the enter year 1988 if I try to give it so it will try to give the Roman year for this one one so this is how we'll be calculating so here what is happening is dividing the Year by the Roman numeral value 1,000 for something like that we are doing and we are printing the numer Roman numeral for every quotient we are doing and we are wrting the remainder to process the further smaller Roman numerals so here what we trying to do the process the year starting from the largest Roman numeral th000 to the smallest Roman numeral one we are trying to processing it one by one so this is how we will be calculating we will be using the functions in order to achieve these type of problem so hope you understood about this concept the problems which I have discussed so if you have any doubts or any sus please post the comments below to this video and if you like this video please do support me by subscribing to my channel thank you