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
Lunna [17]
3 years ago
5

Assume there is a variable, h already associated with a positive integer value. Write the code necessary to compute the sum of t

he perfect squares whose value is less than h, starting with 1. (A perfect square is an integer like 9, 16, 25, 36 that is equal to the square of another integer (in this case 3*3, 4*4, 5*5, 6*6 respectively).) Associate the sum you compute with the variable q. For example, if h is 19, you would assign 30 to q because the perfect squares (starting with 1) that are less than h are: 1, 4, 9, 16 and 30
Computers and Technology
1 answer:
lions [1.4K]3 years ago
6 0

Answer:

int i=1  // initialized i to 1

int q=0  // initialized q to 10

while((i*i)<h) // iterating the while loop

{

q=(i*i)+q  // calculating the sum of square

i=i+1 //Increment of i

}

Explanation:

Following are the description of Program

  • Initialized the variable "i" which is "int" type to 1.
  • Initialized the variable "q" which is "int" type to 0.
  • Iterating the while loop to less then variable "h".
  • In this loop we calculate the sum of square and holding the result in the variable "q".
  • Finally increment the value to "i" by 1 to iterating the loop.
You might be interested in
When performing actions between your computer and one that is infected with a virus, which of the following offers NO risk of yo
Alexandra [31]

The one already infected, I think ..

6 0
4 years ago
Most network behavior analysis system sensors can be deployed in __________ mode only, using the same connection methods as netw
soldier1979 [14.2K]
Most network behavior analysis system sensors can be deployed in passive mode only, using the same connection methods as network based idpss. Idps works as a network or host based systems. Most Nba sensors can be deployed in passive mode only too. The Nba examines the network traffic.
7 0
3 years ago
Where is the viscosity of engine oil found
Rashid [163]
In the crankcase
I hope this helps
8 0
4 years ago
A check list should be based on that apply to your industry.
frozen [14]
Can you please elaborate? This is as your question isn't very clear.
6 0
3 years ago
Read 2 more answers
What Is an Antivirus?
wariber [46]
Antivirus software, or anti-virus software, also known as anti-malware, is a computer program used to prevent, detect, and remove malware. Antivirus software was originally developed to detect and remove computer viruses, hence the name.
8 0
3 years ago
Read 2 more answers
Other questions:
  • An authenticated user can add up to how many computer accounts to the domain, by default
    6·1 answer
  • What is computer? Explain the characteristics of computer.<br>​
    12·1 answer
  • Abram was asked to explain to one of his coworkers the XOR cipher. He showed his coworker an example of adding two bits, 1 and 1
    7·1 answer
  • A lottery ticket contains five unique numbers. A set of unique numbers does not contain repeated elements. The winning combinati
    10·1 answer
  • . public members are accessible from ________________ where the object is visible
    9·1 answer
  • What happens when two computers use the same IP address?
    15·1 answer
  • 15 Points ASAP
    14·2 answers
  • There are....... section in<br>cpu<br>​
    15·1 answer
  • Suppose that the first goal in a GP problem is to make 3 X1 + 4 X2 approximately equal to 36. Using the deviational variables d1
    15·1 answer
  • You have been elected to assist the school's yearbook committee and newspaper club in purchasing new computers. The current comp
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!