Basic Data types | HackerRank Solution...
Basic data types Solution
Input Format
Input consists of the following space-separated values: int, long, char, float, and double, respectively.
Output Format
Print each element on a new line in the same order it was received as input. Note that the floating-point value should be correct up to 3 decimal places and the double to 9 decimal places.
#include <iostream>
#include <cstdio>
#include <iomanip>
using namespace std;
int main() {
// Complete the code.
int a;
long int ld;
char ch;
float f;
double lf;
cin >> a;
cin >> ld;
cin >> ch;
cin >> f;
cout << setprecision(3);
cin >> lf;
cout << setprecision(9);
cout << a <<endl;
cout << ld <<endl;
cout << ch <<endl;
cout << f <<endl;
cout << lf <<endl;
return 0;
}
Comments
Post a Comment