Answer to Question #265563 in C++ for Usama

Question #265563

Write a program in C++ that stores the numerator and denominator of two numbers infraction, after adding them the result is also stored into fraction format. Use structure fraction to store these numbers and their result (Bothnumeratoranddenominatorshouldbeof type int).



1
Expert's answer
2021-11-22T15:17:53-0500
#include <iostream>

struct frac {
 int dominator;
 int numerator;
 double value;
};

int main() {
  struct frac frac;
  std::cin >> frac.numerator;
  std::cin >> frac.dominator;
  frac.value = 1.0 * frac.numerator / frac.dominator;
  std::cout << frac.value;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS