Click here to Skip to main content
15,917,568 members
Please Sign up or sign in to vote.
1.00/5 (4 votes)
See more:
Hi
the number is 8652
I want the average like (8+6+5+2)/4

can any one help me
Posted
Comments
Sandeep Mewara 23-Sep-10 6:13am    
No effort.

Try here[^].
 
Share this answer
 
See here[^].
 
Share this answer
 
Comments
#realJSOP 27-Sep-10 15:41pm    
I thibnk my answer was more appropriate.
Abhinav S 28-Sep-10 0:14am    
You hold the AR-15. You win. :)
int count=0;
int number=8652;
int sum=0;
int remainder=0;
while(number>0)
{
remainder=number%10;
sum=sum+remainder;
count=count+1;// we r incrementing this count to get total no of digits
number=number/10;
}

float average=(float)sum/count;
 
Share this answer
 
v6
Comments
AspDotNetDev 27-Sep-10 15:51pm    
FYI, I think you mean "remainder", not "reminder".
amyjust4u 1-Oct-10 1:13am    
thnks for pointing out my mistake i corrected it
Richard MacCutchan 1-Oct-10 5:02am    
No, it still says #Quote#reminder#Quote#.
amyjust4u 4-Oct-10 8:43am    
I think u shud focus more on logic n not on spellings.As such the one who ws looking foranswer ,got the answer.
Richard MacCutchan 4-Oct-10 9:47am    
If the spelling is wrong it is just as likely that the program will fail.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900