Question: Remove all the unnecessary tests from the nested conditional statement below. Float income; cout < < Enter your monthly income: ; cin >> income; if
Remove all the unnecessary tests from the nested conditional statement below.
Float income; cout << "Enter your monthly income: "; cin >> income; if (income < 0.0) cout << "You are going farther into debt every month." << endl; else if (income >= 0.0 && income < 1200.00) cout << "You are living below the poverty line." << endl; else if (income >= 1200.00 && income < 2500.00) cout << "You are living in moderate comfort." << endl; else if (income >= 2500.00) cout << "You are well off." << endl;
Answer the questions below concerning the following fragment of code. int n; cout << "Enter an integer: "; cin >> n; if (n < 10) cout << "less than 10" << endl; else if (n > 5) cout << "greater than 5" << endl; else cout << "not interesting" << endl; a. What will be the output of the fragment above if the interactive user enters the integer value 0 ? b. What will be the output of the fragment above if the interactive user enters the integer value 15 ? c. What will be the output of the fragment above if the interactive user enters the integer value 7 ? d. What values for n will cause the output of the fragment above to be "not interesting"?
Rewrite the following code fragment so that it uses a "do...while..." loop to accomplish the same task. int n; cout << "Enter a non-negative integer: "; cin >> n; while (n < 0)
cout << "The integer you entered is negative." << endl; cout << "Enter a non-negative integer: "; cin >> n; }
In the code fragment below, the programmer has almost certainly made an error in the first line of the conditional statement.
a. What is the output of this code fragment as it is written?
b. How can it be corrected to do what is the programmer surely intended? int n = 5; if (n = 0) // NOTE THE OPERATOR!!! cout << "n is zero" << ". "; else cout << "n is not zero" << ". "; cout << "The square of n is " << n * n << ". ";
What is the output when the following code fragment is executed?
int n, k = 5; n = (100 % k ? k + 1 : k - 1); cout << "n = " << n << " k = " << k << endl; 18. What is the output when the following code fragment is executed? int n; float x = 3.8; n = int(x); cout << "n = " << n << endl;
What is the output when the following code fragment is executed?
Rewrite the fragment to obtain an equivalent code fragment in which the body of the loop is a simple statement instead of a compound statement. int i = 5; while (i > 0) { --i; cout << i << endl; }
The following loop is an endless loop: when executed it will never terminate. What modification can be made in the code to produce the desired output?
cout << "Here's a list of the ASCII values of all the upper" << " case letters. "; char letter = 'A';
while (letter <= 'Z') cout << letter << " " << int(letter) << endl;
Why are certain functional dependencies called trivial functional dependencies?
Explain what is meant by repetition of information and inability to represent information. Explain why each of these properties may indicate a bad relational database design.
Consider a relation R(A,B,C,D,E) with the following dependencies:
{AB-> C, CD -> E, DE -> B}
Is AB a candidate key of this relation? If not, is ABD? Explain your answer.
No. The closure of AB does not give you all of the attributes of the relation.
If not, is ABD? Explain your answer.
Consider a relation with schema R(A,B,C,D) and FDs {AB -> C, C -> D, D -> A}.
a. What are some of the nontrivial FDs that can be inferred from the given FDs?
Consider a relation R(A,B,C,D,E) with FDs {AB -> C, DE ->C, and B -> D}
a. Indicate all BCNF violations for R.
The dawn of the 21st century witnessed the melting glaciers oscillating between giving too much and too little to billions of people who depend on them for fresh water. The UN climate report estimates that without deep cuts to man-made emissions, at least 30% of the northern hemisphere's surface permafrost could melt by the end of the century. Given this situation of imminent global exodus of billions of people displaced by rising seas, nation-states need to rethink their carbon footprint for political concerns, if not for environmental ones. Which one of the following statements can be inferred from the given passage ?
What is the worst case time complexity of inserting n2 elements into an AVL-tree with n elements initially ?
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
