forked from xeoneux/30-Days-of-Code
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSolution.cpp
40 lines (29 loc) Β· 872 Bytes
/
Solution.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include <iostream>
using namespace std;
int main() {
int i = 4;
double d = 4.0;
string s = "HackerRank ";
// Declare second integer, double, and String variables.
int i2;
double d2;
string s2;
// Read and save an integer, double, and String to your variables.
string tmp;
getline(cin, tmp);
i2 = stoi(tmp);
getline(cin, tmp);
d2 = stod(tmp);
getline(cin, s2);
// Print the sum of both integer variables on a new line.
i=i+i2;
cout<<i<<endl;
// Print the sum of the double variables on a new line.
// Used setprecision(1) to get at least 1 digit after decimal point
d=d+d2;
cout<<fixed<<setprecision(1)<<d<<endl;
// Concatenate and print the String variables on a new line
// The 's' variable above should be printed first.
cout << s << s2 << endl;
return 0;
}