We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Day 1: Data Types
Day 1: Data Types
Sort by
recency
|
3911 Discussions
|
Please Login in order to post a comment
If you are using JS you can give a try. Let me know if there are any other better ways.
// Declare second integer, double, and String variables. var num,double,string // Read and save an integer, double, and String to your variables.
console.log(i+num); // Print the sum of the double variables on a new line. console.log((d+decimal).toFixed(1)); // Concatenate and print the String variables on a new line console.log(s+text);
Em python: It took me a while to notice that what they would be using the imput() function
i = 4 d = 4.0 s = 'HackerRank '
ii = input() dd= input() ss= input()
ii = int(ii) dd=float(dd) ss=str(ss)
print(int(i)+ii) variables on a new line. print(float(d)+dd) printed first. print(str(s) + ss)
What is wrong? Mine is in C
int secondI; float secondD; char s2[100];
scanf("%d", &secondI); scanf("%1f", &secondD); scanf("%s", s2);
printf("%d\n",i + secondI);
printf("%.1f\n", d + secondD);
printf("%s%s\n", s, s2);
import java.io.; import java.util.;
public class Solution {
}
Hello,
This is the backstory. When I 'Run Code', my "Sample Test case 0" is correct. When I "Submit Code", I get the wrong answer on "Test case 1".
i = 4 d = 4.0 s = 'HackerRank '
Declare second integer, double, and String variables.
i2 = 12 d2 = 4.0 s2 = 'is the best place to learn and practice coding!'
Read and save an integer, double, and String to your variables.
i3 = i + i2 d3 = d + d2 s3 = s + s2
Print the sum of both integer variables on a new line.
print(i3)
Print the sum of the double variables on a new line.
print(d3)
Concatenate and print the String variables on a new line
print(s3)
The 's' variable above should be printed first.