Answer:
Program approach:-
- Using the header file.
- Using the standard namespace I/O.
- Define the main function.
- Display the number of terms.
- Display the Fibonacci series.
- Print the first two numbers.
Explanation:
Program:-
//header file
#include <iostream>
//using namespace
using namespace std;
//main function
int main() {
int n, s1 = 0, s2 = 1, nextTerm = 0;
//display the number of terms
cout << "Enter the number of terms: ";
cin >> n;
//display the Fibonacci series
cout << "Fibonacci Series: ";
for (int j = 1; j <= n; ++j) {
// Prints the first two terms.
if(j == 1) {
cout << s1 << ", ";
continue;
}
if(j == 2) {
cout << s2 << ", ";
continue;
}
nextTerm = s1 + s2;
s1 = s2;
s2 = nextTerm;
cout << nextTerm << ", ";
}
Answer:
true false
Explanation:
list1 is assigned as Atlanta, Macon, Savanna
list2 is assigned as Atlanta, Macon, Savanna
list3 is assigned as Macon, Atlanta, Savanna
After these assignments,
The program checks if lis1 is equal to list2 and prints the result. Since both lists are equal, it will print true
The program checks if lis1 is equal to list3 and prints the result. Even though both lists contain the same elements, the order is different, it will print false.
Answer:the answer is not A
Explanation:
Answer:
The solution code is written in Python:
- MONTHS_IN_YEAR = 12
- MONTHS_IN_DECADE = MONTHS_IN_YEAR * 10
Explanation:
Constant variable is a type of variable that holds value which will not be changed. This means the value will only be assigned to the constant variable once. As a convention, constant variable is named with all uppercase letters to differentiate it from other variables.
By presuming there is a constant variable, MONTHS_IN_YEAR which has been declared and assigned with 12 (Line 1).
Next, we create another constant variable, MONTHS_IN_DECADE, and we can calculate the decade by using the value of constant variable MONTHS_IN_YEAR multiplied with 10 and assign the result to MONTHS_IN_DECADE (Line 2).