About Me

My photo
Raipur, Chhattisgarh, India
Hi , I am Amit Thakur. I have worked as a QA Engineer for two years and as a Java Developer for one year in NIHILENT TECHNOLOGIES PVT. LTD., Pune.Currently I am working as DEAN (Research & Development) in Bhilai Institute of Technology, Raipur.

Tuesday, August 27, 2013

Calculate Area of Circle using Pointer :


#include<stdio.h>

void areaperi ( int r, float *a, float *p )
{
*a = 3.14 * r * r ;
*p = 2 * 3.14 * r ;
}

void main( )
{
int radius ;
float area, perimeter ;

printf ( "Enter radius of a circle " ) ;
scanf ( "%d", &radius ) ;

areaperi ( radius, &area, &perimeter ) ;

printf ( "Area = %f", area ) ;
printf ( "Perimeter = %f", perimeter ) ;
}

Output:

Enter radius of a circle 5
Area = 78.500000
Perimeter = 31.400000

No comments: