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
C++ Programming: From Problem Analysis to Program Design
- Computer Science This is a Microprocessor And Assembly Language Question .Write the code for the question in 8086x emulator.arrow_forwardcode language in c++ using for loops and nested for loopsarrow_forwardCODE USING C++ 3. Place Values by CodeChum Admin Manipulating values from a series of numbers is fun, but let's try exploring the use of loops a little more. How about printing out each digit of a number by place values, in ascending order? Instructions: Create a variable and input a random positive integer. Using while loop, print out each digit of the inputted integer in separate lines, starting from its rightmost digit until the leftmost digit of the number. Tip: Use % 10 to get the rightmost digit, and / 10 to remove it from the number. Another tip: don't forget to consider the case wherein the input is `0` Input A line containing an integer. 214 Output Multiple lines containing an integer. 4 1 2arrow_forward
- Programming Language: C++ Provide some explanation about the code and the loop pls.arrow_forwardCreate 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_forwardAll in one programarrow_forward
- C++arrow_forwardC++ Vector iteration: Sum of excess. Vector testGrades contains NUM_VALS test scores. Write a for loop that sets sumExtra to the total extra credit received. Full credit is 100, so anything over 100 is extra credit. Ex: If testGrades = {101, 83, 107, 90}, then sumExtra = 8, because 1 + 0 + 7 + 0 is 8.arrow_forwardC++ 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_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