diff_months: 16

CS107: C++ Programming Assignment

Flat 50% Off Order New Solution
Added on: 2023-02-21 09:04:14
Order Code:
Question Task Id: 0

Question 1

Write a program to read five values into an array and print them out in reverse order (Use two independent for loops).

Question 2

Assume the following declarations are made:

const int little = 6, medium = 10;
int k, number[medium];

For each of the following, show what the array looks like after the execution of the code:

a)

for (k = 0; k < medium xss=removed>

b)

for (k = 0; k < little xss=removed xss=removed xss=removed>

c)

number[0] = 1;
k = 1;
do
{
number[k] = 2 * number[k -1];
k++;
}
while (k < medium>

Question 3

Given the statement:

int profit[6] = {150, 300, 500};

What is the value of n, when:

a) n = profit[3]
b) n = profit[0]
c) n = profit[6]

Question 4

What would be printed by the following program segment:

int list[10] = {0};
int k;
for (k = 0; k < 5 xss=removed xss=removed>
      

Question 5

An array contains the elements shown below. The first two elements have been sorted using a selection sort. What would be the value of the elements in the array after three more passes of the selection sort algorithm?

1) 7 8 26 44 13 23 98 57

Question 6

We have the following array:

47 3 66 32 56 92

After two passes of a sorting algorithm, the array has been rearranged as shown below:

3 47 66 32 56 92

Which sorting algorithm is being used? Explain your answer.

Question 7

We have the following array:

80 15 21 72 3 33

After two passes of a sorting algorithm, the array has been rearranged as shown below:

15 21 3 33 72 80

Which sorting algorithm is being used? Explain your answer.

Question 8

An array contains the elements shown below. Using the binary search algorithm, trace the steps followed to find 88. At each loop, including the last, show the contents of low, middle, and high.

8 13 17 26 44 56 88 97

Question 9

The program below searches through an unsorted array for any to numbers that match and stops the search if a match is found. Fill in the missing numbers, variable names, or statements in the space provided:

int numbers[23], cnt1, cnt2, cnt3, testNo;
int match = 0;
for (cnt1 = 0; cnt1 < ______; cnt++)
{
testNo = numbers[cnt1];
for (cnt2 = ______; cnt2 < ______; cnt2++)
{
if (testNo == numbers[______])
{
match = 1;
break;
}
if (match == 1)
{
printf ("A match has been found!\n");
______;
}

Question 10

Based on the following array, what will be the output in each declaration?

char teams[ ] = {'L','a','k','e','r','s','\0','N','e','t','s','\0'};

a) printf(" %s",teams);
b) printf("%s",teams+7);
c) printf("%s",(teams+3));
d) printf("%s",teams[0]);
e) printf("%c",(teams+0)[0]);
f) printf("%c",(teams+5));
g) printf("%c",(teams-200)[202]);


 

 

  • Uploaded By : Katthy Wills
  • Posted on : February 21st, 2023
  • Downloads : 0
  • Views : 306

Order New Solution

Can't find what you're looking for?

Whatsapp Tap to ChatGet instant assistance

Choose a Plan

Premium

80 USD
  • All in Gold, plus:
  • 30-minute live one-to-one session with an expert
    • Understanding Marking Rubric
    • Understanding task requirements
    • Structuring & Formatting
    • Referencing & Citing
Most
Popular

Gold

30 50 USD
  • Get the Full Used Solution
    (Solution is already submitted and 100% plagiarised.
    Can only be used for reference purposes)
Save 33%

Silver

20 USD
  • Journals
  • Peer-Reviewed Articles
  • Books
  • Various other Data Sources – ProQuest, Informit, Scopus, Academic Search Complete, EBSCO, Exerpta Medica Database, and more