+ 1
In this program
1.#include<iostream> 2. using namespace std; 3.void printsomething() { 4. cout<<"hello world"; 5.} 6.int main() { 7. printsomething(); 8. return 0; 9.} here the 8th line has no meaning in the sense that even if i remove it or keep it. i always get the same output. why plis help
11 ответов
+ 9
i.e
void Afunction() {
cout << "inside a function" << endl;
}
const int aGlobal = 5; // outside
int main() {
cout << "inside main" << endl;
aFunction();
return 0;
}
+ 7
return 0 will be added automatically by the compiler if it is missing.
It is used to return a value to main. which reports to the operating system if the program exited normally or not.
+ 7
you 'should' but only for the main function.
If you forget it is added for you
+ 2
yup it will add return 0 explicitly
oops I'm late . Nice ans @jay
+ 2
jay does that mean that i always need to put return 0; everytime in my codes.
+ 2
whatever enclosed within the curly braces {} belongs to the respective function or the class (means is the inner side ) whereas outside the braces gives u the outer side of the function or class
+ 1
nope even if u dont the compiler will do it for you
+ 1
ok thanks
+ 1
jay and nirmal plis tell me what is inside and outside of a function or class. is it the inner side enclosed by the curly braces.
+ 1
thank q
+ 1
thanks jay