Declaring a variable provides the compiler with an assurance that there is a variable that exists with that very given name. This way, the compiler will get a signal to proceed with the further compilation without needing the complete details regarding that variable.
The declaration of variables is useful when we use multiple numbers of files and we define the variables in one of the files that might be available during the time of program linking.