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

Who could write how to find a prime number in dynamic array?

1 Answers  


program to find magic aquare using array

4 Answers   HCL,


print a semicolon using Cprogram without using a semicolon any where in the C code in ur program!!

35 Answers   Tata Elxsi, TCS, VI eTrans,


Is there any difference between the two declarations, 1. int foo(int *arr[]) and 2. int foo(int *arr[2])

1 Answers  


There were 10 records stored in “somefile.dat” but the following program printed 11 names. What went wrong? void main() { struct student { char name[30], rollno[6]; }stud; FILE *fp = fopen(“somefile.dat”,”r”); while(!feof(fp)) { fread(&stud, sizeof(stud), 1 , fp); puts(stud.name); } }

1 Answers  






What is the subtle error in the following code segment? void fun(int n, int arr[]) { int *p=0; int i=0; while(i++<n) p = &arr[i]; *p = 0; }

1 Answers  


1 o 1 1 0 1 0 1 0 1 1 0 1 0 1 how to design this function format in c-language ?

2 Answers  


A program that will create a movie seat reservation. The program will display the summary seats and its status. The user will be ask what seat no. to be reserved, then it will go back again to the summary to display the updated seat status. If the seat no. is already reserved then it will prompt an error message. And also if the input seat no is out of range then it will also prompt an error message. The program is continuously running. Termination of the program will depends on how the programmer will apply. Sample output: Movie Seats Reservation Summary of Seats: Seat 1: Available Seat 2: Available Seat 3: Available Seat 4: Available Seat 5: Available Enter seat no. (Press 0 to terminate Or the assigned seat capacity) : 1 Movie Seats Reservation Summary of Seats: Seat 1: Reserve Seat 2: Available Seat 3: Available Seat 4: Available Seat 5: Available Enter seat no. (Press 0 to terminate Or the assigned seat capacity) : 6 The Seat no. is out of range! Movie Seats Reservation Summary of Seats: Seat 1: Reserve Seat 2: Available Seat 3: Available Seat 4: Available Seat 5: Available Enter seat no. (Press 0 to terminate Or the assigned seat capacity) : 1 The Seat no. is already reserved! Movie Seats Reservation Summary of Seats: Seat 1: Reserve Seat 2: Available Seat 3: Available Seat 4: Available Seat 5: Available Enter seat no. (Press 0 to terminate Or the assigned seat capacity) : 0 GoodBye... Thank You!!!

0 Answers  


main() { struct date; struct student { char name[30]; struct date dob; }stud; struct date { int day,month,year; }; scanf("%s%d%d%d", stud.rollno, &student.dob.day, &student.dob.month, &student.dob.year); }

1 Answers  


main() { char * strA; char * strB = I am OK; memcpy( strA, strB, 6); } a. Runtime error. b. I am OK c. Compile error d. I am O

4 Answers   HCL,


void main() { int *mptr, *cptr; mptr = (int*)malloc(sizeof(int)); printf(“%d”,*mptr); int *cptr = (int*)calloc(sizeof(int),1); printf(“%d”,*cptr); }

1 Answers  


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

2 Answers  


Categories