What is the effect of putting void before main function i mean?
What you wrote means the function returns no value. This is valid syntax in general, but not for the main function. Many functions don't have a return value. For example, a function that receives a structure pointer as an argument and updates the contents of the structure might well have no return value.
The main function must return an integer (an int) to be compliant with the standard. The returned value indicates success (zero) or failure of some sort (non-zero).
DH is completely right: void main() is not okay, 'not nowhow, not noway' as the Lion said to Dorothy.
If you leave it as void main(), when the program returns to the shell or whoever called it, the return value can be any integer, ie. whatever garbage is left in stack space. If it returns a zero, it is probably pure luck - programming by coincidence.
main() should be defined as 'int main()' or in many cases 'int main(int argc, char * argv)'.
The C++ standard requires main to return int.
The C standard permits compilers to allow other return types -- but such code is, in principle, nonportable.
Separate names with a comma.