Basic Data Types Cpp - Hackerrank Solution

 

Basic Data Types in C++


Objective:

Some C++ data types, their format specifiers, and their most common bit widths are as follows:

Int ("%d"): 32 Bit integer
Long ("%ld"): 64 bit integer
Char ("%c"): Character type
Float ("%f"): 32 bit real value
Double ("%lf"): 64 bit real value


Reading
To read a data type, use the following syntax:

scanf("`format_specifier`", &val)
For example, to read a character followed by a double:

char ch;
double d;
scanf("%c %lf", &ch, &d);
For the moment, we can ignore the spacing between format specifiers.


Solution:

#include <iostream>
#include <cstdio>
using namespace std;
int main()
{
    int a;
    cin>>a;
    cout<<a<<endl;
    long int b;
    cin>>b;
    cout<<b<<endl;
    char c;
    cin>>c;
    cout<<c<<endl;
    float v;
    scanf("%f",&v);
    printf("%f\n",v);
    double r;
    scanf("%lf",&r);
    printf("%lf\n",r);

}


Note:

This Code is Verified by all Test Cases.If any error occurs then Comment correct code Below in comment box.

Disclaimer:-

The above hole problem statement is given by hackerrank.com, but the solution is generated by the CodexRitik . if any of the query regarding this post or website fill the following contact form Thank You.

Basic Data Types Cpp - Hackerrank Solution Basic Data Types Cpp - Hackerrank Solution Reviewed by CodexRitik on October 16, 2020 Rating: 5

No comments:

Powered by Blogger.