problem is that if the user enters a number over 10, it outputs the error but then runs directly into prompting for radi, it shouldnt do this. instead i need it to ask to imput a number of circles again.
also, its not storing the radi into an array of "circleno" (the number the user entered for how many circles to calculate) length. it takes the last radi entered and runs it through the loop to calculate the circumference and area. then prints the same answers for all circles.
I cleaned up your code a bit to use some precison specifiers and a simple while loop. When in doubt about why your code is acting up, a simple print statement can go a long way. compile and run it and see what value circleno has.
Code:
#include <stdio.h>
#define PI 3.14159265
#define CONSTANT 10
int main (void)
{
int circleno,i, j;
/*circleno < CONSTANT initially so while block is evaluated first*/
while ( circleno > CONSTANT){
printf("Please enter the number of circles (max = 10):");
scanf("%i", &circleno);
}
float radius[circleno], circumference[circleno], area[circleno];
for ( j = 0; j < circleno; j++ ){
printf("Enter the radius for circle #%i:\n", j);
scanf("%f", &radius[circleno]);
printf("circleno is: %d\n", circleno);
circumference[circleno] = 2*PI*radius[circleno];
area[circleno] = PI* (radius[circleno] *radius[circleno]);
}
printf("radius circumference area \n");
printf("======================================\n");
/*notice anything?? */
printf("circle no: %d\n", circleno);
for ( i = 0; i < circleno; i++ ){
printf("%.2f %15.2f %15.2f\n", radius[circleno], circumference[circleno],
area[circleno]);
}
return 0;
}