c program return statement returns more than one value
>> Wednesday, November 2, 2011
This program makes a contrasting concept that how a return statement
can return more than one value. Usually in C programming we make a call by value.
This means that in general you cannot alter the actual arguments. But if
desired, it can always be achieved through a call by reference.
Using a call by reference intelligently we can make a function
return more than one value at a time, which is not possible
ordinarily. This is shown in the program given below.
Output :
can return more than one value. Usually in C programming we make a call by value.
This means that in general you cannot alter the actual arguments. But if
desired, it can always be achieved through a call by reference.
Using a call by reference intelligently we can make a function
return more than one value at a time, which is not possible
ordinarily. This is shown in the program given below.
#include<stdio.h>
#include<conio.h>
int areaperi ( int r, float *a, float *p )
{
*a = 3.14 * r * r ;
*p = 2 * 3.14 * r ;
return (0);
}
int main( )
{
int radius ;
float area, perimeter ;
printf ( "\nEnter radius of a circle " ) ;
scanf ( "%d", &radius ) ;
areaperi ( radius, &area, &perimeter ) ;
printf ( "Area = %f", area ) ;
printf ( "\nPerimeter = %f", perimeter ) ;
getch();
}
Output :
C porgram to return more than one value. |
0 comments:
Post a Comment