Answer:
Explanation:
The following code is written in Java and it asks you for your age and then prints out the exact date from your birthday that you will turn 10,000 days old.
import java.util.Calendar;
import java.util.Date;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
System.out.println("What is your age?");
int age = in.nextInt();
int daysLeft = (10000 - (age*365));
Date birthday = new Date();
Calendar cal = Calendar.getInstance();
cal.setTime(birthday);
cal.add(Calendar.DATE, daysLeft);
Date modifiedDate = cal.getTime();
System.out.println(modifiedDate);
}
}
Answer:
1. 5
2. Because they let us quickly process the contents of an array, which have many values.
Explanation:
Answer:
In C++:
int PrintInBinary(int num){
if (num == 0)
return 0;
else
return (num % 2 + 10 * PrintInBinary(num / 2));
}
Explanation:
This defines the PrintInBinary function
int PrintInBinary(int num){
This returns 0 is num is 0 or num has been reduced to 0
<em> if (num == 0) </em>
<em> return 0; </em>
If otherwise, see below for further explanation
<em> else
</em>
<em> return (num % 2 + 10 * PrintInBinary(num / 2));
</em>
}
----------------------------------------------------------------------------------------
num % 2 + 10 * PrintInBinary(num / 2)
The above can be split into:
num % 2 and + 10 * PrintInBinary(num / 2)
Assume num is 35.
num % 2 = 1
10 * PrintInBinary(num / 2) => 10 * PrintInBinary(17)
17 will be passed to the function (recursively).
This process will continue until num is 0
I believe the answer is annual maintenance
Hope this helps :p