hi guys. been workin on this program for a while now and i cant seem to get it to output correctly. i know somethings wrong with my loop and my array...just need some direction and what not.
the program asks the user how many circles to calculate (between 1 and 10). then it takes that imput and begins to ask for a radi for each. after that, the program puts the imputed radi through a couple equations to calculate circumference and area and prints the results.
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 appreciate the help.
Code:#include <stdio.h>
#define PI 3.14159265
#define CONSTANT 10
int main (void)
{
int circleno;
int j;
int i;
printf("Please enter the number of circles (max = 10):\n");
scanf("%i", &circleno);
float radius[circleno];
float circumference[circleno];
float area[circleno];
if ( circleno > CONSTANT )
printf("Error -> %i circles is to many. Please try again:\n", circleno );
else
for ( j = 1; j <= circleno; ++j ) {
printf("Enter the radius for circle #%i:\n", j);
scanf("%f", &radius[circleno]);
circumference[circleno] = 2*PI*radius[circleno];
area[4] = PI*radius[circleno]*radius[circleno];
}
printf("radius circumference area \n");
printf("======================================\n");
for ( i = 1; i <= circleno; ++i ) {
printf("%f %f %f \n", radius[circleno], circumference[circleno], area[circleno]);
}
}
