I have also attached detailed Instructions Enhance your program from Programming Exercise 13 by outputting: The largest number of the sequence a 0 ,a 1 ,a 2 , ..., a k . The position of the largest...

1 answer below »


I have also attached detailed Instructions


Enhance your program fromProgramming Exercise 13by outputting:



  1. The largest number of the sequencea

    0

    ,a

    1

    ,a

    2

    , ..., a

    k
    .

  2. The position of the largest number


For example, for the input sequence:75,226,113,340,170,85,256,128,64,32,16,8,4,2,1, the program output should contain the following:


The largest number of the sequence is 340


The position of the largest number is 4


Test your program for the following values ofx:75,111,678,732,873,2048, and65535.




Instructions Enhance your program from Programming Exercise 13 by outputting: 1. The largest number of the sequence a0 ,a1 ,a2 , ..., ak. 2. The position of the largest number For example, for the input sequence: 75, 226, 113, 340, 170, 85, 256, 128, 64, 32, 16, 8, 4, 2, 1, the program output should contain the following: The largest number of the sequence is 340 The position of the largest number is 4 Test your program for the following values of x: 75, 111, 678, 732, 873, 2048, and 65535. THIS is the code given to work with: #include  #include     using namespace std; int main() {     long x;     int count;     long a_n;     cout < "enter a nonnegative integer: ";     cin ="">> x;     cout < endl;     count =" 0;"     a_n =" x;"><>< ", ";     while (a_n !=" 1)"     {=""         if (a_n % 2 ="= 0)"             a_n =" a_n / 2;"         else=""             a_n =" 3 * a_n + 1;"         count++;=""><><", ";     }="">< endl;><><>< endl;   return 0; } these are what the grading software looks for: tasks 0.00 out of 10.00 correct output for test cases 3 0 out of 3 checks passed. review the results below for more details. checks test caseincomplete test case 2 input 99 output enter a nonnegative integer: 99 99, 298, 149, 448, 224, 112, 56, 28, 14, 7, 22, 11, 34, 17, 52, 26, 13, 40, 20, 10, 5, 16, 8, 4, 2, 1, the integer k such that a_k = 1 is 25 results the largest number of the sequence is 448 the position of the largest number is 4 show details test caseincomplete test case 1 input 10 output enter a nonnegative integer: 10 10, 5, 16, 8, 4, 2, 1, the integer k such that a_k = 1 is 6 results the largest number of the sequence is 16 the position of the largest number is 3 show details test caseincomplete test case 3 input 34 output enter a nonnegative integer: 34 34, 17, 52, 26, 13, 40, 20, 10, 5, 16, 8, 4, 2, 1, the integer k such that a_k = 1 is 13 results the largest number of the sequence is 52 the position of the largest number is 3 expected output the largest number of the sequence is 52 the position of the largest number is 3 0 from the book:   return 0;="" }="" these="" are="" what="" the="" grading="" software="" looks="" for:="" tasks="" 0.00="" out="" of="" 10.00="" correct="" output="" for="" test="" cases="" 3="" 0="" out="" of="" 3="" checks="" passed.="" review="" the="" results="" below="" for="" more="" details.="" checks="" test="" caseincomplete="" test="" case="" 2="" input="" 99="" output="" enter="" a="" nonnegative="" integer:="" 99="" 99,="" 298,="" 149,="" 448,="" 224,="" 112,="" 56,="" 28,="" 14,="" 7,="" 22,="" 11,="" 34,="" 17,="" 52,="" 26,="" 13,="" 40,="" 20,="" 10,="" 5,="" 16,="" 8,="" 4,="" 2,="" 1,="" the="" integer="" k="" such="" that="" a_k="1" is="" 25="" results="" the="" largest="" number="" of="" the="" sequence="" is="" 448="" the="" position="" of="" the="" largest="" number="" is="" 4="" show="" details="" test="" caseincomplete="" test="" case="" 1="" input="" 10="" output="" enter="" a="" nonnegative="" integer:="" 10="" 10,="" 5,="" 16,="" 8,="" 4,="" 2,="" 1,="" the="" integer="" k="" such="" that="" a_k="1" is="" 6="" results="" the="" largest="" number="" of="" the="" sequence="" is="" 16="" the="" position="" of="" the="" largest="" number="" is="" 3="" show="" details="" test="" caseincomplete="" test="" case="" 3="" input="" 34="" output="" enter="" a="" nonnegative="" integer:="" 34="" 34,="" 17,="" 52,="" 26,="" 13,="" 40,="" 20,="" 10,="" 5,="" 16,="" 8,="" 4,="" 2,="" 1,="" the="" integer="" k="" such="" that="" a_k="1" is="" 13="" results="" the="" largest="" number="" of="" the="" sequence="" is="" 52="" the="" position="" of="" the="" largest="" number="" is="" 3="" expected="" output="" the="" largest="" number="" of="" the="" sequence="" is="" 52="" the="" position="" of="" the="" largest="" number="" is="" 3="" 0="" from="" the="">
Answered Same DayOct 30, 2021

Answer To: I have also attached detailed Instructions Enhance your program from Programming Exercise 13 by...

Bikram answered on Oct 30 2021
125 Votes
#include
#include

using namespace std;
int main()
{
long x;
i
nt count,pos=0,largest=1,curpos=1;
long a_n;

cout << "Enter a nonnegative integer: ";
cin >> x;
cout << endl;
count = 0;
a_n = x;
cout << a_n << ", ";
...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here