Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

simple percentange Calculation

Tags:

objective-c

Please take a look at the following code and tell me why skillPercentange is always Zero:

NSInteger skillPercentange;
skillPercentange=totalCorrectAns * reloader/100;
like image 453
sohel14_cse_ju Avatar asked Mar 02 '26 04:03

sohel14_cse_ju


1 Answers

I don't know exactly what you want to do, but I'll try to show you a demo:

int allQuestions = 50;
int correctAnswers = 25;
float precentage = (100 * correctAnswers)/allQuestions;
NSLog("%i of %i questions answered correctly. That are %.1f percent!",correctAnswers,allQuestions,precentage);

Output: "25 of 50 questions answered correctly. That are 50.0 percent!"

like image 69
Fabio Poloni Avatar answered Mar 04 '26 18:03

Fabio Poloni



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!