Printf,Scanf functions In C

In this article, I am going to tell you about some inbuilt functions which are present in stdio.h header files. what are printf and scanf functions?

A function is a set of statements written in block. we are using printf and scanf inbuilt functions by giving parameters. Generally, printf takes a string as a parameter and it prints on to the screen.
what do you mean by the above statement? why do you write every time the above statement in every program? I will clarify your doubts.

printf and scanf functions are inbuilt functions that are present in standard input and output header files. Mainly printf function is used for printing strings on the screen and scanf function is used to read the input from user.when compiler comes to scanf statement it expects input from the keyboard.
as you see in the above example we are printing the "hello world" string on the screen. within parenthesis, we write the string to be printed on the screen. Above is the syntax to be followed during writing printf statement.

Now let's look at scanf function,
we declared 'a' as an integer variable, so we can store an only integer in 'a' variable. its time to initialize a value by using scanf function.

carefully observe the above statement, as we are taking integer type of input, we used "%d"(Format specifier).Generally, the format specifier used to retrieve the specific type of data and format from the stream.
here are the common format specifier in C language


1.      Integer                                 "%d"

2.      Char                                      "%c"

3.       float                                      "%f"

Above are the commonly used format specifiers in C language, we used '&' in scanf statement, it is the address of are telling scanf function to store the value at variable 'a' address by using '&' character.

you must follow and practice above syntax, so you can write any print any type of statement and read any type of data from users

Post a comment