What are the difference between printf and scanf in the C language?
In today's blog we will learn about some important functions used in c language. Which is often used in the coding of C. As well as learn its syntax and usage.
https://todaygyan3.blogspot.com
Printf() Function
This function is used to display output on the computer screen. printf() is a
pre-defined or in-built function that resides in standard C library. We can also
called output. Through this function, the user receives any type of message
on the output screen.
There are some syntax and uses of printf() function.
1.When user display only message on the screen of the computer-
Syntax:- printf("any message");
Example :- printf ("My name is Dhananjay Kumar");
Output :- My name is Dhananjay Kumar
Note:- 'a' is character, but "Dhananjay" is a string beacause string is a sets of
characters.
2. When user wants display the value of variables.
Syntax :- printf("format specifier", variables Name);
Example :- int num = 521 ;
printf ("%d", num);
Output :- 521
3. When we display variable value with any messages.
Syntax :- printf ("Any messages format specifier", variable name);
Example :- float n ;
n = 25.2 ;
printf ("The value of n= %f ", n);
Output :- The value of n = 25.2
Scanf() Function
It is used to input value at the run time in a specific variable. Scanf() is a pre-
defined or in-built function that resides in standard C library. We can also
called input. Through this function, we get the input from the user at run time.
Syntax :- scanf ("format specifier", &variable);
Where & = address of variable.
Example :- int number;
scanf ("%d", &number);
I hope you know What are the difference between printf and scanf in the C language. Must have understood very well. If you have any doubts in this blog, then you can write for it in the below comment box. There is one more request from you that you must tell your friends about this blog and share it on as many social media accounts as Facebook, What's app or others.
What are the difference between printf() and scanf() in the C language?
By- Today Gyan
Learn more:-
What is type casting
How many types of casting are there in Java?
What is the difference between explicit and implicit casting in Java?
What are implicit and explicit casting explain with the help of example Java?
How many types of casting are there in Java?
What is the difference between explicit and implicit casting in Java?
What are implicit and explicit casting explain with the help of example Java?