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);
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);
circumference = 2.0 * PI * radius;
//Output the result
printf ("Area of Circle: %.4f\n", area);
printf ("Circumference of Circle: %.4f ", circumference);
};
Output
Input Radius of Circle: 15.45
Area of Circle: 749.8839
Circumference of Circle: 97.0723
Area of Circle: 749.8839
Circumference of Circle: 97.0723
No comments:
Post a Comment
Please do not post spam links.