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
|
3975 Discussions
|
Please Login in order to post a comment
//in c
include
include
include
include
int main() { int i = 4; double d = 4.0; char s[] = "HackerRank "; int j; double k; char s1[100]; scanf("%d",&j); scanf("%lf",&k); getchar(); fgets(s1,sizeof(s1),stdin); printf("%d\n",i+j); printf("%.1lf\n",k+d); printf("%s%s\n",s,s1);
}
/* Declare second integer, double, and String variables. / int i2; double d2; String s2; / Read and save an integer, double, and String to your variables./ i2 = scan.nextInt(); d2 = scan.nextDouble(); scan.nextLine(); s2 = scan.nextLine(); / Print the sum of both integer variables on a new line. / System.out.println(i + i2); / Print the sum of the double variables on a new line. / System.out.println(d + d2); / Concatenate and print the String variables on a new line; the 's' variable above should be printed first. */ System.out.println(s.concat(s2));
Javascript solution for those whoo need help
{ // Predefined variables
}
import java.io.; import java.util.; import java.text.; import java.math.; import java.util.regex.*;
public class Solution {
// BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); /* Declare second integer, double, and String variables. / int var1=i; double var2=d; String var3=s; / Read and save an integer, double, and String to your variables.*/ var1+=scan.nextInt(); var2+=scan.nextDouble(); scan.nextLine(); var3+=scan.nextLine(); // Note: If you have trouble reading the entire String, please go back and review the Tutorial closely.
System.out.println(var1); System.out.println(var2); System.out.println(var3);
} }