C Program - Calculation of Area and Circumference of a Circle using Pointers

The following program is one good example that illustrates how we can return more than one value in a function. The answer is certainly using Pointers. The following program demonstrates the method.

Write a function that calculates both Area and Perimeter/ Circumference of the Circle, whose Radius is
entered through the keyboard.


#include<stdio.h>
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);

}


areaperi(int r, float *a, float *p)

{
*a=3.14*r*r;
*p=2*3.14*r;

}



//This Program exhibits the use of Call By Reference.




The program can be found at:
Download File.

Comments

surya said…
become a follower for free C,C++ And vb code of my blog:
http://www.a2zhacks.blogspot.com to learn C,C++,VB programming.

Popular posts from this blog

Matchstick Game using C Programming

Generation of Fibonacci Sequence using Recursion.