Get started today!

Good to have you back!
If you've signed in to StudyBlue with Facebook in the past, please do that again.

- StudyBlue
- Wisconsin
- University of Wisconsin - Eau Claire
- Computer Science
- Computer Science 163
- Ernst
- C++ Programming- Divide and Multiply Fractions

Taylor J.

#include #include using namespace std; struct fraction // the structure { int num; int denom; bool positive; }; void multiply_frac (fraction *f1, fraction *f2, fraction *f3) // for multiplying { f3->num = f1->num * f2->num; f3->denom = f1->denom * f2->denom; } void div_frac (fraction *f1, fraction *f2, fraction *f3) // for dividing { f3->num = f1->num * f2->denom; f3->denom = f1->denom * f2->num; } int main() { fraction f1; fraction f2; fraction fresult; char tempchar; bool positive1 = true; bool positive2 = true; // you need 2 positives, for fraction 1 and fraction 2 cout << "Input the first numerator." << endl; cin >> f1.num; cout << "Input the first denominator." << endl; cin >> f1.denom; cout << "Is the fraction positive? (Y/N)" << endl; cin >> tempchar; if (tempchar == 'Y') positive1 = true; else { if (tempchar == 'N' ) positive1 = false; else { cout<<" The program will assume the fraction is positive"<> f2.num; cout << "Input the second denominator." << endl; cin >> f2.denom; cout << "Is the fraction positive? (Y/N)" << endl; cin >> tempchar; if (tempchar == 'Y') positive2 = true; else { if (tempchar == 'N' ) positive2 = false; else { cout<<"You must type Y or N .The program will assume the fraction is positive"<

Advertisement
)

Advertisement

"StudyBlue is great for studying. I love the study guides, flashcards and quizzes. So extremely helpful for all of my classes!"

Alice , Arizona State University"I'm a student using StudyBlue, and I can 100% say that it helps me so much. Study materials for almost every subject in school are available in StudyBlue. It is so helpful for my education!"

Tim , University of Florida"StudyBlue provides way more features than other studying apps, and thus allows me to learn very quickly!Â I actually feel much more comfortable taking my exams after I study with this app. It's amazing!"

Jennifer , Rutgers University"I love flashcards but carrying around physical flashcards is cumbersome and simply outdated. StudyBlue is exactly what I was looking for!"

Justin , LSU