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
Anton [14]
3 years ago
10

write a loop that reads positive integers from stands input and that terinated when it reads an interger that is not positive af

ter the loop termpinates
Computers and Technology
1 answer:
gtnhenbr [62]3 years ago
5 0

Loop takes only positive numbers and terminates once it encounters a negative numbers.

Answer and Explanation:

Using javascript:

Var positiveInt= window.prompt("insert positive integer");

While(positiveInt>=0){

Alert("a positive integer");

Var positiveInt= window.prompt("insert positive integer");

}

Or we use the do...while loop

Var positiveInt= window.prompt("insert positive integer");

do{

Var positiveInt= window.prompt("insert positive integer");

}

While (positiveInt>=0);

The above program in javascript checks to see if the input number is negative or positive using the while loop condition and keeps executing with each input until it gets a negative input

You might be interested in
In Python, what is returned when evaluating [n for n in range(10) if n % 2]?​
Firlakuza [10]
First we need to understand what "n for n in range(10)" means. Basically, we are iterating through all the values n that are in the range of 10 (meaning 0, 1, 2, 3, ..., 9).

Next we are evaluating if n%2. The percentage sign is used to represent modulus which is the remainder of when two numbers are divided. In this case, we are dividing n by 2, and the remainder is our result. When dividing by 2, the only possible remainders are 0 or 1, which when used in an if statement represent the boolean vlaues false and true, respectively. We are doing this calculation for each n from 0 to 9, and if the result is true, we output n to an array.

The numbers that will result in true (a remainder of 1) are the odds numbers. For example, 4/2 = 2 with nothing left over while 5/2 = 2 with 1 left over.

So the following is returned:

[1, 3, 5, 7, 9]
8 0
3 years ago
Which of the following components transfers information between other core components?
Viktor [21]

Answer:

System bus

Explanation:

6 0
3 years ago
Read 2 more answers
What does the following code print to the console?
UNO [17]

Answer:

although there are errors in this program but it'd print Ireland and Colombia

if you need help in python programming language, hit the comment section

6 0
3 years ago
What is the total number of counts for
andriy [413]

Answer:

i belive your answer would be 32 because

Explanation:

whole note =4 beats

dotted half note =3 beats

and 2 quarter notes get =8 beats

all of that added together equals 18 minus half note =2 beats

which=16 times a half note which =2 would give you your answer 32

4 0
3 years ago
True or Flase
Naily [24]

Answer:

True

Explanation:

The c++ program to explain the variable life cycle is given below.

#include <iostream>

using namespace std;

int main() {    

   char c;

   int i;

   double d;

   string s;    

   c = 'B';

   i = 1111;

   d = 33.0123456789;

   s = "Name";    

   cout << " Char     " << c << endl;

   cout << " Integer  " << i << endl;

   cout << " Double   " << d << endl;

   cout << " String   " << s << endl;    

   cout << " Program ends. Variables out of scope, variables die out... " << endl;    

   return 0;    

}

OUTPUT

Char     B

Integer  1111

Double   33.0123

String   Name

Program ends. Variables out of scope, variables die out...

1. Program begins with declaring variables of type character, integer, double and string.

   char c;

   int i;

   double d;

   string s;

2. Next, all these variables are initialized.

   c = 'B';

   i = 1111;

   d = 33.0123456789;

   s = "Name";

3. This program only displays the values of the variables. No operation or modification is done to the variables. Hence, in this program, usage of variables is limited to printing the value of the variables.

   cout << " Char     " << c << endl;

   cout << " Integer  " << i << endl;

   cout << " Double   " << d << endl;

   cout << " String   " << s << endl;

4. In this program, the scope of the variables is the scope of the main() function itself. Once the program ends, the main() function also ends and the variables die out.

5. The life cycle of the variable ends with the termination of the program. Hence, the message is printed.

6. These variables can be used again only when the program is executed again or the same variables are used in another program. These variables can not be used directly without following the life cycle – declaration, initialization, usage, termination.

5 0
3 years ago
Other questions:
  • Write the interface (.h file) of a class ContestResult containing: An data member winner of type string, initialized to the empt
    14·1 answer
  • Describe two measures you can use to evaluate whether an attachment in a message is reliable to open.
    8·2 answers
  • Why were mechanical calculators developed?
    8·2 answers
  • Tom is the aerobics coordinator at a fitness center. He needs a more efficient way for his instructors to share information. Cla
    13·2 answers
  • Which of the following is a group of email names and addresses used for mass distribution of a message?
    5·1 answer
  • Requests to access specific cylinders on a disk drive arrive in this order: 24, 20, 4, 40, 6, 38, and 12, and the seek arm is in
    10·1 answer
  • Precautionary measures to be observed when using ICT tools​
    15·1 answer
  • Consider the following class interfaces:
    8·1 answer
  • Write a method maxMagnitude() with two integer input parameters that returns the largest magnitude value. Use the method in a pr
    13·1 answer
  • Which popular video game franchise has released games with the subtitles World At War and Black Ops?
    10·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!