Basic Data Types

Sort by

recency

|

1529 Discussions

|

  • + 0 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;
    

    }

  • + 0 comments

    cannot we initialize int float etc with deceleration

  • + 0 comments

    how can I do it using cin and cout

  • + 0 comments

    Little counterintuitive, but works none the less. Simple, easily understandable code you can use (no credit)

    #include <iostream>
    #include <cstdio>
    using namespace std;
    
    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", a);
        cout << endl;
        printf("%ld", b);
        cout << endl;
        printf("%c", c);
        cout << endl;
        printf("%f", d);
        cout << endl;
        printf("%lf", e);
        cout << endl;
        return 0;
    }
    
  • + 0 comments

    C++ and C are distinct programming languages, each with its own unique features and purposes. While they can work together seamlessly when needed, they remain separate entities. Despite their compatibility and ability to complement each other in projects, they should be treated as independent languages. Maintaining their distinction preserves their individual strengths and ensures clarity in usage, even when used simultaneously.