Thursday, 1 February 2018

Hacker Rank Basic Data Types Problem

Hacker Rank Problem

Input Format
Input consists of the following space-separated values: intlongcharfloat, 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 .
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;

}

1 comment:

  1. i have done the same but with cin and cout but i get wrong answer on different cases

    ReplyDelete

Featured post

Freecharge Recharge Hack Trick 100% Cashback