Basic Data Types

Sort by

recency

|

1533 Discussions

|

  • + 0 comments

    **Solution by Using Cout and Cin **

    #include <iostream>
    #include <cstdio>
    #include<iomanip>
    using namespace std;
    
    int main() {
        int int1;
        long long1;
        char char1;
        float float1;
        double double1;
        
        cin>>int1>>long1>>char1>>float1>>double1;
        
        cout<<int1<<endl;
        cout<<long1<<endl;
        cout<<char1<<endl;
        cout<<fixed<<setprecision(6)<<float1<<endl;
        cout<<fixed<<setprecision(9)<<double1;
        return 0;
    }
    
  • + 0 comments
    #include <iostream>
    #include <bits/stdc++.h>
    
    int main()
    {
    int a;
    long b;
    char c;
    float d;
    long e;
    
    cin>>a>>b>>c>>d>>e;
    cout<<a<<'\n'<<b<<'\n'<<c<<'\n'<<setprecision(10)<<d<<'\n'<<setprecision(20)<<e;  //we need precision for int precision and hidden test cases
    
    return 0;
    }
    
  • + 0 comments
    int main() {
        int a;
        long b;
        char c;
        float d;
        double e;
        scanf("%d %ld %c %f %lf", &a, &b, &c, &d, &e);
        printf("%d\n%ld\n%c\n%f\n%lf", a, b, c, d, e);
        return 0;
    }
    
  • + 0 comments

    Perhaps Hackerrank people who created this course need to pass the certification themselfs before being hired.

    This is NOT C++ this is C:

    char ch;
    double d;
    scanf("%c %lf", &ch, &d);
    
  • + 3 comments

    Two issues with this hackerrank problem, the problem statement is not having a proper start heading, so its confusing! Second, it is not even mentioned that if the candidate decides to use setprecision, they will have to add a header as well #include. So #hackerrank team, please look inot it!

    Here is the solution for the problem in c++

    include

    include

    include

    using namespace std;

    int main() { int a; long b ; char c ; float d ; double e ;

    cin>>a>>b>>c>>d>>e;
    cout <<a<<endl;
    cout <<b<<endl;
    cout <<c<<endl;
    cout <<fixed<<setprecision(3)<<d<<endl;
    cout <<fixed<<setprecision(9)<<e<<endl;
    
    return 0;
    

    }