how to return a multiple value from a function?

Answers were Sorted based on User's Feedback



how to return a multiple value from a function?..

Answer / yogesh

#include<stdio.h>
#define PI 3.1415
int main()
{
double area,perimeter,radius;
printf("Enter radius of Circle:");
scanf("%lf",$radius);
calculate(&area,&perimeter,radius);
printf("Area of Circle:%lf\nPerimeter of
Circle:%lf",area,perimeter);
}
calculate(double *a,double *p,double r)
{
*a=PI*r*r;
*p=2*PI*r;
}

Is This Answer Correct ?    3 Yes 0 No

how to return a multiple value from a function?..

Answer / chandu

using call by refernce

Is This Answer Correct ?    4 Yes 2 No

how to return a multiple value from a function?..

Answer / shruti

use call by refrance..-> pointers.

Is This Answer Correct ?    0 Yes 1 No

how to return a multiple value from a function?..

Answer / ara

string f()
{
return "a multiple value";
}

:) if this a trick question ...

Is This Answer Correct ?    1 Yes 4 No

how to return a multiple value from a function?..

Answer / vinayakkatkar

using if else statement
for example
int fun()
{
if(cond1)
return var1;
else
return var2;

}

Is This Answer Correct ?    1 Yes 7 No

Post New Answer

More C Code Interview Questions

write a program to find out roots of quadratic equation "x=-b+-(b^2-4ac0^-1/2/2a"

2 Answers  


Derive expression for converting RGB color parameters to HSV values

1 Answers  


posted by surbhi just now main() { float a = 5.375; char *p; int i; p=(char*)&a; for(i=0;i<=3;i++) printf("%02x",(unsigned char) p[i]); } how is the output of this program is :: 0000ac40 please let me know y this output has come

2 Answers   GATE,


Given an array of characters which form a sentence of words, give an efficient algorithm to reverse the order of the words (not characters) in it.

2 Answers   Wipro,


main() { clrscr(); } clrscr();

2 Answers  






In the following pgm add a stmt in the function fun such that the address of 'a' gets stored in 'j'. main(){ int * j; void fun(int **); fun(&j); } void fun(int **k) { int a =0; /* add a stmt here*/ }

1 Answers  


main() { if (!(1&&0)) { printf("OK I am done."); } else { printf("OK I am gone."); } } a. OK I am done b. OK I am gone c. compile error d. none of the above

3 Answers   HCL,


What is the main difference between STRUCTURE and UNION?

13 Answers   HCL,


struct point { int x; int y; }; struct point origin,*pp; main() { pp=&origin; printf("origin is(%d%d)\n",(*pp).x,(*pp).y); printf("origin is (%d%d)\n",pp->x,pp->y); }

1 Answers  


What are segment and offset addresses?

2 Answers   Infosys,


#include<stdio.h> main() { struct xx { int x; struct yy { char s; struct xx *p; }; struct yy *q; }; }

2 Answers  


Which version do you prefer of the following two, 1) printf(ā€œ%sā€,str); // or the more curt one 2) printf(str);

1 Answers  


Categories