Find Area and perimeter of circle in c code
#include
#include
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();
}
Find Area and perimeter of circle in c code. This c 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 c program find area and perimeter of circle given below.
Find Area and perimeter of circle in c code
#include
#include
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 ) ;