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

How to reverse a String without using C functions ?

33 Answers   Matrix, TCS, Wipro,


main(){ char a[100]; a[0]='a';a[1]]='b';a[2]='c';a[4]='d'; abc(a); } abc(char a[]){ a++; printf("%c",*a); a++; printf("%c",*a); }

2 Answers  


main(int argc, char **argv) { printf("enter the character"); getchar(); sum(argv[1],argv[2]); } sum(num1,num2) int num1,num2; { return num1+num2; }

1 Answers  


Ramesh’s basic salary is input through the keyboard. His dearness allowance is 40% of basic salary, and house rent allowance is 20% of basic salary. Write a program to calculate his gross salary.

1 Answers  


main() { char *p="hai friends",*p1; p1=p; while(*p!='\0') ++*p++; printf("%s %s",p,p1); }

3 Answers  






write a simple calculator c program to perform addition, subtraction, mul and div.

0 Answers   United Healthcare, Virtusa,


how to programme using switch statements and fuctions, a programme that will output two even numbers, two odd numbers and two prime numbers of the users chioce.

0 Answers   Mbarara University of Science and Technology,


main(){ int a= 0;int b = 20;char x =1;char y =10; if(a,b,x,y) printf("hello"); }

1 Answers   TCS,


Find your day from your DOB?

15 Answers   Accenture, Microsoft,


main() { int i=5,j=6,z; printf("%d",i+++j); }

2 Answers  


main() { int i; printf("%d",scanf("%d",&i)); // value 10 is given as input here }

2 Answers   IBM,


Write a program to receive an integer and find it's octal equivalent. How can i do with using while loop.

2 Answers  


Categories