Advertisement
Spocoman

10. Multiply by 2

Sep 6th, 2023
758
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.31 KB | None | 0 0
  1. #include <iostream>
  2. #include<iomanip>
  3.  
  4. using namespace std;
  5.  
  6. int main() {
  7.     double number;
  8.  
  9.     while (true) {
  10.         cin >> number;
  11.  
  12.         if (number >= 0) {
  13.             cout << "Result: " << fixed << setprecision(2) << number * 2 << endl;
  14.         }
  15.         else {
  16.             cout << "Negative number!";
  17.             break;
  18.         }
  19.     }
  20.  
  21.     return 0;
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement