how to return a multiple value from a function?
Answers were Sorted based on User's Feedback
#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 |
Answer / ara
string f()
{
return "a multiple value";
}
:) if this a trick question ...
| Is This Answer Correct ? | 1 Yes | 4 No |
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 |
void main() { int i=5; printf("%d",i+++++i); }
What are the files which are automatically opened when a C file is executed?
Write a C program to print ‘Campus Force training’ without using even a single semicolon in the program.
void main() { int i=i++,j=j++,k=k++; printf(“%d%d%d”,i,j,k); }
main() { register int a=2; printf("Address of a = %d",&a); printf("Value of a = %d",a); }
Give a oneline C expression to test whether a number is a power of 2?
25 Answers EA Electronic Arts, Google, Motorola,
main() { void swap(); int x=10,y=8; swap(&x,&y); printf("x=%d y=%d",x,y); } void swap(int *a, int *b) { *a ^= *b, *b ^= *a, *a ^= *b; }
What are the following notations of defining functions known as? i. int abc(int a,float b) { /* some code */ } ii. int abc(a,b) int a; float b; { /* some code*/ }
#define prod(a,b) a*b main() { int x=3,y=4; printf("%d",prod(x+2,y-1)); }
main() { char *cptr,c; void *vptr,v; c=10; v=0; cptr=&c; vptr=&v; printf("%c%v",c,v); }
Is the following code legal? typedef struct a { int x; aType *b; }aType
Is the following code legal? struct a { int x; struct a b; }