Advertisement
Olart

C++ III Task 2 (1)

Dec 18th, 2014
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.67 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3.  
  4. int main(int argc, const char * argv[]) {
  5.    
  6.     double num1, num2, intPart1, intPart2, fractPart1, fractPart2;
  7.     std::cout << "2 Fractional Numbers Integers and Remainders calculator \n";
  8.     std::cout << "Please enter the 1st Fractional Number: \n";
  9.     std::cin >> num1;
  10.     std::cout << "Please enter the 2nd Fractional Number: \n";
  11.     std::cin >> num2;
  12.     fractPart1 = modf(num1, &intPart1);
  13.     fractPart2 = modf(num2, &intPart2);
  14.     std::cout << "Sum of Integer parts is " << intPart1 + intPart2 << std::endl;
  15.     std::cout << "Sum of Fractional parts is " << fractPart1 + fractPart2 << std::endl;
  16.  
  17.    
  18.     return 0;
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement