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
What is blogging
tester [92]
Typically, blogging is online journaling. If you've seen Ask Me Why, she blogs throughout the whole movie and tells those who are watching her blog what is happening in her life. So, the answer is A.
5 0
3 years ago
Read 2 more answers
What are the design concepts and assumptions behind a class, an object and the relationship between them? What are the roles met
Triss [41]

Answer:

Object-oriented programming (OOP) is a procedural language and based on classes associated with an object. Without classes and object relationship OOP is not possible. According to program's design concept classes provide abstraction and encapsulation with the help of object. Object have states and behaviors like cat has states like name, color and  cat has also behaviors like  wagging the tail, eating, jumping etc. A class forms template or blueprints for these states and behaviors because different cats have different behaviors and states.

Methods provide a way for encapsulation and accessing private class members with public methods and static fields are sometimes best alternative for global variable. We can use static field when it same for all and shared by all objects of that class and it can save memory because we do not have to initialize it for each object

8 0
3 years ago
What is data protection
Fiesta28 [93]
Legal safeguards to prevent misuse of information stored on computers, particularly information about individual people.             In other terms it is security for personal information.
3 0
3 years ago
Panes created using the vertical split bar scroll together horizontally. true or false.
Nataly_w [17]
I think the statement given above is false. Panes created using the vertical split bar do not scroll together horizontally. <span>The two </span>panes scroll together vertically, but scroll<span> independently </span>horizontally<span>. Hope this answers the question. Have a nice day.</span>
4 0
3 years ago
56- What is the term used when you press and hold the left mouse key and more the mouse
elena55 [62]

Answer:

i'd say it's dragging, but i'm not 100% sure

Explanation:

8 0
2 years ago
Other questions:
  • The purpose of the ____________ element is to provide a method for a browser to display different images depending on specific c
    14·1 answer
  • When is the bond between the actin and myosin head is broken? when an ATP molecule binds to the myosin head when an ATP molecule
    6·1 answer
  • . A program that can run more than one thread at once is called:
    9·1 answer
  • "To take advantage of these developments in the digital world, new approaches, concepts,instruments, and methods are needed, whi
    8·1 answer
  • How do you change the text style on brainly mobile ?
    12·1 answer
  • Which is not one of the four criteria for proving the correctness of a logical pretest loop construct of the form: while B do S
    14·1 answer
  • Anyone down to play gta later i play on ps4?
    15·2 answers
  • WILL GIVE MORE POINTS, PLEASE HELP!!!
    11·1 answer
  • The complete process for learning through repetition is to read, write, say, rest and revisit the information. Please select the
    12·2 answers
  • How to connect two routers wirelessly to extend range.
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!