Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a C program to generate a sequence of numbers for each element of the list of integers inList by according to the guidelines that

Write a C program to generate a sequence of numbers for each element of the list of integers inList by according to the guidelines that have been provided. OutList is determined and output based on the counts of the numbers that are contained in each sequence. [10 Marks]
Make sure that you begin with the number that is immediately to the left of the element that you are now working with in the inList.
In order to generate the next number in the sequence, you should begin with the current number as your starting point:
In order to determine the next number, divide the current number by two if it is an even number.
If the current number is an odd number, multiply it by three and then add one to receive the next number.
Until the number 1 is produced, continue to generate numbers by applying the guidelines that were presented earlier.
Find the total number of numbers that are contained in each sequence.
In the same order as the entries appear in the inList, add the counts that have been identified to the result list.
Write a C program that accepts a list called inList as its input and then produces a list of integers that represent the counts of numbers in the sequences that you have generated.
If the input is 6,8,10,5,7, the expected output should be
(immediately to the left of 6)>7->22->11->34->17->52->26->13->40->20->10->5->16->8->4->2->1(Count 17)
(immediately to the left of 8)>6->3->10->5->16->8->4->2->1(Count 9)
(immediately to the left of 10)>8->4->2->1(Count 4)
(immediately to the left of 5)>10->5->16->8->4->2->1(Count 7)
(immediately to the left of 7)>5->16->8->4->2->1(Count 6)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Concepts

Authors: David M. Kroenke, David J. Auer

7th edition

133544621, 133544626, 0-13-354462-1, 978-0133544626

More Books

Students also viewed these Databases questions