Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. How can information technology support a company's business processes and decision making and give it a competitive advantage? GIve examples to illustrate your answer.

1. How can information technology support a company's business processes and decision making and give it a competitive advantage? GIve examples to illustrate your answer.

2. How does the use of the Internet, intranets, and extranets by companies today support their business processes and activities?

a. Suppose that in response to the prompt, the interactive user types the following line and presses Enter: Please go away.

What will the output of the code fragment look like?

b. Suppose that the statement "cin >> message[i];" is replaced by the statement cin.get(message[i]);

Now what will the output of the code fragment look like if, in response to the prompt, the interactive user types the following line and presses Enter? Please go away. 11. The nested conditional statement shown below has been written by an inexperienced C/C++ programmer.

The behavior of the statement is not correctly represented by the formatting. if (n < 10) if (n > 0) cout << "The number is positive." << endl; else cout << "The number is ______________." << endl; a. What is the output of the statement if the variable n has the value 7 ? If n has the value 15 ? If n has the value 3 ?

b. Correct the syntax of the statement so that the logic of the corrected statement corresponds to the formatting of the original statement. Also, replace the blank with an appropriate word or phrase. c. Correct the formatting of the (original) statement so that the new format reflects the logical behavior of the original statement. Also, replace the blank with an appropriate word or phrase. 12. The loop shown below has been written by an inexperienced C/C++ programmer. The behavior of the loop is not correctly represented by the formatting. int n = 10; while (n > 0) n /= 2; cout << n * n << endl; a. What is the output of the loop as it is written?

b. Correct the syntax of the loop so that the logic of the corrected loop corresponds to the formatting of the original loop. What is the output of the corrected loop? c. Correct the formatting of the (original) loop so that the new format reflects the logical behavior of the original loop.

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;

Write function named "sum_from_to" that takes two integer arguments, call them "first" and "last", and returns as its value the sum of all the integers between first and last inclusive. Thus, for example, cout << sum_from_to(4,7) << endl; // will print 22 because 4+5+6+7 = 22 cout << sum_from_to(-3,1) << endl; // will print 5 'cause (-3)+(-2)+(-1)+0+1 = 5 cout << sum_from_to(7,4) << endl; // will print 22 because 7+6+5+4 = 22 cout << sum_from_to(9,9) << endl; // will print 9

Write function named "enough" that takes one integer argument, call it "goal" and returns as its value the smallest positive integer n for which 1+2+3+. . . +n is at least equal to goal . Thus, for example, cout << enough(9) << endl; // will print 4 because 1+2+3+4 9 but 1+2+3<9 cout << enough(21) << endl;// will print 6 'cause 1+2+ . . .+6 21 but 1+2+ . . . 5<21 cout << enough(-7) << endl;// will print 1 because 1 7 and 1 is the smallest // positive integer cout << enough(1) << endl; // will print 1 because 1 1 and 1 is the smallest // positive integer

Write function named "g_c_d" that takes two positive integer arguments and returns as its value the greatest common divisor of those two integers. If the function is passed an argument that is not positive (i.e., greater than zero), then the function should return the value 0 as a sentinel value to indicate that an error occurred. Thus, for example, cout << g_c_d(40,50) << endl; // will print 10 cout << g_c_d(256,625) << endl; // will print 1 cout << g_c_d(42,6) << endl; // will print 6

cout << g_c_d(0,32) << endl; // will print 0 (even though 32 is the g.c.d.) cout << g_c_d(10,-6) << endl; // will print 0 (even though 2 is the g.c.d.)

Write function named "digit_name" that takes an integer argument in the range from 1 to 9 , inclusive, and prints the English name for that integer on the computer screen. No newline character should be sent to the screen following the digit name. The function should not return a value. The cursor should remain on the same line as the name that has been printed. If the argument is not in the required range, then the function should print "digit error" without the quotation marks but followed by the newline character. Thus, for example, the statement digit_name(7); should print seven on the screen; the statement digit_name(0); should print digit error on the screen and place the cursor at the beginning of the next line.

Write function named "reduce" that takes two positive integer arguments, call them "num" and "denom", treats them as the numerator and denominator of a fraction, and reduces the fraction. That is to say, each of the two arguments will be modified by dividing it by the greatest common divisor of the two integers. The function should return the value 0 (to indicate failure to reduce) if either of the two arguments is zero or negative, and should return the value 1 otherwise. Thus, for example, if m and n have been declared to be integer variables in a program, then m = 25; n = 15; if (reduce(m,n)) cout << m << '/' << n << endl; else cout << "fraction error" << endl; will produce the following output: 5/3 Note that the values of m and n were modified by the function call. Similarly, m = 63; n = 210; if (reduce(m,n)) cout << m << '/' << n << endl; else cout << "fraction error" << endl;r

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Microeconomics

Authors: Jeffrey M. Perloff

8th edition

134519531, 978-0134519531

More Books

Students also viewed these Economics questions

Question

What reward will you give yourself when you achieve this?

Answered: 1 week ago