Electrofriends

To calculate area and circumference of the circle

by Ranjith | November 6th, 2008.

Let us start from the beginning. Here discusses a model program for calculating the circumference and the area of the circle, where the radius is specified by the user.

Logic: As we know, Circumference is ‘Pi’ times diameter of the circle and Area is ‘Pi’ times the radius squared. Implementing the same is the main concept here.

Here, we  declared three floating point numbers, to scan user inputs, and to store and display the values after calculation. Displayed a note to the user to enter radius, scanned through the function which is in the included header library “stdio.h”. Area and the circumference are calculated as discussed.

#include<stdio.h>
void main()
{
float area, radius, circum;
clrscr();
printf(“\n\n\t ENTER THE RADIUS OF THE CIRCLE…:”);
scanf(“%f”, &radius);
area = 3.142 * radius * radius;
circum = 2 * 3.142 * radius;
printf(“\n\n\t THE AREA OF THE CIRCLE IS…: %f”, area);
printf(“\n\n\t THE CIRCUMFERENCE OF THE CIRCLE IS…: %f\n”, circum);
getch();
}


Share and Enjoy:
  • Digg
  • Technorati
  • StumbleUpon
  • Twitter
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • Reddit
  • Mixx
  • Yahoo! Buzz
  • LinkedIn
  • NewsVine
  • RSS
  • email
Similar Posts:

Leave a Reply

Share and enjoy

    • Digg
    • Facebook
    • Technorati
    • StumbleUpon
    • Twitter
    • Reddit
    • del.icio.us
    • Yahoo! Buzz
Copyright©2009 www.electrofriends.com All Rights Reserved. Powered by Dhyeya