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
Byte pair encoding is a data encoding technique. The encoding algorithm looks for pairs of characters that appear in the string
nika2105 [10]

Answer:

The encoding algorithm looks for pairs of characters that appear in the string more than once and replaces each instance of that pair with a corresponding character that does not appear in the string. ... Byte pair encoding is an example of a lossy transformation because it discards some of the data in the original string.

Explanation:

hope it helps!!

6 0
3 years ago
A continuous and differentiable function f(x) with the following properties: f(x) is decreasing at x=−5 f(x) has a local minimum
butalik [34]

The continuous and differentiable function where f(x) is decreasing at x = −5 f(x) has a local minimum at x = −2 f(x) has a local maximum at x = 2 is given as: y = 9x - (1/3)x³ + 3.

<h3>What is a continuous and differentiable function?</h3>

The continuous function differs from the differentiable function in that the curve obtained is a single unbroken curve in the continuous function.

In contrast, if a function has a derivative, it is said to be differentiable.

<h3>What is the solution to the problem above?</h3>

It is important to note that a function is differentiable when x is set to a if the function is continuous when x = a.

Given the parameters, we state that

f'(5) < 0; and

x = -5

The local minimum is given as:
x = -3;

the local maximum is given as

x = 3

Thus, x = -3 ; alternatively,

x = 3.  With this scenario, we can equate both to zero.

Hence,

x + 3 = 0;

3-x = 0.

To get y' we must multiply both equations to get:

y' = (3-x)(x + 3)

y'   = 3x + 9 - x² - 3x

Collect like terms to derive:

y' = 3x - 3x + 9 - x²; thus

y' = 9-x²

When y' is integrated, the result is

y = 9x - (x³/3) + c

Recall that

F (-5) < 0

This means that:

9 x -5 - (-5³/3) + c < 0
⇒ -45 + 125/3 + c <0
⇒ -10/3 + c < 0

Collecting like terms we have:
c < 10/3; and

c < 3.33


Substituting C into

f(x) = 9x - x³/3 + c; we have

f(x) = 9x - x³/3 + 3, which is the same as  y = 9x - (1/3)x³ + 3.

Learn more about differentiable functions at:
brainly.com/question/15047295
#SPJ1

7 0
2 years ago
Which statement is true regarding bitmap images?
horrorfan [7]
<span>Which statement is true regarding bitmap images?</span>
I believe it is D

8 0
3 years ago
Read 2 more answers
When you connect to an Access database, which entities are shown in the Navigator window?
Leni [432]

1DFASDFAASDASDFASDFADSFASFD

4 0
3 years ago
Read 2 more answers
In what way, if any, can your social media presence affect your chances of getting a job in social media?
Leno4ka [110]

Answer:

Your social media postings can help you secure a job too, not just it being effective in a bad way.

Explanation:

Your content can give hiring managers an overall idea of your personality, what you are passionate about, how you interact with people in group discussions and how previous colleagues feel about you through recommendations and so on. All of these give you an advantage in securing a job.

7 0
2 years ago
Other questions:
  • Put the steps of the decision-making process in the correct order.
    12·1 answer
  • When you use the fill handle to copy a formula to adjacent cells, this creates what kind of cell reference?
    5·1 answer
  • Explain and give examples of at least two search engines.
    9·1 answer
  • Henry, a graphic artist, wants to create posters. Which software should Henry use for this purpose?
    13·1 answer
  • Why does my hp computer keep freezing when i move it?
    10·1 answer
  • Why is plastic durable?
    9·2 answers
  • Which search engine do you prefer? Why
    15·2 answers
  • Not every organization integrates with the Internet, but all use some or most of the technology that gave rise to it.
    15·1 answer
  • If a filesystem has a block size of 4096 bytes, this means that a file comprised of only one byte will still use 4096 bytes of s
    12·1 answer
  • A multiprocessor with 10 processors has 36 attached tape drives. A number of jobs have been submitted to the system where each j
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!