in order to return more than one values from a single function we , intelligently need to make use of pointers..!!!
an example using pointers is illustrated below...
#include"header files"
void main()
{
int radius;
float area,perimeter;
printf("\n enter the radius of the circle");
scanf("%d",&radius);
areaperi(radius,&area,&perimeter)//we pass the refernce of the area and perimeter
printf("area=%f",area);
printf("\nperimeter=%f",perimeter);
}
areaperi(int r,int *a,int *p)
{
*a=3.14*r*r;
*p=2*3.14*r;
}
outut----
enter radius of the circle=5
area=78.500000
perimeter=31.40000
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment