Hanwool Codes RSS Tag Admin Write Guestbook
2023-01-22 18:00:34

Basic Data Types | HackerRank

 

Basic Data Types | HackerRank

Learn about the basic data types in C++. Take the given input and print them.

www.hackerrank.com

 

Goal

1. Read space-seprated values : int, long, char, float and double, respectively

2. Print each element on a new line in the same order it was received as input. + correct decimal points of floating and double points.

 

 

Solution

Follow HackerRank explanation of c++ data types and their format specifiers.

// Basic Data Types

#include <iostream>
#include <cstdio>
using namespace std;

int main() {
    // Complete the code.
    int a;
    long b;
    char c;
    float d;
    double e;

    scanf("%d %ld %c %f %lf", &a, &b, &c, &d, &e);
    printf("%d\n", a);
    printf("%ld\n", b);
    printf("%c\n", c);
    printf("%f\n", d);
    printf("%lf\n", e);
    return 0;
}
Hanwool Codes. Designed by 코딩재개발.