Write C+ + statement(s) to do the following: (1, 2)
Declare an array alpha of 50 components of type int.
Initialize each component of alpha to -1.
Output the value of the first component of the array alpha.
Set the value of the 25th component of the array alpha to 62.
Set the value of the 10th component of alpha to three times the value of the 50th component of alpha plus 10.
Use a for loop to output the value of a component of alpha if its index is a multiple of 2 or 3.
Output the value of the last component of alpha.
Output the value of the alpha so that 15 components per line are printed. i. Use a for loop to increment every other element (the even indexed elements). j. Create a new array, diffAlpha, whose elements are the differences between consecutive elements in alpha. What is the size of dif fAlpha?
Trending nowThis is a popular solution!
Chapter 8 Solutions
EBK C++ PROGRAMMING: PROGRAM DESIGN INC
- 2. Test Scores File: test_scores.py Write pseudocode for the main() part of a program that asks the user to enter 4 test scores between 0 and 100, then displays a JCU grade for each score and also the average test score. When you have written the pseudocode for main, implement your solution in Python code and test it with a range of meaningful data. Remember that we've done the JCU grades question before, so copy your function from that practical code file. Sample Output Score: 3 Score: 50.5 Score: 66 Score: 100 Score 3.0, which is N Score 50.5, which is P Score 66.0, which is C Score 100.0, which is HD The average score was 54.875 Enhancements When you have that working... We asked for 4 scores. Have a look at your code... did you use 4 as a numeric literal or a constant?Change 4 to 3... Did you have to change the program in more than one place?If so, then you've missed one of the things we've taught...As a strong guideline: if you need to use the same literal more than once, you…arrow_forwardPrograming in C Write a program that calculates the average grade of a class. 1. You should ask the user how many students you have (you will use this number to set up the length of your array of decimals). 2. Once you have your array, you will have to ask the user for all the grades (there should only be one grade per student). Using a while loop. 3. While you are scanning the grades, you should check if the inputted grade is in the range 0.0 to 10.0 (inclusive). If the grade is not in this range, you should display a message to the user and assign 0.0 to the grade. 4. Once your array is populated with all student's grades, print out the values of the array, so that the user knows these values were saved correctly (use a while loop as well). 5. After this calculate the average (add up all grades and divide by the number of students). Hint: You will need a loop to do so; please use a while loop as well. Example: How many students are in your class? 8 Please input the grades: 8.5 9.8…arrow_forwardC++ While loop to check a number is zero or not. Often the number of times a loop is executed is not predetermined. You may use an input value to signify the end of the loop. Such a value is known as a sentinel value. Write a program that reads and calculates the sum and average of an unspecified number of integers. The input 0 signifies the end of the input.arrow_forward
- Create a program using C++ that satisfies the following requirements: SAMPLE ATTACHED Develop a function called "randomPairsGenerator" that generates and displays pairs of random numbers, with a maximum of 5 pairs per line. Within this function, use a loop to create 20 pairs of random numbers:1) The first number in each pair should be within the range of 1 to 50, inclusive.2) The second number in each pair should be within the range of 51 to 100, inclusive. For each pair, print the two numbers side by side, separated by a space. Separate each pair with a comma. After every 5 pairs, start a new line. After all 20 pairs have been generated, display the total count of pairs in which the sum of the two numbers is divisible by 7.arrow_forwardC++arrow_forwardBEGINNER C++: Hello, I have the programming assignment below and was wondering if I can get some help with some explanations. Thank you very much Write a program that allows two players to play a game of tic-tac-toe. Use a two-dimensional char array with three rows andthree columns as the game board. Each element of the array should be initialized with an asterisk (*). The program should run a loop that Displays the contents of the board arrayAllows player 1 to select a location on the board for an X. The program should ask the user to enter the row and column number.Allows player 2 to select a location on the board for an O. The program should ask the user to enter the row and column number.Determines whether a player has won, or a tie has occurred. If a player has won, the program should declare that player the winner and end.If a tie has occurred the program should say so and end. Player 1 wins when there are three Xs in a row on the game board. The Xs can appear in a row, in a…arrow_forward
- C++ PROGRAM Exercise 1: Average Age of Adults Write a program that computes the average age of adults in a sample population. The program prompts the user to enter the size of the population and then using a for loop, it shall prompt the user for the age of every person in the population. The program shall compute the average age of adults only. Produce output as shown in the sample input/output. Note: an adult is a person whose age is 2 18. Sample input/output: Enter size of population sample : 6 Enter age of person # 1: 20 Enter age of person # 2: 10 Enter age of person # 3: 15 Enter age of person # 4: 24 Enter age of person # 5: 19 Enter age of person # 6: 18 There are 4 adults in the population sample. The average age of adults is: 20.25arrow_forwardSolve in c programming languagearrow_forwardC++ programmingarrow_forward
- It is C++ Goto Loop programming topic. Use [#include (iostream)]. Screenshot the input and output of the program.arrow_forwardUsing C++ Language In this program, you will write a program that uses a function to compute the maximum value in a randomly generated array of integers. Inside your main function, declare an array of size 10. Using a suitable loop, generate seeded randomly generated numbers between 50 and 100 inclusive. Display the randomly generated numbers using a suitable message. Call a function that returns the maximum value of the array. You will need to pass this array to a function. The function does not need to modify the array, hence pass it as a constant array. Use a global constant for the size of the array. You must display the maximum value of the array in the main function.arrow_forwardC++ Write a program that creates an array of size 10 integers.Then you will read these numbersusing “cin”and for loop into the array:1,2,3,4,5,6,7,8,9,10After you read these numbers into the array : 1)Display the content of array by using coutand for loop.2)Use for loop to sum ONLY the odd numbers and display the resultusing “cout”arrow_forward
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningC++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology PtrMicrosoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,
- Programming with Microsoft Visual Basic 2017Computer ScienceISBN:9781337102124Author:Diane ZakPublisher:Cengage LearningProgramming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:Cengage