fork download
  1. #include <iostream>
  2. #include <iomanip>
  3. #include <limits>
  4.  
  5. using namespace std;
  6.  
  7. int main() {
  8. int i = 4;
  9. double d = 4.0;
  10. string s = "HackerRank ";
  11.  
  12.  
  13. // Declare second integer, double, and String variables.int x;
  14. int x;
  15. double y;
  16. string str;
  17. // Read and save an integer, double, and String to your variables.
  18. std::cin >> x;
  19. std::cin >> y;
  20. std::cin.ignore();
  21. getline(std::cin, str);
  22.  
  23. // Note: If you have trouble reading the entire string, please go back and review the Tutorial closely.
  24.  
  25. // Print the sum of both integer variables on a new line.
  26. cout << x + i << endl;
  27. // Print the sum of the double variables on a new line.
  28. std::cout << std::fixed;
  29. std::cout << std::setprecision(1);
  30. cout << y + d << endl;
  31. // Concatenate and print the String variables on a new line
  32. // The 's' variable above should be printed first.
  33. cout << s + str << endl;
  34.  
  35. return 0;
  36. }
Success #stdin #stdout 0s 4484KB
stdin
12
4.0
is the best place to learn and practice coding!
stdout
16
8.0
HackerRank is the best place to learn and practice coding!