jeudi 17 mai 2018

Function not returning value, but cout displays it

I've been learning C++ for a bit and tried my hand at making a simple function that returns the area of a room. The return statement doesn't output the value, however using cout I can see the result. Am I missing something here?

#include <iostream>
using namespace std;

int Area(int x, int y);

int main()
{
  int len;
  int wid;
  int area;
  cout << "Hello, enter the length and width of your room." << endl;
  cin >> len >> wid;
  cout << "The area of your room is: ";
  Area(len, wid);
  return 0;
}

int Area(int len, int wid)
{
  int answer = ( len * wid );
  return answer;
}

Aucun commentaire:

Enregistrer un commentaire