A Learning Platform

SUCCESS

Success = Discipline + Consistency + Sacrifice.
Discipline - in what you do.
Consistency - in what you do.
Sacrifice - for what you do.

                   -- Manjunatha C. P. --

C Program: Area and Circumference of Circle

C Program to calculate Area and Circumference of circle when radius is given


Description:

In this program we are going to find the area and perimeter or circumference of circle without using functions.


PI = 3.14

r = radius of the circle.

a = area of the circle.

c = circumference of the circle.

Below formulae are used to calculating the area and circumference of the circle.


a = PI * r * r

c = 2 * PI * r


Algorithm to find area and circumference of circle:


STEP 1: START

STEP 2: INITIALIZE value of PI

              PI=3.14

STEP 3: Read the value of radius

              READ r

STEP 4: CALUCATE area and circumference of Circle

              a = PI * r * r

              c = 2 * PI * r

STEP 5: Print the values of area and circumference

              PRINT a, c

STEP 6: END


Program to calculate area and circumference without using functions:


#include<stdio.h>

#include<conio.h>

int main() {

    float r;

    float PI = 3.14, a, c;

    printf("Enter radius of circle:");

    scanf("%f", &r);

    a = PI * r * r;

    c = 2 * PI * r;

    printf("\nArea of circle : %f ", a);

    printf("\nCircumference of circle : %f ", c);

    getch();

    return 0;

}


Output:


Enter radius of circle : 3


Area of circle : 28.260000

Circumference of circle : 18.840000