Basic Data types | HackerRank Solution...

                Basic data types Solution



Input Format

Input consists of the following space-separated values: intlongcharfloat, 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

Popular posts from this blog

There are three people sitting in a room - Alice, Bob, and Charlie. They need to decide on the temperature to set on the air conditioner. Everyone has a demand each:

Using HTML CSS and JavaScript Create a Responsive Personal Portfolio Website Design