Transcript for:
Standard Library Functions in C Programming

what's up guys this is me padma from programming and welcome back to this series on c programming in the last video we'll learn to create a function this function which we define ourselves i called user defined function in c there is another type of function called standard library function the function definition of standard library function is already provided by c and we can directly use them in our program so let's get started before we learn about standard function let's see a simple example to print a text you can see this code in my code editor i'll run this program and you can see hello world is printed on the screen here printf is a standard library function that prints the text on the screen we haven't provided any definition for printf instead we are directly using it in our program in c programming a standard library function is a predefined function which is already defined inside a file and we can directly use them in our program in our case the definition of printf file is present inside the stdio.edge header file that's why we have included stdio.edge header file inside our program and once the file is included we are able to use the printf function inside our program and also the scanf function that we have used to take the input from the user is also a standard library function and it is also defined inside the stdio.h header file there are various header files available in c programming this file includes different standard library function that we can use directly in our program let's learn about some of the c library files and standard library function present in those files we'll start with the math file the math.h file provides us with various built-in function that helps us to perform mathematical operation easily for example the sqrt function computes the square root of a number all this math based standard library function are defined inside the math dot edge header file so to use them we import the math dot edge header file in our program let's now use this math based library function in our program i'll start with the square root function on your screen you can see the basic structure of a c program now first i'll import the math dot edge header file so i'll include math dot edge header file then i'll create an end variable say num and i'll assign value 25 to this i'll print the square root of this number so i'll write printf bracket inside quotation square root percent lf and comma s q r t inside parenthesis name of our variable num here the sqrt function returns the value in double so i have used percent lf to print the output now let me run this code as you can see we get 5 as output which is the square root of 25 here we don't have to worry about the definition of sqrt function we can simply pass a number and get the square root of that number similarly we can use the cbit function to compute the cube root of a number let me show you i'll change the value of 25 to 27 and i'll change this function sqrt to cbrt and then i'll change this text from square root to cube root so i'll run this as you can see i get 3 as output which is the cube root of 27 now let me show you one more example this time i'll calculate the power of a number i'll use the same code from earlier and i'll remove these lines and i'll create two variables so end a and i'll assign value 5 to this in variable a and another variable b and i'll assign 2 to this now i'll use pow function so inside the parenthesis i'll use two variables a and b here this pow function is the power function i'll assign this to a double variable result so double result is equals to pow function and finally i'll print this using printf statement so power percent lf comma result and i'll run this code here we get 25 as our output so what happens here is this first argument a of the power function is the base value and the second argument b is the power raised to the base so it gives 5 raised to the power 2 which is equals to 25 now let me change this value of b from 2 to 3 and i'll run this again and this time you can see we get 125 which is 5 raised to there are various functions defined inside the math dot edge here file you can learn about them on programmies.com website i'll put the link in the video description below by the way if you're watching this there is a good chance you want to improve your skills in c programming lucky for you we have a mobile app that provides a well-structured c programming course with certification at the end and you can use the app alongside the video to practice on the built-in compiler our course is free so download now by scanning this qr code or click the link in the video description now let's learn about different library function available inside the c type dot edge header file this file provides function to perform various operations on characters hence it is known as a character type header file let's see some example so you can see this basic structure of c program here first i'll import c type header file in our program so c type dot h header file now inside the main function i'll create a character variable say alpha and i'll assign a character e to this let's first use a function to convert this character to uppercase so i'll use a function to upper and inside the parenthesis i'll use alpha and i'll assign this to a care variable upper so care upper is equals to this function then i'll print this using printf statement so percent c comma upper i will run this code and you can see we get capital e as output now let's change this uppercase value to lowercase so after this print statement i'll write care lower and i'll assign function to lower inside parentheses i'll put here upper then i'll print this lower variable as well so percent c comma lower and then i'll run this code as you can see the capital e is now converted to lowercase e in our example to upper and to lower our standard library function that are used to convert character to uppercase and lowercase respectively okay guys we need your support to keep these types of content free for all users youtube really likes engagement on the video so leave a comment below press that like button hit subscribe if you haven't already let's get the engagement score high up so that more people can discover and enjoy these courses now that we know how to use library function in our program let's see why standard library function are so helpful as we saw earlier we can directly use library function in our program we don't have to worry about the function definition and we don't have to write the code ourselves this saves significant amount of time and since they are already tested they work completely fine without any error also they are built in inside the c program so they are optimized for better performance and developers are constantly improving to keep them up to date there are so many library function in c programming if you want to learn about them visit our text based tutorial i'll put the link in the video description below now to revise what we have learned in this video here is a programming task for you create a program that compute the result of a number raised to the power of the square root of a number so first take the input from user compute the square root of number using sqrt function compute the power of the number raised to the power of its square root and then print the result you can find the answer to this question in our github repository and also if you want to revise this concept all these program in this video are present in there the link is in the video description below now that we have reached the end of this video it's time for programming squeeze what is the correct way to include library function in our program comment your answer below see you in the next video happy programming [Music] you