C Program to return more than one value from the function using call by Reference..

#include<stdio.h>

  // Returning more than one value...

float area(float r,float *p)
{
    float a=3.14*r*r;
    *p=3.14*2*r;
    return a;
}

void main()
{
    float r,ar,pr;
    printf("\nEnter the radius..");
    scanf("%f",&r);
    ar=area(r,&pr);
    printf("\nThe area is..%f",ar);
    printf("\nThe perimeter is ..%f",pr);
}

No comments:

Post a comment