The scanf() function in C is used to read formatted input from the standard input (usually the keyboard). It allows you to capture user input and store it in variables. The function takes a format string that specifies the type of data to read, along with the addresses of the variables where the input will be stored.
For example:
int num;
printf("Enter an integer: ");
scanf("%d", &num);
In this example, scanf() reads an integer from the user and stores it in the variable num. The %d format specifier indicates that an integer is expected, and the & operator is used to pass the address of num to scanf().
