473,473 Members | 1,837 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

What is return type?how can we use it?

4 New Member
What is return type?how can we use it?
Aug 10 '10 #1
4 1507
wild wolf
5 New Member
it is so complex a question . it accords to your needs and your definition. for example ,the funtion: int salary();then it will a type of integer .
Aug 10 '10 #2
weaknessforcats
9,208 Recognized Expert Moderator Expert
The return type is used when you want your function to be an RVAL.

In this code:

Expand|Select|Wrap|Line Numbers
  1. int data = 10;
The 10 is an RVAL (the value is to the right of the = operator). data is the LVAL.

If the 10 need to be calculated, then you can use a function that returns an int:

Expand|Select|Wrap|Line Numbers
  1. int data = Calculate();
The compiler will call the function to get the int to assign to data. Calculate() is now an RVAL.
Aug 10 '10 #3
whodgson
542 Contributor
Yes...and at its simplest it is demonstrated by functions.
Expand|Select|Wrap|Line Numbers
  1. int convert(double x)
  2. {x/=12;
  3. return x;}
  4.  
double x is passed to convert(),converted to feet and returned as an int (the function type)
Aug 11 '10 #4
donbock
2,426 Recognized Expert Top Contributor
The starting point is with functions: what a function is and how it can be used. Let us know if you have questions about that.

Some languages (such as VisualBasic.NET, Pascal, Fortran, Ada) make a distinction between subroutines and functions. They consider a subroutine to be a callable block of code; while a function is a subroutine that also returns a value.

In C, both are called functions. However, a function that returns void is analogous to a subroutine.

You don't include a return value in a function definition for the fun of it -- you do it if and only if it makes sense to you for a value of some sort to be associated with the function. If you can't think of any useful value to return then define the function to return void.
Aug 11 '10 #5

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

Similar topics

5
by: Murat Tasan | last post by:
so i have a situation that i know cannot be solved directly, and i've already worked around it, but i was hoping to find an explanation as to why this behavior is as it is... i have an abstract...
2
by: Nuno Barros | last post by:
Hello, I am writting a c++ code to crete a kind of a table in memory. Each table has an container of columns, which can be of any type. To do this i created a virtual class Column which has...
59
by: Michael C | last post by:
eg void DoIt() { int i = FromString("1"); double d = FromString("1.1"); } int FromString(string SomeValue) {
31
by: CeZaR | last post by:
Hi, How can i specify the return type of a function returning a managed array of chars. If i try to write: "char __gc func()" i get an error! How can i do that? Thanks!
1
by: Thomas D. | last post by:
Hello all, I'm using the IXmlSerializable interface for a project and encounter some problems when testing my webservice in a client application. I know this interface is undocumented and not...
3
by: C++ | last post by:
According to Thinking in C++ "You cannot modify the return type of a virtual function during overriding.but there is a special case in which you can slightly modify the return type. If you¡¯re...
8
by: WakeBdr | last post by:
I'm writing a class that will query a database for some data and return the result to the caller. I need to be able to return the result of the query in several different ways: list, xml,...
3
by: Mitchel | last post by:
I'm kind of new to java & I'm trying to do a grade project called Grade.java Its suposed to make a grade book but I keep on geting 2 errors. Both say return type required. I put the error points in...
9
by: hufaunder | last post by:
I have a class "TestSuper" that implements the interface "TestBase". The interface has a property of type "ReturnType". The class "TestSuper" does not return "ReturnType" but a derivation...
18
by: Carl Forsman | last post by:
there are 2 ways to return a value from a function ==================== 1) passing a reference as parameter - the following will return time void Table::Get(char* FieldName, *SYSTEMTIME time) {...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.