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
Margaret [11]
3 years ago
11

javascript Write a function named sumNumbers that accepts a nonnegative number, adds up all of the numbers between 0 and the num

ber (inclusive), and returns the sum.
Engineering
1 answer:
BartSMP [9]3 years ago
5 0

Answer:

  1. function sumNumbers(num){
  2.        let sum = 0;
  3.        for(let i=0; i <= num; i++){
  4.            sum += i;        
  5.        }
  6.        return sum;
  7. }

Explanation:

Firstly, let's create a function named <em>sumNumbers()</em> that take one input parameter, <em>num</em> (Line 1).

Declare a variable,<em> sum</em>, to hold the value of total number between 0 and the input number (Line 2). Initialize it with 0 value.

Create a for-loop to traverse through the numbers started from 0 till input number (Line 3). In the loop, add the each number to<em> sum</em> variable (Line 4).

At last, return the <em>sum</em> as output (Line 6).

You might be interested in
Convert the following pairs of voltage and current waveforms to phasor form. Each pair of waveforms corresponds to an unknown el
Lisa [10]

Answer:

The solutions are attached below:

Explanation:

3 0
3 years ago
Given x = 67 and y = 18, use two's complement to calculate:(1)x+y (2) x-y (3)-x+y (4)-x-y. Do the calculation, show the results
joja [24]

Answer:

See attachment

Explanation:

8 0
3 years ago
Primary U.S. interstate highways are numbered 1-99. Odd numbers (like the 5 or 95) go north/south, and evens (like the 10 or 90)
IrinaVladis [17]

Answer:

#include <iostream>

using namespace std;

int main()

{

int inputNumber ;

cout << "Enter an interstate highway number:";

cin >> inputNumber ;

if(inputNumber<=0 || inputNumber >= 1000)

cout << inputNumber << " is not a valid interstate highway number" << endl ;

else{

if(inputNumber > 99){

cout << "I-"<<inputNumber<< " is auxiliary, ";

int temp = inputNumber % 100 ;

cout <<"serving I-"<<temp<<", ";

if(temp%2==0){

cout << "going east/west." << endl;

}

else{

cout << "going north/south." << endl;

}

}

else{

cout << "I-"<<inputNumber<< " is primary, ";

if(inputNumber%2==0){

cout << "going east/west." << endl;

}

else{

cout << "going north/south." << endl;

}

}

}

return 0;

}

Explanation:

  • Check if input number is greater than 99, then display that the input number is auxiliary.
  • Check if remainder of input number/2 is equal to 0, then display that going east/west.
3 0
3 years ago
Quadrilateral ABCD is a rectangle.<br> If m ZADB = 7k + 60 and mZCDB = -5k + 40, find mZCBD.
yuradex [85]

Hope this helps...........

8 0
3 years ago
Answer every question of this quiz
Reil [10]

I'd say number 4, number 3 looks like an exhaust valve

5 0
4 years ago
Other questions:
  • 3. An isolated system has an initial temperature of 30oC. It is then placed on top of a Bunsen burner whose temperature is 70oC
    10·1 answer
  • A 1-m long, thin symmetric airfoil is placed at a free stream. Calculate the drag force for the wind speed of 150 m/s. Assume th
    7·1 answer
  • Which of the following statement(s) are true?
    14·1 answer
  • . Steam is to be condensed from saturated vapor to saturated liquid in the condenser of a steam power plant at a temperature of
    5·1 answer
  • Why was the lack of preparedness of the Federal Emergency Management Agency in the Hurricane Katrina disaster so damaging for th
    12·1 answer
  • What was the first prototype of the artificial tree like?
    5·1 answer
  • Who else ships it????????
    6·1 answer
  • A mixture of octane, C8H18, and air flowing into a combustor has 60% excess air and 1 kmol/s of octane. What is the mole flow ra
    11·1 answer
  • Starting with a context diagram, draw as many nested DFDs as you consider necessary to represent all the details of your times p
    11·1 answer
  • 3. Whether an accident scene is safe or not, you should first take action to help any victims.
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!