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
Posts that you delete
kiruha [24]
Answer
are visible to others may already have been shared
8 0
2 years ago
In popular usage and in the media, the term ________ often describes someone who breaks into a computer system without authoriza
ch4aika [34]
The answer here is hacker
6 0
3 years ago
Which describes the first step a crawler-based search engine uses to find information?
elena-14-01-66 [18.8K]
C is the correct answer to the problem
6 0
3 years ago
Read 2 more answers
Capstone Project part 11 quiz
kobusy [5.1K]
It is checking if the response is not yet yes
4 0
2 years ago
How to analyze time complexity of a code?
VladimirAG [237]

Answer:

we can multiply or divide by a constant factor to get to the simplest expression. The most common metric for calculating time complexity is Big O notation. This removes all constant factors so that the running time can be estimated in relation to N as N approaches infinity.

Explanation:

7 0
3 years ago
Other questions:
  • A series of instructions that can be grouped together as a single command and are often used to automate a complex set of tasks
    11·2 answers
  • 1) Put the following in order from smallest to largest A) 1,500,000 bytes B) 2,000 kilobytes C) 0.01 petabytes D) 1 Terabyte E)
    8·1 answer
  • What channel will the republian debate be broadcast on?
    6·2 answers
  • Text messaging is an example of nonverbal communication. Please select the best answer from the choices provided. T F
    7·2 answers
  • ___________ is an approach to boundary spanning that results from using sophisticated software to search through large amounts o
    8·1 answer
  • Windows workstations all have elements of server software built-in. What are these elements, and why is the Windows Professional
    9·1 answer
  • Which line in the following program will cause a compiler error?
    9·1 answer
  • (Java) In the ChiliToGo program in Exercise 12, the costs to produce an adult meal and a child’s meal are $4.35 and $3.10, respe
    8·1 answer
  • __________ is a software-enabled technique that can change the hardcoded mac address to any mac address and thus overcome mac ad
    8·1 answer
  • click the view lab button. restart the computer and press the f2 or delete key on your keyboard to enter the bios setup program.
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!