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

My answer should be average is 4.5       However, am I getting the

My answer should be average is 4.5       However, am I getting the

wrong average.  I keep getting (see attached photo – average is 2.888889) I am using ideone.com compiler.  C language
This is what my source code looks like: I took a screen shot of my result. It is attached.

// C code
// This program will calculate the sum of 10 positiveintegers.
// Developer: Faculty CMIS102
// Date: Jan 31,XXXX
#include
int main ()
{
/* variable definition: */
int count, value, sum,number;
double avg
;
/* Initialize
*/
count = 0;
sum = 0;
avg = 0.0;

// Loop through to input values
printf(“how many positive Integer you want to enter: \n”);
scanf(“%d”, &number);

while (count {
printf(“Enter a positive Integer\n”);

scanf(“%d”, &value);
if (value >= 0) {
sum = sum+ value;
count = count + 1;
}
else {
printf(“Value must be positive \n”);
}
}
// Calculate avg. Need to type cast since two integers will yield an integer
avg = (double) sum/count;
printf(“average is %lf\n ” , avg);
return 0;
}

Background image of page 1

Step-

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