Data Types - Java | Practice | GeeksforGeeks

Working with Data Types is very important in programming world. Here, we will learn to manipulate the basic data types in Java. You will be given four different variables of different data types: a (int), b (float), c (double), l (long), d (byte). Your task is to do step-wise operations as given below:
1. Divide c by b.
2. Divide b by a.
3. Divide c by a.
4. Add result at step 3 with l.
5. Divide a by d.
Example 1:
Input:
1 2 3 5 127

Output:
1.5 2.0 3.0 8.0 0

Exaplanation:
a=1, b=2, c=3, l=5, d=127
c/b=1.5
b/a=2.0
c/a=3.0
(c/a)+l=8.0
a/d=0
Example 2:
Input:
2 4 8 16 32

Output:
2.0 2.0 4.0 20.0 0

Exaplanation:
a=2, b=4, c=8, l=16, d=32
c/b=2.0
b/a=2.0
c/a=4.0
(c/a)+l=2.0
a/d=0
User Task: 
Your task is to complete the provided function dataTypes() following the above given steps. 
Constraints:
1 <= a, b, c <= 106
1 <= d <= 127
1 <= l <= 1018
0
ravi119033852 months ago
 double p = c/b;//c/b       double q = b/a;//b/a       double r = c/a;//c/a       double m = r+l;//r+l       int s = a/d;//a/d
0
mdsaif04052 months ago
double p = c/b;
double q = b/a;
double r = c/a;
double m = r+l;
int s = a/d;

System.out.println(p+" "+q+" "+r+" "+m+" "+s);
 
+1
badgujarsachin835 months ago
static void dataTypes(int a, float b, double c, long l, byte d){
        
        double p = c/b;//c/b
        double q = b/a;//b/a
        double r =c/a ;//c/a
        double m =r+l ;//r+l
        int s =a/d ;//a/d
        
        //Printing all the results 
        System.out.println(p + " " + q + " " + r + " " + m + " " + s);
        
    }
0
प्रथमेश बोरसे1 year ago
प्रथमेश बोरसे
For coding discussion with coders all across the India
and
for any premium courses for free courses, join Indian coders on telegram HERE
0
Debojyoti Sinha2 years ago
Debojyoti Sinha
Correct Answer.Correct AnswerExecution Time:0.31
class Geeks{        // Function to do operations with different data types    static void dataTypes(int a, float b, double c, long l, byte d){                double p = c/b;//c/b        double q = b/a;//b/a        double r = c/a;//c/a        double m = r+l;//r+l        int s = a/d;//a/d                //Printing all the results         System.out.println(p + " " + q + " " + r + " " + m + " " + s);            }}
0
shourov2 years ago
shourov
class Geeks{    static void dataTypes(int a, float b, double c, long l, byte d){
        double p = c/b;//c/b        double q = b/a;//b/a        double r = c/a;//c/a        double m = r+l;//r+l        int s = a/d;//a/d
        System.out.println(p + " " + q + " " + r + " " + m + " " + s);
    }}
0
Raksha Kannu2 years ago
Raksha Kannu
simple solution
class Geeks{
    // Function to do operations with different data types    static void dataTypes(int a, float b, double c, long l, byte d){
        double p = c/b;//c/b        double q = b/a ;//b/a        double r = c/a;//c/a        double m = r+l;//r+l        int s = a/d;//a/d
        System.out.println(p + " " + q + " " + r + " " + m + " " + s);
    }}
0
Nataraja Murthy2 years ago
Nataraja Murthy
Here is Data types Explanation:
0
Taguma Tahwa3 years ago
Taguma Tahwa
https://ide.geeksforgeeks.o...HELP
0
Shubhamm Tidke3 years ago
Shubhamm Tidke
//WORKING.
class Geeks{
    // Function to do operations with different data types    static void dataTypes(int a, float b, double c, long l, byte d){
        double p = (double)c/b;        double q = (double)(b/a);//        double r = (double)c/a;//        double m = (double)r+l;//        int s = (int)a/d;//
        System.out.println(p + " " + q + " " + r + " " + m + " " + s);
    }}
We strongly recommend solving this problem on your own before viewing its editorial. Do you still
                    want to view the editorial?
 Login to access your submissions. 

Problem


Contest

Reset the IDE using the second button on the top right corner.
Avoid using static/global variables in your code as your code is tested against multiple test cases and these tend to retain their previous values.
Passing the Sample/Custom Test cases does not guarantee the correctness of code. On submission, your code is tested against multiple test cases consisting of all possible corner cases and stress constraints.
You can access the hints to get an idea about what is expected of you as well as the final solution code.
You can view the solutions submitted by other users from the submission tab.