top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration

Facebook Login
Site Registration

C Program to Calculate Area of Circle using Pointer?

+1 vote
172 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
Contact Us
+91 9880187415
sales@queryhome.net
support@queryhome.net
#280, 3rd floor, 5th Main
6th Sector, HSR Layout
Bangalore-560102
Karnataka INDIA.
QUERY HOME
...