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;
}
'software Engineering > (C++)HackerRank' 카테고리의 다른 글
[C++] HackerRank - Functions (0) | 2023.02.04 |
---|---|
[C++] HackerRank - For Loop (0) | 2023.01.24 |
[C++] HackerRank - Conditional Statements (0) | 2023.01.24 |
[C++] HackerRank - "Input and Output" (0) | 2023.01.18 |
[C++] HackerRank - "Say "Hello, World!" With C++" (0) | 2023.01.18 |