1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
nevsk [136]
3 years ago
15

Assume the int variables i, lo, hi, and result have been declared and that lo and hi have been initialized. Write a for loop tha

t adds the integers between lo and hi (inclusive), and stores the result in result. Your code should not change the values of lo and hi. Also, do not declare any additional variables -- use only i, lo, hi, and result.
Computers and Technology
1 answer:
IRISSAK [1]3 years ago
4 0

Answer:

result=0;

for (i=lo ; i<=hi; i++){

result += i;

}

Explanation:

The question says result was declared but not initialized, so using result without initializing it to 0 would throw an error as result would be undefined and you can't add a number to undefined

Another way to do it to keep everything inside the loop would be

for (i=lo ; i<=hi; i++){

if (i==lo) result= 0;

result += i;

}

but this is impractical since it would add unnecesary operations in each cycle of the loop

You might be interested in
In this exercise, you are given a word or phrase and you need to return that word or phrase with the word ‘like’ in front of it.
bogdanovich [222]

Answer:

See the link

Explanation:

There's exact same question on Brainly

brainly.com/question/15797916

7 0
3 years ago
The declarations and statements that compose the method definition are called the __________.
Fiesta28 [93]

Answer:

a. method body.

Explanation:

A method contains the following components:

  • method name
  • method arguments
  • method return type
  • method implementation code

All of these together constitute the method body. The method body contains the declarations and statements constituting the method definition.

Apart from this, when the method is invoked at runtime, it needs to be called with method-name and the actual parameter list which gets substituted for the formal parameters in the method body.

8 0
3 years ago
Disadvantages of Batch<br>operation system​
jok3333 [9.3K]

Answer:

Disadvantages of Batch Operating System:

  1. The computer operators should be well known with batch systems.
  2. Batch systems are hard to debug.
  3. It is sometime costly.
  4. The other jobs will have to wait for an unknown time if any job fails.
8 0
3 years ago
Write a recursive function that returns 1 if an array of size n is in sorted order and 0 otherwise. Note: If array a stores 3, 6
galina1969 [7]

Answer:

The function in C++ is as follows:

int isSorted(int ar[], int n){

if (n == 1 || n == 0){

 return 1;}

if (ar[n - 1] < ar[n - 2]){

 return 0;}

return isSorted(ar, n - 1);}

Explanation:

This defines the function

int isSorted(int ar[], int n){

This represents the base case; n = 1 or 0 will return 1 (i.e. the array is sorted)

if (n == 1 || n == 0){

 return 1;}

This checks if the current element is less than the previous array element; If yes, the array is not sorted

if (ar[n - 1] < ar[n - 2]){

 return 0;}

This calls the function, recursively

return isSorted(ar, n - 1);

}

6 0
2 years ago
Lesson 1 (4.0 points)
sesenic [268]


3. Hold down the CTRL, ALT, and DELETE keys simultaneously, click Task Manager option, then right-click the frozen program's name, and finally click the end task button.


8 0
3 years ago
Read 2 more answers
Other questions:
  • A hacker changing the ip addresses used in conjunction with a particular company’s web site to re-route them to the hacker’s ser
    11·1 answer
  • Additional chemical hazards training must be provided to employees:
    12·1 answer
  • Rainfall_mi is a string that contains the average number of inches of rainfall in Michigan for every month (in inches) with ever
    12·1 answer
  • Provide a few examples of how cryptography actually secures data.
    8·1 answer
  • Word can store a maximum of how many documents in its Recent Documents area? five ten fifteen twenty
    8·1 answer
  • One of the most common encryption protocols in use today. It is an asymmetric protocol that enables the sharing of a secret key
    7·1 answer
  • I am bad with excell pleasee heelp
    15·1 answer
  • PLS HELP ILL GIVE BRAINLY- (enter the answer) Microsoft _________ is an example of a desktop publishing software
    13·2 answers
  • Que es tarjeta madre resumen porfa
    13·2 answers
  • HELP FAST PLS<br> Do you care more about avoiding fees/costs, accumulating perks, convenience, etc?
    14·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!