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
VLD [36.1K]
3 years ago
13

(Complete the Problem-Solving discussion in Word for Programming Challenge 2 on page 404. Your Problem-Solving discussion should

include Problem Statement, Problem Analysis, Program Design, Program Code and Program Test in Words Document.) Create a program that will find and display the largest of a list of positive numbers entered by the user. The user should indicate that he/she has finished entering numbers by entering a 0.
Computers and Technology
1 answer:
zimovet [89]3 years ago
6 0

Answer:

The approach to the question and appropriate comments are given below in C++

Explanation:

Problem statement:

Write a program that will find and display the largest of a list of positive numbers entered by the user. The user should indicate that he/she has finished entering numbers by entering a 0.

Problem Analysis:

It can be completed in worst-case O(n) complexity, best case O(1) (if the first number is maxed element)

Program Design:

1. Start

2. Take the list of positive numbers for the user until he/she enter 0.

3. store the entered numbers in an array

4. find the max number from it.

5. Print the output

6. End

Program Code:

#include<iostream>

using namespace std;

int main(){

  int num = 0, *array = NULL, i= 0, counter = 0, max = 0;

 

  cout<<"Enter a list of positive numbers to find the maximum out of it and if you enter 0 that is the last number: \n";

  array = new int;

 

  /*Taking input from user until he/she enters 0*/

  while(1){

      cin>>num;

      array[i] = num;

      i++;counter++;

      if(num == 0)

          break;  

  }

 

  cout<<"Print user input numbers: \n";

  for(int i=0;i<counter;i++)

      cout<<"list["<<i<<"] --> "<<array[i]<<"\n";

  cout<<"\n";

 

  /*Find max element*/

  max = array[0];

  for(int i=0;i<counter;i++){

      if(array[i] > max)

          max = array[i];  

  }

  cout<<"Max number = "<<max<<"\n";      

  delete array;  

  return 0;

}

You might be interested in
Which of the following is an example of a stereotype?
amm1812

Answer:

d)"I have a really bad feeling about her. I don't know why."

Explanation:

5 0
2 years ago
Question # 2 Multiple Choice The _____ method returns an integer between the two provided numbers. It can take the value of eith
nlexa [21]

Answer:

randint

Explanation:

7 0
3 years ago
Read 2 more answers
Technology can help governments handle economic emergencies, such as the reliance on automation. Crop and resource shortages. Th
uranmaximum [27]

Answer

Technology can help government handle economic emergencies such as crop and resource shortages.

Explanation

The government can address the concerns of food shortages and water scarcity through embracing new technology interventions to increase farm yields and mitigate the impacts of water shortages. Through crop protection methods, weeds and pest can be controlled. Drip irrigation technology applies water directly to the roots of crops to facilitate high crop production. Other technologies to apply can include organic agriculture and integrated soil fertility management.



3 0
3 years ago
Read 2 more answers
Which securities protect data through processes, procedures,decisions,and user pernissions. Determines where and how data can be
vovangra [49]

Answer:

Data can be stored on storage devices.

Explanation:

Network security, Application security and information security are the securities that protect data. Data can be stored on storage devices such as hard disk drives, solid state drives, external hard drives, USB flash drives and SD cards etc. Hard disk drives, floppy disks and tapes store data magnetically. The data can be stored with a device that spins the disk with magnetic coatings and heads has the ability to read and write information in the form of magnetic patterns.

5 0
3 years ago
Each modern computer system is equipped with a compiler. ___ .
oksano4ka [1.4K]
False, modern computers don't need to compile direct source code from users. There are DUIs (direct user interface) that allows the user to interact with a computer without coding.
6 0
3 years ago
Read 2 more answers
Other questions:
  • What is Gamekit Loa3's all questsions
    14·1 answer
  • Clicking on this will minimize all open windows.
    5·2 answers
  • In controlling network traffic to minimize slow-downs, a technology called ________ is used to examine data files and sort low-p
    15·1 answer
  • Which design element is used to convey smoothness or roughness in a design
    12·1 answer
  • Which of the following are not parts of a message? Select all that apply.
    12·1 answer
  • A file named numbers.txt contains an unknown number of lines, each consisting of a single positive integer. Write some code that
    6·1 answer
  • What is the purpose of the Excel Function Reference?
    9·1 answer
  • When an external device becomes ready to be serviced by the processor the device sends a(n)_________ signal to the processor.
    8·1 answer
  • Why do you think Jacinda believed what people told her about her own beauty? Even if you understand that what you see on social
    13·1 answer
  • Juan is a network administrator and must set up a VPN for his company's network. To allow safe communication, he should
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!