Hello viewers I welcome you all in my channel digital role in the previous video we learn about some terminologies of C programming and today we will be learning what is printf and scanf and how they perform also we will learn about the declaration of variables and how can we assign values to them and access them so let’s get.
Started so what is printf printf is a keyword which is used to display the information or result anything we want to display to the output screen or to the.
User there will be the use of printf and the printf is defined inside the header file stdio dot s and the secondly scanf scanf is a keyword which is used to take input anything or any data which will the user give will be taken input by the scanf function and also scanf is also defined inside the header file stdio dot ads and more about them will the learning through.
The program so let’s start our example so here I will be making a simple program to calculate addition subtraction multiplication quotient and remainder through is we will learn about the printf scanf declaration of variables accessing those values assigned to the variables and how the values are assigned so let’s start at first I will include the header files STD outdoor test and Co Naya daur tats generally you can use.
1 the STD hours or tests but here I was using Konoha test too so let’s get started you can declare intamin also but here we have nothing to return is a return type so but we have nothing to return so we are declaring void here so let’s declare our variables I will declare two variables a and B and to calculate addition I will be declaring the variable.
Difference I will recognize and sub for multiplication I will have mu ality and for goose and I will.
Be declaring variables Q mu E and for the remainder I will be declaring the variable re young right I declare all the variables integer you can also declare these two quotient and remainder as float because quotient and remainder can be floating values as well so I will be declaring this you have to declare like this at first we have to write data type and then bribable names.
You have to end the line using the semicolon and next line like this so after this will be display one informated message using the keyword printf printf the syntax is like this just was it this is the backslash and for new then you.
Turn this is not a compulsory you can leave this.
But I will be doing like this I will display enter any values to a and B so this masses will be appear to the out output screen seeing the values for a and B and those values will assign we’ve assigned to end V by the keyword scanf we will be taking input.
Like this for the integer value we will be taking percent D and there are two gravels will be doing personally or send D without commas and dot para spaces and their coma and with assigning values using the ampersand sign this is the address sign here and percent a comma and ampersand PE doing this what we did is we assigned the values entered by the user to a and B to the memory location of a.
And B when these two variables these two drivers a and B had already resolved the memory location in storage and we assigned the values to these memory locations using the ampersand sign.