
LANGUAGE: JAVA
CHALLENGE:
Two variables, num and cost have been declared and given values : num is an integer and cost is a double. Write a single statement that outputs num and cost to standard output. Print both values (num first, then cost), separated by a space on a single line that is terminated with a newline character. Do not output any thing else.
SOLUTION:
System.out.println(num + " " + cost + "\n");
System.out.print(num + ” ” + cost + “\n”);
FOR C
printf(“%d %lf\n”, num, cost);
For people saying it isn’t helpful, make sure you used \n instead of /n. That was the mistake I made.
Can you help me understand why it works the way it does?