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
anzhelika [568]
3 years ago
15

The process of finding the largest and smallest numbers is used frequently in computer applications. Write a C++ program that us

es a while statement to determine and print the largest and the second largest number of x integers entered by the user, where x should also be input by the user.
Computers and Technology
1 answer:
WINSTONCH [101]3 years ago
3 0

Answer:

The program to this question can be given as:

Program:

#include<iostream>  //header file

using namespace std;

int main()    //main method

{

int x[10],i,largest = 0,second_largest=0,n;  //variable

cout << "Enter Number of elements :";  //message

cin>>n;

cout << "Insert array elements :";  //message

for(i=0;i<n;i++)  //insert elements in array

{

cin >>x[i];

}

//Finding Largest element  

for(i=0;i<n;i++)

{

if (x[i]>largest)

{

largest = x[i];

}

}

//finding second largset element

for(i=0;i<n;i++)

{

if (x[i]>second_largest)

{

   if(x[i]==largest)

   {

   continue;   //Ignoring largest in order to get second largest

   }

   second_largest=x[i];

}

}

//print value

cout <<"Largest Number:"<<largest<<endl;

cout <<"Second Largest Number:"<<second_largest;

return 0;

}

Output:

Enter Number of elements :5

Insert array elements :33

45

75

87

23

Largest Number:87

Second Largest Number:75

Explanation:

In the above program firstly we define the header file then we define the main method in the main method we define the array and other variables. We first input the number for the size of the array. Then we insert array elements after inserting array elements we search the largest number and the second largest number in the array. To search the largest number in the array we use the loop. To search the first largest number we define a condition that array is greater than the largest number and store the value into the largest variable. Then we check the second largest number in the array for this we use two conditions that are array is greater than the second largest number in this we use another condition that is array is equal to the largest number. If the inner condition is true then it will move forward and end of an inner condition. In the outer condition, the value will be stored on the second_largest variable all the conditions will be done inner the loop. At the last we print values.

You might be interested in
Luis saves an attachment that he received from Kevin. Where will the attachment save by default?
tia_tia [17]

Answer:

first one I do believe good luck with the answer

6 0
3 years ago
Which is a method used with arrays?<br><br> find<br><br> index<br><br> insert<br><br> sort
Furkat [3]

Answer:

Index

Explanation:

Got it right e2020

4 0
3 years ago
Hawaii and japan are examples of islands made by? You have to write it.
Brums [2.3K]

Answer:

Volcanic activity

5 0
3 years ago
Are technical skills or people skills more important to the team manager in a software development project?
VladimirAG [237]

Answer:

A well-rounded team manager in a software development project is critical to its success. Having the best developers only gets you so far. Without proper leadership, the project will most likely fail. Developers won't know what direction to go, deadlines won't be met, and the end product will not be created to the specifications as set forth in the project. A software development team manager needs to possess both the proper technical skills to guide the developers when they get stuck, but more importantly have the proper people skills and business process skills to allow the team to work as a well-oiled machine. In this paper, we will look at two different types of team managers and how they affect the software development lifecycle.

5 0
4 years ago
Read 2 more answers
Kerning is the adjustment of space between ___ characters.
IrinaK [193]
Answer: printed

Explanation: The definition of kerning is; the spacing between letters or characters in a piece of text to be printed.

4 0
4 years ago
Other questions:
  • Determine the number of bytes necessary to store an uncompressed binary image of size 4000 × 3000 pixels.
    9·1 answer
  • Common icons found on the Windows desktop are _____.
    6·2 answers
  • What is the command to use the memory diagnostics tool?
    11·1 answer
  • I need to create a function that returns Pascal's Triangle with n rows, where n is an int argument.
    12·1 answer
  • Discuss OPENGL instruction to draw the following drawing primatives:
    14·1 answer
  • para que sirve los siguientes sistemas operativos : a. Windows 10 b. Apple yosemite c. linux Ubuntu d. Android marshmallow e. IO
    9·1 answer
  • HELP WILL GIVE BRAINIEST IF YOU HELP ME.....
    8·2 answers
  • 1. Write a programme to print the Fees Receipt of English High School Required Inputs Name of the Student Monthly Tuition Fees M
    10·1 answer
  • 20. Describe the steps that transform a program written in a high-level language such as C into a representation that is directl
    9·1 answer
  • If the middle number is lesser than the candidates then u eliminate the ___ half of the data​
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!