Best writers. Best papers. Let professionals take care of your academic papers

Order a similar paper and get 15% discount on your first order with us
Use the following coupon "FIRST15"
ORDER NOW

how do you make a boolean loop where the user can determine how many

how do you make a boolean loop where the user can determine how many

number they use? for instance this code is meant to sum numbers but what ways am I able to allow the person executing the program to be able to choose how many numbers are to be executed?
int main () {
/* variable definition: */
int count;
double avg, value, weight, sum, sumw;
/* Initialize */
count = 0;
sum = 0;
sumw = 0;
avg = 0.0;
// Loop through to input values
while (count < 10) {
printf(“Enter a value and its weight: “);
// use %lf for double, %f for float
scanf(“%lf %lf”, &value, &weight);
if (weight >= 0) {
sumw = sumw + weight;
sum = sum + value * weight;
count = count + 1;
}
else {
printf(“Weight must be positive\n”);
} // end if weight ok
} // end reading input values and weights
// Calculate avg if sumw is not 0
avg = sum / sumw;
printf(“average is %lf\n ” , avg );
return 0;
} // end main

I would like to be able to enter any number in the code or allow the user to enter any number, a point in the right direction would be greatly appreciated on how to alter my boolean loop

 
Looking for a Similar Assignment? Order now and Get 10% Discount! Use Coupon Code "Newclient"