Use of scanf function in C Langauge
Scanf () Function..
scanf("format characters",&variable1,&variable2, .......);
a) scanf("%d", &a);
b) scanf("%d %d", &a, &b);
c) scanf("%d %f %c, ", &a, &b, &c);
& -> address of operator
Use of scanf function in C
-> Scanf is an input function , the header for which is stdio.h
-> This function takes the value for given varaible at runtime.
-> At runtime when the scanf function is found in the program, execution stops and its wait for the user to provide values for the variables given with scanf() function.
-> We have to give that many values of that types , as the numbers and types of variable we have given with scanf function.
-> The given values gets assigned to the given varable seperately.
->The values given at run time may be seperated :
a) Using spaces
eg: 10 20
b) Using enter keys
c) Using tab Keys
eg: 1- -> 20
-> Message can't be given with scanf() function like
scanf("enter one integer %d",a);
-> So generally a printf function is given before sanf to provide a messsage to the user to him data entry.
eg: printf("enter the integer");
-> The main advantage of scanf () is that each time you can run the program , you can give the different set of value for the same variable and can get different O/P and developed generalised program.