Return funtion

Sep 30, 2012 at 3:15pm
#include <iostream>
using namespace std ;

int calcArea( int , int ) ;
void display ( void ) ;
int main ()
{

int length , width , area ;

cout << "please enter the length and width" << endl ;
cin >> length >> width ;

area = calcArea ( length , width ) ;

display ( void ) ;


return 0 ;
}

int calcArea ( int l , int w )
{
return l * w ;
}

void display ( void )
{
return "display the area" ;

}

THERE IS SOMETHING WRONG ON THIS CODE. I CAN'T RUN THIS PROGRAMME.
Sep 30, 2012 at 3:21pm
When you call the display you should not write void inside the parenthesis.
Sep 30, 2012 at 7:13pm
Here you are returning constant character string from the function which has void as return type.
Either you do not return any thing (return; or //return "display the area" ; ) or change the return type (to char* display ( void ); in this example).
Last edited on Sep 30, 2012 at 7:14pm
Topic archived. No new replies allowed.