+ 1

Hi.what is the output and why?(c++)

#include<iostream> using namespace std; void main(){ int i = 5; cout << i; }

13th Dec 2017, 3:46 PM
S.hasan
S.hasan - avatar
6 Answers
+ 8
yeah main function should be int and return any value like 0 #include<iostream> using namespace std; int main(){ int i = 5; cout << i; return 0; }
13th Dec 2017, 3:54 PM
GAWEN STEASY
GAWEN STEASY - avatar
+ 7
yeah return 0; is not necessary it will work fine without it too but it is written literally because every function returns an value
13th Dec 2017, 4:02 PM
GAWEN STEASY
GAWEN STEASY - avatar
+ 2
ohhh! main function can not be void!!! this is reason of error!!!
13th Dec 2017, 3:52 PM
S.hasan
S.hasan - avatar
+ 1
but i think return 0; is not necessary and will work without it. is it true?
13th Dec 2017, 3:57 PM
S.hasan
S.hasan - avatar