In C, if you don't return anything...it will show a warning message that functiona should return a value and then it will return a int type containing a 0 by default....coz zero is the signal to OS that program terminated normally i.e. without any critical errors....
2006-08-12 22:37:47
·
answer #1
·
answered by DeAd MaN 4
·
0⤊
0⤋
Hi,
You Asked That Main Returns Int Type, Then You Must Write Programme Code As Following:
int main()
{
/*.....Code.......*/
return(0)
}
Now, If Above Version Of Main Doesn't Return Anything And You Want To Write "int" Key Word Then You Must Declare It As "Void" B'coz It Don't Return Any Thing Now See Another Example:
int main()
{
int x,y,z;
Printf("Addition Programme.");
scanf("%d %d",&x,&y);
z=x+y;
return(z);
}
Now You Can Easily Understand Why We Need Return Statement.
And, Still You Don't Write Any More Return Statement Then You Will Get Compilation Error. OK ?
I Think This Answer Is Sufficient For Your Query...BYE Have Nice Day And Keep Asking Such Questions...
2006-08-12 01:45:08
·
answer #2
·
answered by dhvtzala 2
·
0⤊
0⤋
if u give a data type along with main then u will have have a return statement at the end or else the program will not compile. try using void main instead. its better than using int main and then return 0
2006-08-12 03:57:20
·
answer #3
·
answered by Jijo 2
·
0⤊
0⤋
If you omit the return then C will by default return the "int" type.
if you mention void main() then it will not return anything .
if you want the function main to return the int type as you mentioned you must declare the main as int or if you want it to return the string type then you must declare it as string. now after you declare the type of the main() and even you dont give return, as i said in first line of my answer it will return the declared type of the main() in your case it will return "int" type
2006-08-11 23:56:03
·
answer #4
·
answered by mane 5
·
0⤊
0⤋
you can leave keep it as
void main()
it will not reuturn anything ..
you don't need to return anything from a main.. So you can keep nything u want..
Infact its best to keep it as void main..
If you dunt give reuturn statement...
it will not compile !!
2006-08-11 23:20:09
·
answer #5
·
answered by xlord_vader 3
·
0⤊
0⤋
void main()
2006-08-14 04:46:37
·
answer #6
·
answered by anish g 1
·
0⤊
0⤋