The initial value of the radius of a circle is equal to one unit and each succeeding radius is one unit greater than the value before it. Write a program that computes the area of the circle starting with r = 1.0 to r = 5.0. Print out each radius and the corresponding area of the circle.
#include <stdio.h>
#define PI 3.14159265f
int main() {
  float r = 1.0;
  while (r <= 5.0) {
    printf("r: %f, area: %f\n", r, PI * r * r);
    r += 1.0;
  }
  return 0;
}
Comments
Leave a comment