Hacker Rank Problem
Input Format
Input consists of the following space-separated values: int, long, char, float, and double, respectively.
Output Format
Print each element on a new line in the same order it was received as input. Note that the floating point value should be correct up to 3 decimal places and the double to 9 decimal places.
Sample Input
3 12345678912345 a 334.23 14049.30493
Sample Output
3
12345678912345
a
334.230
14049.304930000
Explanation
Print int ,
followed by long ,
followed by char ,
followed by float ,
followed by double .
followed by long ,
followed by char ,
followed by float ,
followed by double .
Hacker Rank Problem Solution
#include <iostream>
#include <cstdio>
using namespace std;
// Sumit Kumar
int main() {
int i;
long l;
char c;
float f;
double d;
scanf("%d %ld %c %f %lf", &i, &l , &c , &f , &d);
printf("%d \n %ld \n %c \n %f \n %5.9lf ", i , l, c , f , d);
return 0;
}
i have done the same but with cin and cout but i get wrong answer on different cases
ReplyDelete