How can I return multiple values from a function?

Answer Posted / suman halder

1.we can apply "call by reference" mechanism within the
function so that multiple values get returned..

2.if the return types are homogeneous..i.e if we wanna return more than one integer values or more than one characters or any other type,then we can use an array to do that job for us as C provides various ways to return array from a function ..

*** if u try to return more than one value at a time through return statement ,last value will be returned and
all other values are ignored..
e.g
return 10,20,30;

it will only return 30

so,the most convenient way to do this is to use "call by reference" mechanism..

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Why c is a mother language?

560


How to write a code for implementing my own printf() and scanf().... Please hep me in this... I need a guidance... Can you give an coding for c... Please also explain about the header files used other than #include...

4908


What are pointers?

636


Is main an identifier in c?

607


PLS U SENS ME INTERVIEW O. MY EMAIL ADD, SOFIYA.SINGH@GMAIL.COM

1719






What are reserved words with a programming language?

606


Explain what are the different file extensions involved when programming in c?

639


What are identifiers c?

569


What is string function in c?

544


What are high level languages like C and FORTRAN also known as?

690


why arguments can generally be passed to functions a) sending the values of the arguments b) sending the addresses of the arguments c) a & b d) none of the above

647


Is there anything like an ifdef for typedefs?

708


What is a scope resolution operator in c?

754


Can main () be called recursively?

633


What are called c variables?

576