Digital जीवन

Free Online Education for India...

Full width home advertisement

Computer Basic

C Programming

Engineering Graphics

Post Page Advertisement [Top]

Dr. A.P.J. Abdul Kalam Technical University, Lucknow

KCS101 / KCS201 Programming for Problem Solving - Using C Language


Lab Exercises


3. Write a program to calculates the area and circumference of a circle.


/*
 File: Prgrm03.c
 Author: Aditya Saini
 Date: Sept 11, 2019
 Description: Program to calculate the area and circumference of a circle.
*/

#include <stdio.h>

int main (void)
{
               float radius;
               float circumference;
               float area;
               const float PI = 3.1415;

               //Input radius of circle.
               printf ("Input Radius of Circle: ");
               scanf ("%f", &radius);

               //Calculate area and circumference.
               area = PI * radius * radius;
               circumference = 2.0 * PI * radius;

               //Output the result
               printf ("Area of Circle: %.4f\n", area);
               printf ("Circumference of Circle: %.4f ", circumference);

               return 0;
};

Output

Input Radius of Circle: 15.45
Area of Circle: 749.8839
Circumference of Circle: 97.0723



No comments:

Post a Comment

Please do not post spam links.

Bottom Ad [Post Page]

| Designed by Colorlib