Saturday, January 5, 2019

Area of the Circle Using Pointers in C

In this article, I would like to share with you a sample program that will ask the radius of the circle and compute its area and perimeters using pointers in C.

I am currently accepting programming work, it projects, school and application development.


programming projects, thesis and capstone projects, IT consulting.

work, computer tutorials, and web development work kindly contact me in the following email address for further details.  If you want to advertise on my website kindly contact me also in my email address also. Thank you.
My email address is the following jakerpomperada@gmail.com, jakerpomperada@aol.com, and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

My telephone number at home here in Bacolod City, Negros Occidental Philippines is  +63 (034) 4335675.

Here in Bacolod I also accepting computer repair, networking and Arduino Project development at a very affordable price.

My personal website is http://www.jakerpomperada.com


Problem 

Write a program that will ask the user the radius of the circle
and then the program will compute it's area and perimeter of the circle
and display the result on the screen.

Program Listing

/* area_circle.c
   Author   : Jake Rodriguez Pomperada,BSCS,MAED-IT
   Date     : November 26, 2018  Monday  2:19 PM
   Location : Bacolod City, Negros Occidental
   Tool     : Dev C++ Version 5.11
   Website  : http://www.jakerpomperada.com
   Email    : jakerpomperada@jakerpomperada.com and jakerpomperada@gmail.com
*/

#include<stdio.h>

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

int main( )
{
int radius=0;
float area=0.00, perimeter=0.00 ;

printf("\n\n");
printf("\tArea of the Circle");
printf("\n\n");
printf ("\tEnter Radius of a Circle : " ) ;
scanf ( "%d", &radius ) ;

solve_area(radius, &area, &perimeter ) ;

printf("\n\n");
printf("\t===== DISPLAY REPORT =====");
printf("\n\n");
printf ( "\tThe Area = %.2f.", area ) ;
printf ( "\tThe Perimeter = %.2f.", perimeter ) ;
printf("\n\n");
printf("\tEnd of Program");
printf("\n\n");

}

No comments:

Post a Comment