Use of & in scanf() but not in printf() Last Updated : 03 Jul, 2023 Comments Improve Suggest changes Like Article Like Report Why there is need of using '&' in case of scanf function while not in case of printf function. Examples: scanf("%d %d", &a, &b);printf("%d %d", a, b);As a and b above are two variable and each has their own address assigned but instead of a and b, we send the address of a and b respectively. The reason is, scanf() needs to modify values of a and b and but they are not local to scanf(). So in order to reflect changes in the variable a and b of the main function, we need to pass addresses of them. We cannot simply pass them by value. But in case of printf function as we are only going to print the values of the variables in output console, there are no changes going to be made in variable a and b's values. So it is not required to send their addresses. Comment More infoAdvertise with us Next Article Use of & in scanf() but not in printf() U UPENDRA BARTWAL, Follow Improve Article Tags : Misc C Language c-input-output C-Functions Practice Tags : Misc Similar Reads Cin-Cout vs Scanf-Printf Regular competitive programmers face common challenge when input is large and the task of reading such an input from stdin might prove to be a bottleneck. Such problem is accompanied with âWarning: large I/O dataâ. Let us create a dummy input file containing a line with 16 bytes followed by a newlin 3 min read Return values of printf() and scanf() in C/C++ What values do the printf() and scanf() functions return ? printf() : It returns total number of Characters Printed, Or negative value if an output error or an encoding error Example 1: The printf() function in the code written below returns 6. As 'CODING' contains 6 characters. CPP // C/C++ program 2 min read What is use of %n in printf() ? In C printf(), %n is a special format specifier which instead of printing something causes printf() to load the variable pointed by the corresponding argument with a value equal to the number of characters that have been printed by printf() before the occurrence of %n. C #include<stdio.h> int 1 min read Why "&" is not used for strings in scanf() function? Below is syntax of Scanf. It requires two arguments: scanf("Format Specifier", Variable Address); Format Specifier: Type of value to expect while input Variable Address: &variable returns the variable's memory address. In case of a string (character array), the variable itself points to the firs 2 min read Print an Integer Value in C Printing an Integer in C is one of the most basic tasks. Input and output of the elements are essential for taking input from the user and then giving the output to the user. Here we are going to take an integer as input from the user with the help of the scanf() function and print that integer with 2 min read Like