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
n200080 [17]
2 years ago
9

Write a program that repeatedly reads in integers until a negative integer is read. The program keeps track of the largest integ

er that has been read so far and outputs the largest integer when the (first) negative integer is encountered. (See subsection Example: Finding the max value of section 4.1 Loops (general) to practice the algorithm).
Computers and Technology
1 answer:
vfiekz [6]2 years ago
5 0

Answer:

In Python:

num = int(input("Enter number: "))

maxn = num

while num >=0:

   if num>maxn:

       maxn = num

   num = int(input("Enter number: "))

print("Largest: "+str(maxn))

Explanation:

Get input from the user

num = int(input("Enter number: "))

Initialize the largest to the first input

maxn = num

This loop is repeated until a negative input is recorded

while num >=0:

If the current input is greater than the previous largest

   if num>maxn:

Set largest to the current input

       maxn = num

Get another input from the user

   num = int(input("Enter number: "))

Print the largest

print("Largest: "+str(maxn))

You might be interested in
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
HELP ME PLEASE
seraphim [82]

Answer:

Questions and answers

Explanation:

3 0
2 years ago
This isn't about school but every time it tells me to watch an ad to unlock the answer to a question it prompts a survey and it
Masja [62]
Restart it than see what happens
4 0
3 years ago
Read 2 more answers
Write an algorithm to find perimeter of circle<br>​
Anna11 [10]

Answer:

Here’s one!

Given [math]R[/math], the radius of the circle.

Let [math]N,D\leftarrow 0[/math]

Repeat until [math]D[/math] is large enough (about 1,000,000)

[math]x,y\leftarrow U[0,1][/math]

If [math]x^2 + y^2\le 1[/math] then [math]N\leftarrow N+1[/math]

[math]D\leftarrow D+1[/math]

[math]P\leftarrow\frac{8NR}{D}[/math]

Return [math]P[/math]

[math]U[0,1][/math] is a uniform random number in the range [math][0,1][/math].

Explanation:

6 0
2 years ago
When a security administrator wants to conduct regular test on the strength of user passwords, what may be the best setup for th
wariber [46]
I think it’s letter c
4 0
2 years ago
Other questions:
  • What is the output of the following code? public class Test { public static void main(String[] args) { String s1 = new String("J
    9·1 answer
  • 50 points!!!!!
    9·2 answers
  • What is the term used to describe a computer system that can store literary documents, link them according to logical relationsh
    5·1 answer
  • Which of the following is considered a basic task in the context of computer operations? a. Connecting to the Internet b. Natura
    6·1 answer
  • I have a question. This question will probably be deleted, but why do moderators keep deleting my answers when they are legitima
    13·1 answer
  • Write a program to prompt the user for hours worked to compute a gross pay for an employee, and he is paid 100/hour. If he worke
    7·1 answer
  • What are 6 subtopics on computer programming ?
    13·1 answer
  • A class is a type of object that defines the format of the object and the actions it can perform. True False
    14·1 answer
  • Which is the first calculating device invented?​
    14·2 answers
  • If there is a secure socket layer in place, what will you need in addition to a user id in order to access the shared files?.
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!