+ 2
If I m declaring function after a main body it's showing error.But If I m declaring it before main it's working.wats the concept
7 Antworten
+ 4
In order to call a function, the compiler must know the prototype of it. If you wish to have your function follow main, declare the prototype before main and it will work. Putting this before main, allows the definition to be after:
int print();
+ 2
main is a function where the program execution starts. Every program has a main function.
+ 2
You cannot use a function or variable which is not yet declared.
eg:
x = 3; // x not yet declared
int x;
This is wrong. Because the compiler doesn't know what x is and you are using it.🤐
Correct way:
int x;. // first declare x
x = 3;
Likewise:
int print();. // first declare the function
int main(){
print();
}
int print(){
cout<<"You got it?";
}
+ 2
no problem bro
+ 1
ty sir
+ 1
I got it...concept clear ...ty sir
0
ys it is...sir bt wats the concept y is it necessary to declare dt function before main function then after only we cn call it in main body . y it's nt working if I will declare dt function in the main body?