RSS Forums RSS

simple program problem - need help

Please support our C advertiser: Programming Forums
Thread Solved
Reply
Posts: 48
Reputation: atman is an unknown quantity at this point 
Solved Threads: 0
atman atman is offline Offline
Light Poster

simple program problem - need help

  #1  
Nov 9th, 2008
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!
AddThis Social Bookmark Button
Reply With Quote  
Posts: 418
Reputation: Denniz is on a distinguished road 
Solved Threads: 15
Denniz's Avatar
Denniz Denniz is offline Offline
Posting Pro in Training

Re: simple program problem - need help

  #2  
Nov 9th, 2008
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;
}
Reply With Quote  
Posts: 82
Reputation: ajay.krish123 is an unknown quantity at this point 
Solved Threads: 6
ajay.krish123 ajay.krish123 is offline Offline
Junior Poster in Training

Re: simple program problem - need help

  #3  
Nov 9th, 2008
you can also use the above statement as
void main()
{
........
.......
.....
getch();
}
since in using the void function you need have to use return anything.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.



Views: 398 | Replies: 2 | Currently Viewing: 1 (0 members and 1 guests)

 

Thread Tools Display Modes
Forums | Blogs | Tutorials | Code Snippets | Whitepapers | RSS Feeds | Advertising
All times are GMT -4. The time now is 2:15 pm.
Newsletter Archive - Sitemap - Privacy Statement - Acceptable Use Policy - Contact Us
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC