473,327 Members | 2,090 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

value returning function

This lab will allow you to practice using value returning functions Please read all
directions before beginning. You will turn in two programs (L5_P1.cpp and L5_P2.cpp).
Be sure to include you and your partner’s name in the comments section of your program
(see the description in Blackboard.)
Problem 1. (Estimated time 15-20 mins)
When completed, the following program skeleton should ask the user for the length and
width of a yard, and then display the yard’s area. You must write the prototype, the
definition of the function calcArea and the function call to complete the program. Copy
and paste this program into the IDE.
//Program to calculate the area of a rectangular yard.
//L5_P1.cpp
#include <iostream>
using namespace std;
//Place prototype here for calcArea.
int main()
{
float length, width, area;
cout << “This program calculates the area of a\n”;
cout << “rectangular yard. It must know the yard’s \n”;
cout << “length and width. How long is the yard? “;
cin >> length;
cout << “How wide is the yard? “;
cin >> width;
area =//Place function call for calcArea here.
cout << “The area of the yard is “ << area;
return 0;
}
float calcArea(float len, float wide)
{
// Youmust write this function which is to calculate and return //
the area of the yard. Simplymultiply the length
// by the width and return the value.
}

the prof stated that all you have to change is the area portion. my question is to what
Oct 1 '08 #1
1 2505
JosAH
11,448 Expert 8TB
Simply call the function? As in:

Expand|Select|Wrap|Line Numbers
  1. area= calcArea(length, width);
  2.  
kind regards,

Jos
Oct 1 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Mountain Man | last post by:
Hi, I'm having trouble with the foreach function. I'm using it twice inside a user defined function with two different arrays, and in the second instance it's returning the value of the first...
9
by: mjm | last post by:
Folks, Stroustrup indicates that returning by value can be faster than returning by reference but gives no details as to the size of the returned object up to which this holds. My question is...
11
by: JKop | last post by:
AnyClass Blah() { AnyClass poo; return poo; } As we all know, in the above, the compiler is entitled to:
25
by: Victor Bazarov | last post by:
In the project I'm maintaining I've seen two distinct techniques used for returning an object from a function. One is AType function(AType const& arg) { AType retval(arg); // or default...
5
by: Neal Coombes | last post by:
Posted to comp.lang.c++.moderated with little response. Hoping for better from the unmoderated groups: -------- Original Message -------- Subject: Return appropriately by value, (smart)...
3
by: Divick | last post by:
I was reading this section in Bruce Eckel's book which talks about passing and returning large objects ( Chapter 11: References & the Copy-Constructor ), where he explains that how to return big...
8
by: sam | last post by:
i am starting to experiment with recursion, and decided to write a fairly trivial little program which took a float as input, then called a function to halve it recursively until it was less than...
12
by: huangshan | last post by:
hi all In what condition i need( or mast) a (templates)function return value by reference? can you give me a example thanks
21
by: Steven T. Hatton | last post by:
I'm trying to improve my formal understanding of C++. One significant part of that effort involves clarifying my understanding of the vocabulary used to describe the language. This is from the...
12
by: dave_dp | last post by:
Hi, I have just started learning C++ language.. I've read much even tried to understand the way standard says but still can't get the grasp of that concept. When parameters are passed/returned...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.