cplusplus
.com
TUTORIALS
REFERENCE
ARTICLES
FORUM
C++
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs
Forum
General C++ Programming
Return funtion
Return funtion
Sep 30, 2012 at 3:15pm UTC
techboy
(3)
#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 UTC
Peter87
(11238)
When you call the display you should not write void inside the parenthesis.
Sep 30, 2012 at 7:13pm UTC
upX86
(59)
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 UTC
Topic archived. No new replies allowed.