Trouble dividing

Hi all,

Just picked up C++ recently...first project is a simple division program that I'm having trouble with. I'm trying to get the program to tell me the length of time I should stretch/shrink a song sample to in order to have it fit the BPM of a remix/new song. I keep getting an output of "0" at the last step for some reason, though. Thanks ahead of the time for the help. I searched around but couldn't get it to work after multiple attempts.

Here's my code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include <iostream>

using namespace std;

int main()
{
  int bpmorigsong;
  int bpmproj;
  int looporig;
  int loopnew;
  float bpmratio;

  cout<<"BPM of Original Song: ";
  cin>> bpmorigsong;
  cin.ignore();
  cout<<"BPM of Project: ";
  cin>> bpmproj;
  cin.ignore();
  cout<<"Original Loop Length(ms): ";
  cin>> looporig;
  cin.ignore();
  bpmratio = bpmorigsong / bpmproj;
  loopnew = bpmratio * looporig;
  cout<<"New Loop Length (ms): "<< (bpmorigsong / bpmproj) * looporig <<"\n";
  cin.get();
}

Last edited on
If a and b are positive integers and b>a, a/b=0; this holds even if you're assigning the result to a float.
can you explain about what do you mean about "hold"?
hold = "it stays the same";
Topic archived. No new replies allowed.