C program to calculate area and perimeter of a Cirlce…!!!

In our earlier post we calculated the area and perimeter of a circle.In this post we are dealing with calculating the area and perimeter of a circle.

The main input for calculating area and perimeter of a circle is radius of the circle.We use the datatype float to store the radius of the circle.The formula to find the area of the circle is 3.14*r*r and the formula to find perimeter of the circle is 2*3.14*radius.After calculating the area and perimeter we need to display the results to the user.

#include<stdio.h>
#include<conio.h>
void main()
{
  float radius,area,perimeter;  //variable to store radius,area and perimeter
  clrscr();
  printf("\nEnter the radius of the circle:");
  scanf("%f",&radius);
  area = 3.14*radius*radius;
  perimeter = 2*3.14*radius;
  printf("\nArea of the given cirlce is:%f",area);
  printf("\n\nPerimeter of the given circle is:%f",perimeter);
  getch();
}

OUTPUT:
cirareaperi
You can download the program:download
If you have any doubts you can place them in comments.

Advertisement

About Anuroop D

Very enthusiastic about technology and likes to share my knowledge through blogging. Has Bachelor's in Information Technology and currently pursuing my PhD in Computer Science.
This entry was posted in C and tagged , , , , . Bookmark the permalink.

4 Responses to C program to calculate area and perimeter of a Cirlce…!!!

  1. Monia says:

    dont we have to initialize the variables we have taken??

    • Anuroop D says:

      No need to intialize the variables……Because we are requesting new value radius and after multiplication new value for area and new value for perimeter are assigned.

      Hope it helps

  2. The area of perimeter is a good modificatin programmer in progam.

  3. kelvin says:

    it real helped

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s