Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3664156
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T01:36:51+00:00 2026-05-19T01:36:51+00:00

I am trying to divide integers but get 0 as result. I just do

  • 0

I am trying to divide integers but get 0 as result. I just do not understand what i am doing wrong. I am using only int’s in this example but get the same result testing with float or double.

The code i use is:

int wrongAnswers = askedQuestions - playerResult;
int percentCorrect = (playerResult / askedQuestions) * 100;
int percentWrong = (wrongAnswers / askedQuestions) * 100;


NSLog(@"askedQuestions: %i", askedQuestions);
NSLog(@"playerResult: %i", playerResult);
NSLog(@"wrongAnswers: %i", wrongAnswers);
NSLog(@"percentCorrect: %i", percentCorrect);
NSLog(@"percentWrong: %i", percentWrong);
NSLog(@"calc: %i", (wrongAnswers + playerResult));
NSLog(@"wrong answers %: %i %%", ((wrongAnswers / askedQuestions) * 100));

The result i get is:

2011-01-09 16:45:53.411 XX[8296:207] askedQuestions: 5
2011-01-09 16:45:53.412 XX[8296:207] playerResult: 2
2011-01-09 16:45:53.412 XX[8296:207] wrongAnswers: 3
2011-01-09 16:45:53.413 XX[8296:207] percentCorrect: 0 %
2011-01-09 16:45:53.414 XX[8296:207] percentWrong: 0 %
2011-01-09 16:45:53.414 XX[8296:207] calc: 5
2011-01-09 16:45:53.415 XX[8296:207] wrong answers : 0 %

I would very much appreciate help 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T01:36:52+00:00Added an answer on May 19, 2026 at 1:36 am

    Cast the division to decimal. Int divided by int will be rounded up to 0.

    percentCorrect = ((decimal) playerResult / (decimal) askedQuestions) * 100;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to divide 2 integers but the results returns zero no matter what.
I'm trying to divide two integers and multiply by 100 but it keeps giving
I'm trying to divide some integers to get a percentage. By default I get
I'm trying to understand MapReduce model and I need advice because I'm not sure
I am trying to divide an integer by a double value but i believe
I am trying to implement the following algorithm using the divide and conquer method
So I'm trying to divide a page ( in fact just a footer )
I am trying to divide arrays recursively... I think that is what this would
I'm trying to get the remainder of a division using Ruby. Let's say we're
I'm trying to divide some large numbers in Python but i'm getting some strange

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.