question: enter a number, find number of even factor and expressed as percentage
i have type in the code and compiled it sucessfully. But the reuslt wasn't expected (always come as 0). Can someone please help to solve the problem. I am using a blood shed dev cpp ver 4.01.
Here is my code
Code:int c(int day) //find the even factor of day and expressed as percentage //pre: day>0 //post: return percentage { int eFactor;//even factor int tFactor;//total factor int i;//control variable int percent;//express as percentage //initialization eFactor = 0; tFactor = 0; for (i=1; i<=num; i++) { if (num%i==0) { tFactor++; if (i%2==0) eFactor++; }//end if }//end loop percent = (eFactor / tFactor)* 100; return percent; }//end c



LinkBack URL
About LinkBacks


