Example(s):Palindrome, prime, armstrong, "linear search", reverse etc.

Example(s):1575, 1632, 1539 (Only one at a time)

Login

[lwa]

Solved Problem!
#JAVA#3852

Problem Statement - Output writing based on summation of different data types.

Summation of different data types.

TC++ #3852

Solution

Run Output

60.0

int n=12; double d=12.0; float f=12.0f; byte b=12; char c=12;
Values of different data types have been initialised.

System.out.println(n+d+f+b+c);
The summation can be done while passing as argument also. The largest of the type here will be resulted. So this sum would be 60.0 and not 60.

Common Errors

Some time students erroneously write it as 60 and not 60.0