top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

C Program to Calculate Area of Circle using Pointer?

+1 vote
914 views
C Program to Calculate Area of Circle using Pointer?
posted Dec 2, 2014 by Vinitha

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

+3 votes
#include<stdio.h>

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

void main( )
{
   int radius ;
   float area, perimeter ;
clrscr();
   printf ( "nEnter radius of a circle " ) ;
   scanf ( "%d", &radius ) ;

   func( radius, &area, &perimeter ) ;

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

Output

Enter radius of a circle 5
Area = 78.500000
Perimeter = 31.400000
answer Dec 2, 2014 by Shivaranjini
...