Tuesday 26 August 2014

C Program to find out the area of a circle



C Program to find out the area of a circle
This is a C program to find out area of a circle. It will be useful to the beginners of C programming. In this example, it takes the radius of the circle as input to the program, calculates the area using the formula PI * r * r and prints the result.

See the source code of the program

/*
            Program to find out the area of a circle
            input  : raduis
            output : area
*/

# include <stdio.h>
# define PI 3.14

void main () {
            float r, area;

            clrscr();

            printf ("\nInput\n\n");
            printf ("Enter radius of the circle:");
            scanf ("%f", &r);

            area = PI * r * r;

            printf ("\nOutput\n\n");
            printf("Area of the circle is:%.2f", area);

            printf("\n\nPress any key to continue...");
            getch();
}  


Output








No comments:

Post a Comment