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
IgorC [24]
3 years ago
9

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.NOTE: just write the for loop header; do not write the loop body itself.
Computers and Technology
1 answer:
hram777 [196]3 years ago
3 0

Answer:

for (i = lo, result = 0; i <= hi; result += i, i++) {}

Explanation:

A for loop header has three statements:

  1. <em>i = 0, result = 0;     </em>This statement initializes <u>i</u> and <u>result</u> variables with 0. It is executed only once at the very start of the for loop.
  2. <em>i <= hi;</em>     This statement is executed after the first statement and again after the execution of code in body of the loop.
  3. <em>result += i, i++</em>     This statement is executed after the execution of code in body of the loop but before the execution of second statement.

Therefore, the following sequence of events will occur:

  • The result variable is initialized with 0 at start.
  • Then, the condition is checked. If the value of i will be less than or equal to the value of hi, the third statement will be executed.
  • The third statement will add the value of i to the value of result and then increase the value of i by 1.
  • Then, again the condition in second statement will be checked.

This loop will be executed for as long as the condition remains true.

You might be interested in
JavaScript is the same thing as Java?
Mila [183]

Not really, because Java is an OOP programming language and JavaScript is an OOP scripting language.

Hope I helped!

~Mshcmindy

5 0
3 years ago
Read 2 more answers
The domain name system ________. Question 2 options: A) is a way to find a host's IP addresses if your computer only knows the h
ra1l [238]

Answer:

C) both a and b

Explanation:

13) The domain name system ________.

A) is a way to find a host's IP addresses if your computer only knows the host's host name

B) is a general naming system for the Internet

C) both A and B

D) neither A nor B

8 0
2 years ago
You configured the IP address and DNS name of a new internal web server named WEB3. Your first test from a web browser on your w
bonufazy [111]

Answer:

I would reset the Domain Name System (DNS)

Explanation:

One factor that could lead to the "Site Cannot Be Reached" error is DNS "poisoning". Another is invalid DNS cache. Both can be caused by an attack on the system by people trying to spoof the system. Spoofing ensures that even when the right address is entered, it leads one to another web address.

One way to quickly reset the DNS is to run ipconfig /flushdns

This helps to clear the DNS cache.

Once the DNS cache has been successfully flushed, the system returns a confirmatory message that reads “flushed the DNS resolver cache”.

The systems administrator can now proceed to reconfigure the IP address(es)

Cheers

3 0
3 years ago
The minimum recommended standards for the operating system, processor, primary memory (RAM), and storage capacity for certain so
timurjin [86]

Answer:

They are called System Requirements.

Explanation:

3 0
2 years ago
Write a function called backspaceCompare that takes two strings sl and s2 and evaluate them when both are typed into empty text
Andrej [43]

Answer:

Go to explaination for the program code

Explanation:

import java.util.Stack;

public class Lab3 {

public static void main(String[] args) {

String s1="DataStructuresIssss###Fun";

String s2="DataStructuresIszwp###Fun";

boolean ans=backspaceCompare(s1,s2);

System.out.println(ans);

/*String s1="abc##";

String s2="wc#d#";

boolean ans=backspaceCompare(s1,s2);

System.out.println(ans);*/

}

public static boolean backspaceCompare(String s1, String s2) {

Stack<Character> s1_stack=new Stack<Character>();

Stack<Character> s2_stack=new Stack<Character>();

//backspaceCount is a variable to count back space

int backspaceCount=0;

//logic is that if '#' encountered we are putting pop else push

for(int i=0;i<s1.length();i++){

if(s1.charAt(i)=='#'){

backspaceCount++;

s1_stack.pop();

}

else

{

s1_stack.push(s1.charAt(i));

}

}

//this all is for s2 string

for(int i=0;i<s2.length();i++){

if(s2.charAt(i)=='#') s2_stack.pop();

else s2_stack.push(s2.charAt(i));

}

//here is the main logic first we are adding based upon # means we pop up the string while adding the string if any # character found

//here we are checking from the end using pop condition both are not mathing then we are returning false

for(int i=0;i<s1.length()-2*backspaceCount;i++){

if(s1_stack.pop()!=s2_stack.pop()) return false;

}

return true;

}

}

6 0
3 years ago
Other questions:
  • Besides technical skill, what is the most important factor for staying employed and being offered promotions?
    6·2 answers
  • What is A/B Testing
    10·2 answers
  • A file named data.txt contains an unknown number of lines, each consisting of a single integer. Write some code that creates two
    14·2 answers
  • Write the document type declaration markup statement for an HTML5 file. Be sure to include the appropriate opening and closing b
    12·1 answer
  • What is the name of the function used to open a file in C?
    8·1 answer
  • _____ describes the layout of the screen. Block-based, Interface, Editor, Player
    11·2 answers
  • A large company has a LAN. The manager of the company wants to change it to a WAN
    10·1 answer
  • How is primary storage different from secondary storage? Select the TWO correct statements. The CPU can only read and write data
    12·2 answers
  • What help the ict in your life?and write own idea three or four sentence
    12·1 answer
  • If your cell phone rings while you are driving and you do not have a hands-free device you should
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!