Computer Science › Programming Constructs
Which of the following is a recursive factorial function?
Recall that an example of a factorial is:
Which of the following is a recursive factorial function?
Recall that an example of a factorial is:
int lairotcaf (int n) {
if (n <= 1){
return 1
}
temp = n * lairotcaf(n-1)
return temp;
}
int num;
cin >> num;
``
if (num >= 0){
lairotcaf(n)
} else {
cout << "must use number greater or equal to zero"< endl;
}
What is returned by lairotcaf(5)
?
int lairotcaf (int n) {
if (n <= 1){
return 1
}
temp = n * lairotcaf(n-1)
return temp;
}
int num;
cin >> num;
``
if (num >= 0){
lairotcaf(n)
} else {
cout << "must use number greater or equal to zero"< endl;
}
What is returned by lairotcaf(5)
?
int var=0;
int array\[4\];
for (int j=0; j<=4;j++)
{
var=var+1;
}
What is the value of var?
int var=0;
int array\[4\];
for (int j=0; j<=4;j++)
{
var=var+1;
}
What is the value of var?
True or False.
This code snippet will iterate 5 times.
ArrayList<String> arrList = new ArrayList<String>();
arrList.add("string0");
arrList.add("string1");
arrList.add("string2");
arrList.add("string3");
arrList.add("string4");
for (int i = 0; i < arrList.size(); i++) {
System.out.println(arrList.get(i));
}
Suppose you have the following code:
public static void main(String\[\] args) {
int a =2;
if (a%2==0)
System.out.println("Hello World");
else
System.out.println("Hi");
}
If the main method is called, what will be printed?
True or False.
This code snippet will iterate 5 times.
ArrayList<String> arrList = new ArrayList<String>();
arrList.add("string0");
arrList.add("string1");
arrList.add("string2");
arrList.add("string3");
arrList.add("string4");
for (int i = 0; i < arrList.size(); i++) {
System.out.println(arrList.get(i));
}
Suppose you have the following code:
public static void main(String\[\] args) {
int a =2;
if (a%2==0)
System.out.println("Hello World");
else
System.out.println("Hi");
}
If the main method is called, what will be printed?