DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   C (http://www.daniweb.com/forums/forum118.html)
-   -   simple program problem - need help (http://www.daniweb.com/forums/thread156165.html)

atman Nov 9th, 2008 2:46 am
simple program problem - need help
 
Hello.,
Im learning C online, and one of the examples from the internet is this:

#include <stdio.h>

int CalcVolume (int length, int width, int height);

void PrintIt (int vol);

void main()
{       
int volume1, volume2;
int x = 8, y = 15, z = 20;
volume1 = CalcVolume (10, 20, 30);
PrintIt (volume1);
volume2 = CalcVolume (x, y, z);               
PrintIt (volume2);       
}       

/* end of main */       

int CalcVolume (int length, int width, int height)       

{

int vol;       
vol = length * width * height;
return vol;       
}
/* end of CalcVolume */

void PrintIt (int vol)
{               
printf("The volume is: %d\n", vol);
}


but when im trying to compile it sais

ch5m.c: In function ‘main’:
ch5m.c:9: warning: return type of ‘main’ is not ‘int’

is there an error in the exesize?

Thanx!

Denniz Nov 9th, 2008 3:05 am
Re: simple program problem - need help
 
Some C compiler will give you a warning when your main function does not return an integer.

In this case, do the following changes to the main function:
int main()
{
......
......
return 0;
}

ajay.krish123 Nov 9th, 2008 11:23 am
Re: simple program problem - need help
 
you can also use the above statement as
void main()
{
........
.......
.....
getch();
}
since in using the void function you need have to use return anything.


All times are GMT -4. The time now is 9:29 am.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC