QuestionQuestion

Write the code to:
1.                Create an integer array named k with 20 elements (declare k)
2.                Initialize each element of k to 100.
3.                Ask the user to enter each value of the array
4.                Print all elements of the k array
5.                Print all elements of the array in reverse order
6.                Sum all elements of the array
7.                Determine the average of all elements in the array
8.                Find the largest element in the array
9.                Divide all even-numbered elements in the k array by 2. [k[0],k[0],..k[18]
10.               Subtract 1 from every element of the k array.

11.   Give the output from the following code segment:
int test[10];                        
int index;
for (index = 0; index < 10; index++) {
test[index] = index * 2;
}

cout << test[0] << endl;
cout << test[9] << endl;
cout << index << endl;

12.    Set up a two dimensional array called table with 3 rows and 4 columns. (Declare it)
13.    Print the first row of table.

14.      Set up the appropriate array for a tic tac toe board
15.      Print out the tic tac toe board

For each of the following: write complete code (use an array for each).

16.    Design a complete program that will read an array of 200 characters and display to the screen the array and a count of the occurrences of each of the vowels (a, e, i, o, u) in the array. Both upper and lower case vowels should be counted.

Use the following code segment to create and generate the entries for the 200 element test array:
srand((unsigned int)time(0));

char arr[200];
for(int i = 0; i < 200; i++) {
arr[i] = (char)(rand() % 95 + 32);
}

17.    Design an algorithm that will prompt for and receive 10 integers from an operator at a terminal, and count the number of integers whose value is less than the average value of the integers. Your program is to display the average integer value and the count of integers less than average.

18.    Design an algorithm that will prompt for and receive up to 20 integers from an operator at a terminal. The program should then display to the screen the numbers entered and the average of those numbers.

The operator can end input BEFORE 20 integers by entry of a sentinel value of 999. The sentinel value should not be used in the calculation of the average or displayed as part of the number set.

For example, entry of:    1   14   22   5   999    should produce:

The average of [ 1 14 22 5 ] is 10.5

Hint: you can use the break; command to leave a loop early

Solution PreviewSolution Preview

This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse is strictly forbidden.

Write the code to:
1. Create an integer array named k with 20 elements (declare k)

int k [20];

2. Initialize each element of k to 100.

for (int i = 0; i < 20; i++)
{
k[i] = 100;
}

3. Ask the user to enter each value of the array

for (int i = 0; i < 20; i++)
{
cout << "Enter the value to cell "<< i << " of the array: " ;
cin >> k[i];
}...
$25.00 for this solution

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available C-Family Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Decision:
Upload a file
Continue without uploading

SUBMIT YOUR HOMEWORK
We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats