# dividing by any numbers = 4354302

• (2 Pages)
• 1
• 2

## 22 Replies - 894 Views - Last Post: 03 February 2018 - 07:27 PMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'http://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=409100&amp;s=c954699b81a5cb751902c5657aeb7d85&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 kianyt

Reputation: 0
• Posts: 17
• Joined: 03-February 18

# dividing by any numbers = 4354302

Posted 03 February 2018 - 04:15 PM

Hi, i am trying to make a basic dividing code, but no matter what numbers i use the output is 4354302, can anyone help

```
#include <iostream>
#include <cstdlib>
#include <iomanip>

using namespace std;

int main()
{

int totalReviews;
int positiveReviews;
int percentagePositive;

cin >> totalReviews;

cin >> positiveReviews;

percentagePositive == positiveReviews / totalReviews;

cout << percentagePositive << endl;

return 0;
}

```

Is This A Good Question/Topic? 0

## Replies To: dividing by any numbers = 4354302

### #2 modi123_1

• Suitor #2

Reputation: 13752
• Posts: 54,912
• Joined: 12-June 08

## Re: dividing by any numbers = 4354302

Posted 03 February 2018 - 04:17 PM

Remember == and = are different.

== is used to compare two objects and returns a boolean.
= is for assignment.

You should also think about the results.. integers are whole numbers - so no decimal points. Any remainders may be missing.

### #3 kianyt

Reputation: 0
• Posts: 17
• Joined: 03-February 18

## Re: dividing by any numbers = 4354302

Posted 03 February 2018 - 04:18 PM

OK i changed it and now it just outputs 0, any ideas?

### #4 modi123_1

• Suitor #2

Reputation: 13752
• Posts: 54,912
• Joined: 12-June 08

## Re: dividing by any numbers = 4354302

Posted 03 February 2018 - 04:22 PM

What numbers are you using?
Did you look into something that may show a remainder? Again, integers are whole numbers.

### #5 kianyt

Reputation: 0
• Posts: 17
• Joined: 03-February 18

## Re: dividing by any numbers = 4354302

Posted 03 February 2018 - 04:24 PM

just for now i used 100 and 80, just to test as it is very easy, but 0, and if i change positiveReviews to float it makes no difference, still 0

### #6 modi123_1

• Suitor #2

Reputation: 13752
• Posts: 54,912
• Joined: 12-June 08

## Re: dividing by any numbers = 4354302

Posted 03 February 2018 - 04:29 PM

Let's see the current code.

### #7 kianyt

Reputation: 0
• Posts: 17
• Joined: 03-February 18

## Re: dividing by any numbers = 4354302

Posted 03 February 2018 - 04:30 PM

here you go
```#include <iostream>
#include <cstdlib>
#include <iomanip>

using namespace std;

int main()
{

int totalReviews;
int positiveReviews;
float percentagePositive;

cin >> totalReviews;

cin >> positiveReviews;

percentagePositive = positiveReviews / totalReviews;

cout << "Your percentage of positive results is " << percentagePositive << endl;

return 0;
}

```

### #8 modi123_1

• Suitor #2

Reputation: 13752
• Posts: 54,912
• Joined: 12-June 08

## Re: dividing by any numbers = 4354302

Posted 03 February 2018 - 04:33 PM

Think about casting your division problem to a float while assigning it to the float.

### #9 kianyt

Reputation: 0
• Posts: 17
• Joined: 03-February 18

## Re: dividing by any numbers = 4354302

Posted 03 February 2018 - 04:41 PM

Ok i fixed it by doing that, here is the current code.
Now I would like to be able to tell the user how many more positive reviews they would need to have a 90% positive review percentage, but it would need to be of the new percentage, not of the old. for example if a user had 80 positive reviews out of 100 total reviews, it would tell him that he needs a minimum of 100 more positive reviews to get a 90% positive review rate. I have no idea how to do that, and would be great if i could get some pointers

```#include <iostream>
#include <cstdlib>
#include <iomanip>

using namespace std;

int main()
{

int totalReviews;
int positiveReviews;
float percentagePositive;

cin >> totalReviews;

cin >> positiveReviews;

percentagePositive = (float)positiveReviews / (float)totalReviews;

cout << "Your percentage of positive results is " << percentagePositive*100 << endl;

return 0;
}

```

### #10 modi123_1

• Suitor #2

Reputation: 13752
• Posts: 54,912
• Joined: 12-June 08

## Re: dividing by any numbers = 4354302

Posted 03 February 2018 - 04:47 PM

It's an algebra equation.

Now:
percent = positive / total

If you want positive, but have a percent and total how would you go about solving for positive?

### #11 kianyt

Reputation: 0
• Posts: 17
• Joined: 03-February 18

## Re: dividing by any numbers = 4354302

Posted 03 February 2018 - 04:54 PM

I understand that but say if someone has 80/100, and they get 10 more positive, it wont be 90/100, it will be 90/110, so 81.8%, so I need to write a line of code that will tell a user how many more positive they need for 90%, which in this case would be 100, as 180/200 is 90%

### #12 tony jay

Reputation: 17
• Posts: 42
• Joined: 31-January 18

## Re: dividing by any numbers = 4354302

Posted 03 February 2018 - 05:15 PM

Your problem is not coding currently.
If you can do the maths on the back of an envelope, then coding the resultant equation is trivial.

So sit down with pen and paper and solve the problem there...

### #13 kianyt

Reputation: 0
• Posts: 17
• Joined: 03-February 18

## Re: dividing by any numbers = 4354302

Posted 03 February 2018 - 05:20 PM

oh forgot to update, I've got it finished now

### #14 tony jay

Reputation: 17
• Posts: 42
• Joined: 31-January 18

## Re: dividing by any numbers = 4354302

Posted 03 February 2018 - 05:22 PM

Well done!

You seem to be having a busy day today...

### #15 kianyt

Reputation: 0
• Posts: 17
• Joined: 03-February 18

## Re: dividing by any numbers = 4354302

Posted 03 February 2018 - 05:25 PM

yeah, starting 11th grade CIT (coding / computer study), and want to get as far into it as I can during the long weekend that i have

thanks for help all