bsc

Comprehensive codebase and coursework for the 4-year B.Sc. Computer Science Honours degree (WBSU)

git clone https://github.com/notamitgamer/bsc.git
· rebuilt hourlyOpen on GitHub
root / semester_1 / practice-c / pc-ip-08.c

pc-ip-08.c (653B)


      1 /*
      2  * Question 8:
      3  * Write a program that takes the radius of a circle as input, passes it to a function that computes area and circumference, and displays results in main().
      4  */
      5 
      6 #include <stdio.h>
      7 #include <math.h>
      8 
      9 void area_circumference(double, double *, double *);
     10 
     11 int main()
     12 {
     13     double r, area, cir;
     14     printf("Enter the radius of the circle: ");
     15     scanf("%lf", &r);
     16     area_circumference(r, &area, &cir);
     17     printf("\nArea of the circle: %g", area);
     18     printf("\nCircumference of the circle: %g", cir);
     19     return 0;
     20 }
     21 
     22 void area_circumference(double r, double *area, double *cir)
     23 {
     24     *area = M_PI * r * r;
     25     *cir = 2 * M_PI * r;
     26 }