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

main() { char *p; int *q; long *r; p=q=r=0; p++; q++; r++; printf("%p...%p...%p",p,q,r); }

1 Answers  


#define max 5 #define int arr1[max] main() { typedef char arr2[max]; arr1 list={0,1,2,3,4}; arr2 name="name"; printf("%d %s",list[0],name); }

1 Answers  


#include<stdio.h> int main() { int x=2,y; y=++x*x++*++x; printf("%d",y); } Output for this program is 64. can you explain how this output is come??

1 Answers  


main() { static int var = 5; printf("%d ",var--); if(var) main(); }

1 Answers  


#include<stdio.h> main() { FILE *ptr; char i; ptr=fopen("zzz.c","r"); while((i=fgetch(ptr))!=EOF) printf("%c",i); }

1 Answers  






what is the output of the below program & why ? #include<stdio.h> void main() { int a=10,b=20,c=30; printf("%d",scanf("%d%d%d",&a,&b,&c)); }

6 Answers   CSC, IIIT,


Is the following code legal? struct a { int x; struct a b; }

1 Answers  


What are segment and offset addresses?

2 Answers   Infosys,


¦void main() ¦{ ¦int i=10,j; ¦ j=i+++i+++i; ¦printf("%d",j); ¦getch(); ¦} ¦ output:-30 but in same question if we write as- ¦void main() ¦{ ¦int i=10; ¦ int j=i+++i+++i; ¦printf("%d",j); ¦getch(); ¦} ¦ output:-33 why output is changed from 30 to 33. Can any body answer...

3 Answers  


main() { int *j; { int i=10; j=&i; } printf("%d",*j); }

9 Answers   HCL, Wipro,


char inputString[100] = {0}; To get string input from the keyboard which one of the following is better? 1) gets(inputString) 2) fgets(inputString, sizeof(inputString), fp)

1 Answers  


Is it possible to type a name in command line without ant quotes?

1 Answers   Excel, Infosys,


Categories